<?
include 'system/bd.php';
include 'system/cook.php';
include ("system/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include 'system/head.php';
include 'system/head1.php';


switch($_GET[mod]){
default:

echo'<div class="title"> Топ игроков</div>';



$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `exp` >='0' "),0);

$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';


$req = mysql_query("SELECT `login`,`exp`, `id`, `rasa`, `storona`, `online`, `lvl`,`prava` FROM `user` WHERE `lvl` >='0'  ORDER BY lvl DESC LIMIT $start,$cop ");
////////////////////////////

$avto=mysql_num_rows($req);
if($avto>=1){
While($us = mysql_fetch_array($req))
{
echo '<div class="block_link">';
echo"
<a href='users.php?id=$us[id]'>";



$d = time()-7000;
if($us[online] < $d) { 
echo"<img src='img/user/icons/".$us[storona]."_".$us[rasa]."_off.png'>"; 
}else{
echo"<img src='img/user/icons/".$us[storona]."_".$us[rasa].".png'>";
}
 echo "$us[login] <img src='/img/icon/lvl.png' alt='*'/> $us[lvl] ";

if($us[prava] == '3' ){
echo "<font color='orange'> [Админ] </font> ";}
if($us[prava] == '2' ){
echo "<font color='lime'> [Модератор] </font> ";}
if($us[prava] == '1' ){
echo "<font color='yellow'> [Консультант] </font> ";}

echo '</a> </div>';
echo ' <div class="line"> </div>';
}


echo '
<div class="empty_block top pagi item_center">';
if($page-1>0){

echo '<a href="?&page='.($page-1).'">&lt;</a> ';

}

if($page-1>0){

echo '<a href="?&page='.($page-1).'">'.($page-1).'</a> ';

}

echo '<b>'.$page.'</b>';

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">'.($page+1).'</a>';

}

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">&gt;</a>';

}

echo "</div>";


}else{
echo "<img src='/pic/main/!.png' alt='*'/> Нет игроков.";
}


echo ' <div class="block_link">
 <table width="100%" border="0" cellpadding="0" cellspacing="0" style="color:#E5CBB7">
<tbody>
<tr>
<td align="center" width="50%"><a href="?">
Игроки</a></td> 

<td align="center"><a href="?mod=clan">Кланы</a>
</td></tr></tbody></table></div>';


break;

case 'clan':
echo'<div class="title">Топ кланов</div>';
$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `clans` WHERE `exp` >='0' "),0);

$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';


$req = mysql_query("SELECT `name`,`exp`,`id`,`leader`, `lvl` FROM `clans` WHERE `exp` >='0'  ORDER BY exp DESC LIMIT $start,$cop ");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($clan5 = mysql_fetch_array($req))
{
echo '<div class="block_link">';
echo"  <a href=\"clan/clans.php?id=$clan5[id]\">$clan5[name]
<img src='/img/icon/lvl.png' alt='*'/> $clan5[lvl]
</a></div>";

}

echo '
<div class="empty_block top pagi item_center">';

if($page-1>0){

echo '<a href="?&page='.($page-1).'">&lt;</a> ';

}

if($page-1>0){

echo '<a href="?&page='.($page-1).'">'.($page-1).'</a> ';

}

echo '<b>'.$page.'</b>';

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">'.($page+1).'</a>';

}

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">&gt;</a>';

}
echo "</div>";


}else{
echo "<center><div class='block'>Нет кланов </div></center>";
}

echo ' <div class="block_link">
 <table width="100%" border="0" cellpadding="0" cellspacing="0" style="color:#E5CBB7">
<tbody>
<tr>
<td align="center" width="50%"><a href="/ratings.php">
Игроки</a></td> 

<td align="center"><a href="?mod=clan">Кланы</a>
</td></tr></tbody></table></div>';
echo ' <div class="line"></div></div>';

echo ' <div class="block_link">
<a href="/clan/">
<img src="/img/images/arrow.png"> Создать клан </a></div>';
break;

}
}else{
header ("Location: index.php"); exit;
}
include 'system/foot.php';
?>
