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

  header('location: /');
    
exit;

}

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

switch($action) {
  default:
    
    $title = 'Онлайн';


include './system/h.php';  


?>

<div class='title'><?=$title?></div>
<div class='line'></div>
<div class='content'>Все игроки | <a href='/online/search/'>Поиск</a></div>
<div class='line'></div>
<div class='menu'>
  <li>
<?

    $max = 10;
  $count = mysql_result(mysql_query('SELECT COUNT(*) FROM `users` WHERE `online` > "'.(time() - 600).'"'),0);
  $pages = ceil($count/$max);
   $page = _string(_num($_GET['page']));

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

$q = mysql_query('SELECT * FROM `users` WHERE `online` > "'.(time() - 600).'" ORDER BY `online` DESC, `level` DESC LIMIT '.$start.', '.$max.'');

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

<img src='/images/icon/race/<?=$row['r'].($row['online'] > (time() - 600) ? '':'-off')?>.png' alt='*'/> <a href='/user/<?=$row['id']?>/'><?=$row['login']?></a> <img src='/images/icon/level.png' alt='*'/> <?=$row['level']?> ур<br/>

<?

  }

?>

</li><li class='no_b'><?=pages('?');?></li>
</div>

<?

include './system/f.php';

        break;

case 'search':
    
    $title = 'Поиск игрока';


include './system/h.php';  


$login = _string($_POST['login']);
  if($login) {
    $users = mysql_query('SELECT * FROM `users` WHERE `login` = "'.$login.'"');
    $users = mysql_fetch_array($users);
  
  if($users) {

    header('location: /user/'.$users['id'].'/');

  }
  else
  {
  
  }

  }

?>

<div class='title'><?=$title?></div>
<div class='line'></div>
<div class='content'><a href='/online/'>Все игроки</a> | Поиск</div>
<div class='line'></div>

<div class='content'>
  <form action='/online/search/' method='post'>
    Имя персонажа:<br/><input name='login'/><br/>
    <input type='submit' value='Поиск'/>
  </form>
</div>

<?

include './system/f.php';

  break;

}
  
?>