<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Онлайн';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
$taim = 1800;
$date = time();
$timeou = $date - $taim;
$asd = mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeou' ORDER BY `lvl` DESC");
if(isset($visi['usr'])){
$b = mysql_query("SELECT `lvl`, `usr` FROM `users` WHERE `usr` = '$visi[usr]' ORDER BY `lvl` DESC");
$vis = mysql_fetch_array($b);
}
switch($_GET['mod']){
default:
if ($_GET['page'] == ""){
$_GET['page'] = 0;
}
$next = $_GET['page'] + 1;
$back = $_GET['page'] - 1;
$num = $_GET['page'] * 10;
if($_GET['page'] == "0"){
$i = 1;
}else{
$i = ($_GET['page']*10)+1;
}
//**********
$aver = mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeou' ORDER BY `lvl` DESC LIMIT $num, 10");

if($_GET['page'] == "0"){
$i = 1;
}else{
$i = ($_GET['page']*10)+1;
}
$avto=mysql_num_rows($aver);
$res=mysql_num_rows($asd);
$puslap = floor($res/10);

echo'<div class="main"><div class="block_zero">';
echo'Все игроки | <a href="search.php?">Поиск </a>';
echo'</div><div class="mini-line"></div><div class="block_zero">';
While($visi = mysql_fetch_array($aver)){
$b = mysql_query("SELECT `lvl`, `usr` FROM `users` WHERE `usr` = '$visi[usr]' ORDER BY `lvl` DESC");
$onl = mysql_fetch_array($b);
$refi = mysql_fetch_assoc(mysql_query("SELECT `vip` FROM `set` WHERE `usr` = '$visi[usr]' LIMIT 1"));
$reqi = mysql_query("SELECT `lvl`, `storona`, `pol`, `prava` FROM `users` WHERE `usr` = '$visi[usr]' LIMIT 1");
$avto = mysql_num_rows($reqi);
if($avto>=1){
$ref = mysql_fetch_assoc($reqi);



if($ref['prava']=="5"){$im='adm';$tcolor='9bc';}
if($ref['prava']=="2"){$im='mod';$tcolor='f96';}
if($ref['prava']=="3"){$im='mod3';$tcolor='f96';}
if($ref['prava']=="4"){$im='adm';$tcolor='9cc';}
if($ref['prava']=="0"){$tcolor='fff';}

if($ref['storona']=='white'){
$pers=1;
}else{
$pers=0;
}

if($refi['vip']=='on'){
$tcolor='939';
echo'<img src="image/status/vip.png" width="13 height="13" alt="*"> ';
}
elseif($ref['prava']!=='0'){
echo'<img src="image/icon/'.$pers.'.png" alt="*"> ';
}else{
echo'<img src="image/icon/'.$pers.'.png" alt="*"> ';
}


if($visi['usr']==$log){
echo'<a href="pers.php?"><span style="color: #'.$tcolor.';">'.$visi['usr'].'</span></a>';
}else{
echo'<a href="search.php?nick='.$visi['usr'].'&go=go"><span style="color: #'.$tcolor.';">'.$visi['usr'].'</span></a>';
}
//**********

echo' <img src="image/icon/level.png" alt="*"> '.$ref['lvl'].'';
}
//**********
$vis = mysql_fetch_array(mysql_query("SELECT * FROM `mesto` WHERE `usr` = '$visi[usr]' "));
if($ref['prava']==5){
echo' - где-то здесь<br>';
}else{
echo' - '.$vis['place'].'<br>';
}
$i++;
}
//**********
echo'</div><div class="dot-line"></div><div class="block_zero">';
if ($_GET['page'] > 0){
echo "<a href=\"online.php?page=$back\">«Назад</a>";
}
if ($_GET['page'] > 0 and $_GET['page'] < $puslap){ echo" | ";
} 
if($_GET['page'] < $puslap or $avto > 10){
echo "<a href=\"online.php?page=$next\">Вперeд»</a>";
}
break;
}
echo'</div></div>';
include($path.'files/down.php');
?>