<?

include_once "../SYSTEM/include/functions.php";

include_once "../SYSTEM/include/mysql.php";

include_once "../SYSTEM/include/param.php";

include_once "../SYSTEM/include/ban.php";

include_once "../SYSTEM/include/sess.php";

include_once "../SYSTEM/include/ban_2.php";

include_once "../SYSTEM/include/theme.php";

$mesto='СТАТИСТИКА ПОЛЬЗОВАТЕЛЕЙ';

$title='СТАТИСТИКА ПОЛЬЗОВАТЕЛЕЙ';

head();


echo "<div class=\"h\">Статистика юзеров</div><hr />\n";

if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";


if (isset($user))

$k_p_str=$user['k_page'];

else

$k_p_str=$set['k_p_s'];

if ($onl['users']!="0")

{

$v_pages_okr=$onl['users']/$k_p_str%100;

$v_pages_tochn=$onl['users']/$k_p_str;

if ($v_pages_okr==$v_pages_tochn)

$k_page=$v_pages_okr;

else

$k_page=$v_pages_okr+1;

}

$page=1;

if (isset($_GET['page']) && intval($_GET['page'])>0)

$page=intval($_GET['page']);

elseif (isset($_GET['page']) && $_GET['page']=='end')

$page=$k_page;

if ($k_page<$page){$page=$k_page;}

if (0>$page){$page=1;}

$i=$k_p_str*$page-$k_p_str;


echo "<div class=\"str\">";

echo "Сорт: ";

echo "<a href=\"users.php?sort=time&amp;page=$page\">время</a> | \n";

echo "<a href=\"users.php?sort=balls&amp;page=$page\">баллы</a> | \n";

echo "<a href=\"users.php?sort=level&amp;page=$page\">статус</a> | \n";

echo "<a href=\"users.php?sort=rating&amp;page=$page\">рейтинг</a> | \n";

echo "<a href=\"users.php?sort=id&amp;page=$page\">id</a> | \n";

echo "<a href=\"users.php?sort=pol&amp;page=$page\">пол</a> | \n";

echo "<a href=\"users.php?sort=new&amp;page=$page\">новые</a> | \n";

echo "<a href=\"users.php?sort=pereh&amp;page=$page\">переходы</a> | ";

echo "<a href=\"users.php?sort=time_all&amp;page=$page\">время на сайте</a>";

echo "</div>\n<hr />\n";






$asc='DESC';

$order='time';

if (isset($_GET['sort']) && $_GET['sort']=='balls')$order='balls';

elseif (isset($_GET['sort']) && $_GET['sort']=='level')$order='level';

elseif (isset($_GET['sort']) && $_GET['sort']=='rating')$order='rating';

elseif (isset($_GET['sort']) && $_GET['sort']=='id'){$order='id'; $asc='ASC';}

elseif (isset($_GET['sort']) && $_GET['sort']=='new'){$order='id'; $asc='DESC';}

elseif (isset($_GET['sort']) && $_GET['sort']=='pol'){$order='pol';$asc='ASC';}

elseif (isset($_GET['sort']) && $_GET['sort']=='pereh'){$order='pereh';$asc='DESC';}

elseif (isset($_GET['sort']) && $_GET['sort']=='time_all'){$order='time_all';$asc='DESC';}



$q = mysql_query("SELECT * FROM `$mysql[pref]users` ORDER BY $order $asc LIMIT $i, $k_p_str;");

while ($post_user = mysql_fetch_array($q))

{


echo "<div class=\"mess\">\n";

user_pic($post_user['id']);

user_nick($post_user['id'], "../info.php?id=$post_user[id]");


if ($order=='time')

echo "<br />\n<span style=\"color:$color[post_time]\">".vremja($post_user['time']+$timesdvig)."</span>";


if ($order=='rating')

{

if (is_file("../SYSTEM/themes/$them/rating/rating.php"))

echo "<br />\n<img src=\"../SYSTEM/themes/$them/rating/rating.php?r=$post_user[rating]\" alt=\"Рейтинг\" />";

else

echo "<br />\n<img src=\"rating.php?r=$post_user[rating]\" alt=\"Рейтинг\" />";

}


if ($order=='id')

echo " (id=$post_user[id])";


if ($order=='balls')

echo "<br />\n$post_user[balls] баллов";


if ($order=='level')

{

if ($post_user['level']==0){echo "<br />\nЮзер";}

if ($post_user['level']==1){echo "<br />\nМодератор";}

if ($post_user['level']==2){echo "<br />\nСупермодератор";}

if ($post_user['level']==3){echo "<br />\nАдминистратор";}

if ($post_user['level']==4){echo "<br />\nГлавный админ";}

}


if ($order=='pereh')
{
echo "<br />\n$post_user[pereh] переходов";
}

if ($order=='time_all')
{
$ank_time = $post_user['time_all'];

$ank_time_h = floor($ank_time/3600);
$ank_time = $ank_time%3600;

$ank_time_m = floor($ank_time/60);
$ank_time = $ank_time%60;

echo "<br />\n{$ank_time_h}ч. {$ank_time_m}мин. {$ank_time}сек.";
}

echo "</div>\n";
echo "<br />\n";
}



echo "<hr />\n<div class=\"str\">";
str("users.php?sort=$order&amp;",$k_page,$page);
echo "</div>\n";





echo "<hr />\n";
echo "<a href=\"../index.php\">&lt;&lt; На главную</a>\n";
foot();
?>
