<?php
session_start();
include ('private/mysql.php');
include ('tmp/head.php');

echo "<ul class='list_page'><div class='linem'></div>";

$num = 10; 
$page = (int)mysql_real_escape_string(htmlspecialchars(strip_tags($_GET['page']))); 
$result = mysql_query("SELECT * FROM `users` WHERE `online`='".time()."'") or die(mysql_error()); 
$posts = mysql_num_rows($result); 
$total = intval(($posts - 1) / $num) + 1; 
$page = intval($page); 
if(empty($page) or $page < 0) $page = 1; 
if($page > $total) $page = $total; 
$start = $page * $num - $num; 


$q = mysql_query("SELECT * FROM `users` WHERE `online`>'".time()."' ORDER BY `id` ASC LIMIT $start, $num");

While($w = mysql_fetch_assoc($q)){
    
    $us = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id`='$w[id]'"));
    
    if($us['access']=='3'){$stt="<small>[<font color=lightgreen>A</font>]</small>";}
    if($us['access']=='2'){$stt="<small>[<font color=#3366FF>MD</font>]</small>";}
    if($us['access']=='0'){$stt="";}
    
    echo "<li><a href='user.php?id=$w[id]'>$stt ";
    if($us['storona']=='white'){
        echo "<img src='img/white.png' width='14'>";
    }
    if($us['storona']=='dark'){
        echo "<img src='img/dark.png' width='14'>";
    }
    echo " $us[login]</a></li>";
    
}
	if ($page != 1) $pervpage = '<a href=?page=1>««</a> 
                               <a href=?page='. ($page - 1) .'>«</a> '; 
	if ($page != $total) $nextpage = ' <a href=?page='. ($page + 1) .'>»</a> 
                                   <a href=?page=' .$total. '>»»</a>'; 

	if($page - 2 > 0) $page2left = ' <a href=?page='. ($page - 2) .'>'. ($page - 2) .'</a> | '; 
	if($page - 1 > 0) $page1left = '<a href=?page='. ($page - 1) .'>'. ($page - 1) .'</a> | '; 
	if($page + 2 <= $total) $page2right = ' | <a href=?page='. ($page + 2) .'>'. ($page + 2) .'</a>'; 
	if($page + 1 <= $total) $page1right = ' | <a href=?page='. ($page + 1) .'>'. ($page + 1) .'</a>'; 

	echo $pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage; 

echo "</ul>";

include ('tmp/foot.php');
?>