<?
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

$set['title']='Пользователи сайта'; // заголовок страницы
include_once 'sys/inc/thead.php';
title();

$sort='id';

$por='DESC';

if (isset($_GET['ASC']))$por='ASC'; // прямой порядок
if (isset($_GET['DESC']))$por='DESC'; // обратный порядок


switch (@$_GET['sort']) {
	case 'balls':$sql_sort='`user`.`balls`';$sort='balls'; // баллы
 	break;
	case 'level':$sql_sort='`user_group`.`level`';$sort='level'; // уровень
 	break;
	case 'reiting':$sql_sort='`user`.`reiting`';$sort='reiting'; // рейтинг
 	break;
 	default:$sql_sort='`user`.`id`';$sort='id'; // ID
 	break;
}

if (!isset($_GET['go']))
{

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo "<div class='linegreen1'>Сорт:\n";
echo "<a href='?sort=balls&amp;DESC&amp;page=$page'>монеты</a> |\n";
echo "<a href='?sort=level&amp;DESC&amp;page=$page'>статус</a> |\n";
echo "<a href='?sort=reiting&amp;DESC&amp;page=$page'>рейтинг</a> |\n";
echo "<a href='?sort=id&amp;ASC&amp;page=$page'>id</a> |\n";
echo "<a href='?sort=id&amp;DESC&amp;page=$page'>новые</a> \n";
echo "</div>\n";


echo "<table class='post'>\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='komm'>\n";
echo "Нет результатов\n";
echo "  </td>\n";
echo "   </tr>\n";

}
$q=mysql_query("SELECT `user`.`id` FROM `user` LEFT JOIN `user_group` ON `user`.`group_access` = `user_group`.`id` ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_assoc($q))
{
$ank=get_user($ank['id']);
echo "   <tr>\n";
echo '<tr><td class="line">';
onfoto($ank['id']);

echo " <a href='/info.php?id=$ank[id]'><span style=\"color:$ank[ncolor]\"><b>$ank[nick]</b></span></a> \n";

//if ($ank['group_access']>1)echo "<span class='status'>$ank[group_name]</span><br />\n";

if ($sort=='reiting')
echo "<img src='/style/img/reiting.gif' alt='' class='icon'/> <font color='#4d4c4c'> $ank[reiting]</font>\n";
if ($sort=='balls')
echo "<img src='/style/img/coins.gif' alt='' class='icon'/> <font color='#4d4c4c'> $ank[balls]</font>\n";
if ($ank['date_reg']>time()-259200){
echo "<font color='#fcbdee'><b>Новичoк</b></font>\n";
}
echo "<br/>\n";
echo "".online($ank['id'])."\n";
echo "<font color='#9a9795'>".vremja($ank['date_last'])."</font><br />\n";
if ($ank['ank_city']!=NULL)echo " <font color='#424140'>$ank[ank_city]</font><br />\n";
else
echo " <font color='#8f8c85'>Город не указан</font><br />\n";

echo '</td></tr>';
$status=mysql_query("SELECT * FROM `dnev` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC  LIMIT 1");

while ($dnev = mysql_fetch_assoc($status))
{
echo "<td class='hello' colspan='2'><font color='#38386a'>$dnev[name]</font>\n";
}
echo '</td></tr>';
}
echo "</table>\n";
echo "<div class='userline'></div>\n";
if ($k_page>1)str("users.php?sort=$sort&amp;$por&amp;",$k_page,$page); // Вывод страниц

}

include_once 'sys/inc/tfoot.php';
?>