<?php
include ('inc/base.php');
include ('inc/functions.php');
include ('inc/user.php');
$title = 'Онлайн';
include ('inc/header.php');
if(!$user) {
header('location: /');
exit();
}
if($_GET['search'] == 'ok') {
$id = text(num($_POST['id']));
if(!$id) {
echo '<div class="main center">Заполните все поля!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if(strlen($id) > 10) {
echo '<div class="main center">Допустимая длина ID 1-10 символов!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
$us_p = mysql_fetch_array(mysql_query('SELECT * FROM `accounts` WHERE `id` = "'.$id.'" LIMIT 1'));
mysql_free_result($us_p);
if(!$us_p) {
echo '<div class="main center">Профиль не найден!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
header('location: /profile.php?id='.$us_p['id'].'');
exit();
}
$max = text(num($_GET['max']));
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `accounts` where `online` > '".(time() - 86400)."'"),0);
mysql_free_result($k_post);
if($max and $max >= '11') {
$sql = mysql_query("SELECT * FROM `accounts` where `online` > '".(time() - 86400)."' ORDER BY `rating` DESC LIMIT 0, $max");
}else{
$sql = mysql_query("SELECT * FROM `accounts` where `online` > '".(time() - 86400)."' ORDER BY `rating` DESC LIMIT 0, 10");
}
while($on = mysql_fetch_assoc($sql)) {
echo '<a href="/profile.php?id='.$on['id'].'" class="mini-link"><img src="/style/src/online.png"> '.$on['name'].' <span style="float: right">'.$on['rating'].' <img src="/style/src/rating.png"></a>';
mysql_free_result($on);
}
if($k_post > '10' and !$max) {
echo '<div class="new-line"></div><a href="?max='.$k_post.'" class="link center">Показать всех</a>';
}
if($k_post > '10' and $max) {
echo '<div class="new-line"></div><a href="?" class="link center">Скрыть всех</a>';
}
if($k_post < '1') {
echo '<div class="main center">В игре никого нет!</div>';
}
echo '<form action="?search=ok" method="POST" class="main center">ID игрока:<br><input type="text" name="id"><input type="submit" name="search" value="Найти" class="input_send"><div class="new-line"></div></form>';
include ('inc/footer.php');
?>