<?
    
    include './system/common.php';
    
 include './system/functions.php';
        
      include './system/user.php';
    
if(!$user) {

  header('location: /');
    
exit;

}


    $title = 'Рейтинг';    

include './system/h.php';  

?>



<?

$sort = _string($_GET['sort']);



    $max = 1000;
  $count = mysql_result(mysql_query('SELECT COUNT(*) FROM `users`'),0);
  $pages = ceil($count/$max);
   $page = _string(_num($_GET['page']));

    if($page > $pages) {
    
   $page = $pages;
    
    }
  
    if($page < 1) {
    
   $page = 1;
    
    }
    
  $start = $page * $max - $max;


  if($page == 1) {
  
    $i = $page - 1;
  
  }
  elseif($page == 2) {
    
    $i = ($page + 999);
  
  }
  else
  {
  
    $i = ($page * 1000) - 999;
  
  }

switch($sort) {
    default:
$q = mysql_query('SELECT * FROM `users` ORDER BY `str`+`vit`+`agi`+`def` DESC LIMIT '.$start.', '.$max.'');
      break;
case 'level':
$q = mysql_query('SELECT * FROM `users` ORDER BY `level` DESC LIMIT '.$start.', '.$max.'');
      break;
case 'coliseum':
$q = mysql_query('SELECT * FROM `users` ORDER BY `coliseum_rating` DESC LIMIT '.$start.', '.$max.'');
      break;
case 'm':
$q = mysql_query('SELECT * FROM `users` ORDER BY `s` DESC LIMIT '.$start.', '.$max.'');
      break;
}

  while($row = mysql_fetch_array($q)) {

  $i++;

    if($i == 1) {

    $w_1 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_1'].'"');
    $w_1 = mysql_fetch_array($w_1);


if(!$w_1) {

$w_1['item'] = 0;

}

    $w_2 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_2'].'"');
    $w_2 = mysql_fetch_array($w_2);

if(!$w_2) {

$w_2['item'] = 0;

}


    $w_3 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_3'].'"');
    $w_3 = mysql_fetch_array($w_3);

if(!$w_3) {

$w_3['item'] = 0;

}


    $w_4 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_4'].'"');
    $w_4 = mysql_fetch_array($w_4);

if(!$w_4) {

$w_4['item'] = 0;

}


    $w_5 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_5'].'"');
    $w_5 = mysql_fetch_array($w_5);

if(!$w_5) {

$w_5['item'] = 0;

}


    $w_6 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_6'].'"');
    $w_6 = mysql_fetch_array($w_6);

if(!$w_6) {

$w_6['item'] = 0;

}


    $w_7 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_7'].'"');
    $w_7 = mysql_fetch_array($w_7);

if(!$w_7) {

$w_7['item'] = 0;

}


    $w_8 = mysql_query('SELECT * FROM `inv` WHERE `user` = "'.$row['id'].'" AND `id` = "'.$row['w_8'].'"');
    $w_8 = mysql_fetch_array($w_8);

if(!$w_8) {

$w_8['item'] = 0;

}

switch($sort) {
     default:

?>

<div class="title-top">Топ-1000 / По параметрам</div>

<?

      break;
case 'level':

?>

<div class="title-top">Топ-1000 / По уровню</div>

<?

      break;

case 'coliseum':

?>

<div class="title-top">Топ-1000 / Рейтинг колизея</div>

<?

      break;
case 'm':

?>

<div class="title-top">Топ-1000 / По монетам</div>

<?

break;

    }

?>
<div class="separ2"></div><div class="list"><div class="menu_link2" style="padding:0"><table style="width:100%;color:#a5a5a5"><tr><td colspan="3"><table><tr><td style="width:125px"><img src="/images/maneken/<?=$row['sex']?>.png" alt="" style="border-radius:2px;border:1px solid #131313"/></td><td><img src='/xaos/style2/<?=$row['r']?>.png' alt=''/> <a href="/user/<?=$row['id']?>" style="color:khaki"><?=$row['login']?></a>  <img src="http://213.239.195.28/xaos/style2/rat/pow.png" alt=""/>  <?=n_f($row['str']+$row['vit']+$row['def'])?><br/><img src="http://213.239.195.28/xaos/16x16/tower.png" alt=""/> <a href="/clan/<?=$row['id']?>"><?=$clan['name']?></a><br/><br/>
<img src="http://213.239.195.28/xaos/16x16/sword.png" alt=""/> Сила: <span style="color:khaki"><?=$row['str']?></span><br/>
<img src="http://213.239.195.28/xaos/style/heart.png" alt=""/> Здоровье: <span style="color:khaki"><?=$row['vit']?></span><br/>
<img src="http://213.239.195.28/xaos/style2/shield1.png" alt=""/> Защита: <span style="color:khaki"><?=$row['def']?></span><br/>
<img src="http://213.239.195.28/xaos/16x16/sum.png" alt=""/> Сумма:  <span style="color:khaki"><?=($row['str']+$row['vit']+$row['def'])?></span><br/>
 </td></tr></table></td></tr><tr><td colspan="3"><div class="separ"></div></td></tr></table>


<?

    }
    else
    {

?>

</div><div class="menu_link">
<table style="width:100%;color:#a5a5a5">
<tr>
<td style="width:25px">
2.</td><td><img src="/xaos/style2/<?=$row['r']?>.png" alt=""/> <a href="/user/<?=$row['id']?>/" style="color:khaki"><?=$row['login']?></a> 
</td><td style="text-align:right"><?=($row['str']+$row['vit']+$row['def'])?> <img src="http://213.239.195.28/xaos/style2/rat/pow.png" alt=""/>
</td></tr></table></div>


<?

switch($sort) {
     default:

?>


<?

       break;
 case 'level':

?>

<b><?=$row['level']?></b>

<?

      break;
    
case 'coliseum':

?>

<?=$row['coliseum_rating']?>

<?

      break;
    
case 'm':

?>

<?=$row['s']?>



<?

      break;
    
    }
?>


<?

    }
  
  }
  
?>


</div><div class="separ"></div><div class="menu_link2"><div class="div_hr2"></div><center><div class="navi"><?=pages('/rating/'.$sort.'/?');?></div></div>

</div>
</div></center></div><div class="separ"></div><a href="/rating/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/pow.png" alt=""/> По параметрам</a><a href="/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/batt.png" alt=""/> Боевой рейтинг</a><a href="/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/mark.png" alt=""/> По боевым маркам</a><a href="/rating/coliseum/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/duel_point.png" alt=""/> Рейтинг колизея</a><a href="/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/duel_pl.png" alt=""/> Рейтинг нападений</a><a href="/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/job.png" alt=""/> Рейтинг заданий</a><a href="/rating/m/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/money.png" alt=""/> По монетам</a><a href="/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/exp.png" alt=""/> По опыту</a><a href="/rating/level/" class="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/lv.png" alt=""/> По уровню</a><a href="/" class ="menu_link"><img src="http://213.239.195.28/xaos/style2/rat/mineral.png" alt=""/> По минералам</a></div><div class="separ3"></div>
<div>

<?
  
include './system/f.php';

?>