<?php
define('PROTECTOR', 1);

$head = 'online';//фикс. места

$textl='Игроки онлайн';
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');
///////////////
$taim = 180;
$date = time();
$timeou = $date - $taim;
////////////////
$asg = mysql_query("SELECT * FROM guest WHERE laikas > '$timeou' ");
$noreg=mysql_num_rows($asg);
$asd = mysql_query("SELECT laikas, usr FROM online WHERE laikas > '$timeou' ORDER BY lvl DESC");
$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 "<b>Игроки:</b></div><div class='menu'>";
echo'<ul class="nav">';
While($visi = mysql_fetch_array($aver))
{
$onl = mysql_fetch_array($b);
$seti = mysql_query("SELECT vip FROM `set` WHERE `usr` = '$visi[usr]' LIMIT 1");
$refi = mysql_fetch_assoc($seti);
$reqi = mysql_query("SELECT lvl,storona FROM `users` WHERE `usr` = '$visi[usr]' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($reqi);
if($avto>=1){
$ref = mysql_fetch_assoc($reqi);
echo'<li> <a href="search.php?nick='.$visi[usr].'&go=go"><font color="white">'.$i.'. </font> '.$visi[usr].'';
if($refi[vip]==on){echo' <img src="pic/vip.gif" alt="#"/>';}else
{echo'<img src="pic/main/'.$ref['storona'].'.png" alt="#"/>';}
echo'<img src="pic/main/up.png" alt="lvl"/>'.$ref['lvl'].'<font color="white">';
}

$b = mysql_query("SELECT * FROM mesto WHERE usr = '$visi[usr]' ");
$vis = mysql_fetch_array($b);
if($vis[place]=="online"){echo' (Смотрит онлайн)';$a=1;}
if($vis[place]=="kazino"){echo' (В казино)';$a=1;}
if($vis[place]=="pitomec"){echo' (В питомнике)';$a=1;}
if($vis[place]=="towers"){echo' (На башнях)';$a=1;}
if($vis[place]=="search"){echo' (В поиске)';$a=1;}
if($vis[place]=="elexirs"){echo' (В лавке элексиров)';$a=1;}
if($vis[place]=="msg"){echo' (Читает сообщения)';$a=1;}
if($vis[place]=="main"){echo' (В кабинете)';$a=1;}
if($vis[place]=="okrestnosti"){echo' (В Сражениях)';$a=1;}
if($vis[place]=="boss"){echo' (Бьёт босса)';$a=1;}
if($vis[place]=="arena"){echo' (На арене)';$a=1;}
if($vis[place]=="shopaura"){echo' (В магазине)';$a=1;}
if($vis[place]=="almaz"){echo' (В лавке драгоценностей)';$a=1;}
if($vis[place]=="chat"){echo' (В чате)';$a=1;}
if($vis[place]=="forum"){echo' (На форуме)';$a=1;}
if($vis[place]=="library"){echo' (В библиотеке)';$a=1;}
if($vis[place]=="pers"){echo' (В настройках)';$a=1;}
if($vis[place]=="shop"){echo' (В магазине)';$a=1;}
if($vis[place]=="adm_panel"){echo' (В админ-панели)';$a=1;}
if($vis[place]=="mod_panel"){echo' (В модер-панели)';$a=1;}
if($vis[place]=="inventar"){echo' (В инвентаре)';$a=1;}
if($vis[place]=="clanroom"){echo' (В клане)';$a=1;}
if($vis[place]=="auktion"){echo' (На аукционе)';$a=1;}
if($vis[place]=="rating"){echo' (В достижениях)';$a=1;}
if($vis[place]=="duel"){echo' (На дуэли)';$a=1;}
if($a!==1){echo" $vis[place]";}
echo'</font></a></li>';$i++;
}
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>";}
echo"</div>$div<a href=\"online.php?mod=guest\">Гости ($noreg)</a>";
break;

case 'guest':
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 * FROM guest WHERE laikas > '$timeou' LIMIT $num, 10");
if($_GET[page] == "0"){$i = 1;}else{$i = ($_GET[page]*10)+1;}
$avto=mysql_num_rows($aver);
$res=mysql_num_rows($asg);
$puslap = floor($res/10);
echo "<b>Гости:</b></div><div class='menu'>";
echo'<ul class="nav">';
While($visi = mysql_fetch_array($aver))
{

echo"<li> $visi[brauser] $visi[ip]</li>";

}
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>";}
echo"</div>$div<a href=\"online.php?\">«Назад</a>";
break;

}
include('files/down.php');
?>