<?
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();
aut();

/*
==============================================
Этот скрипт выводит 1 случайного "Лидера" и 
ссылку на весь их список.(с) DCMS-Social
==============================================
*/

$k_lider = mysql_result(mysql_query("SELECT COUNT(*) FROM `liders` WHERE `time` > '$time'"),0);

$liders = mysql_fetch_assoc(mysql_query("SELECT * FROM `liders` WHERE `time` > '$time' ORDER BY rand() LIMIT 1"));

if ($k_lider > 0)
{
	echo '<div class="main">';
	$lider = get_user($liders['id_user']);
	echo user::avatar($lider['id'], 0) . user::nick($lider['id'], 1, 1, 1) . '<br />';
	if ($liders['msg'])
		echo output_text($liders['msg']) . '<br />';
	echo '<img src="/style/icons/lider.gif" alt="S"/> <a href="/user/liders/">Все лидеры</a> (' . $k_lider . ')';
	echo '</div>';
}
	
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > '".(time()-600)."'"), 0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

$q = mysql_query("SELECT id, ank_city, pol, ank_d_r, ank_m_r, ank_g_r, ank_o_sebe, url, level, ip, ip_xff, ip_cl, ua, date_last FROM `user` WHERE `date_last` > '".(time()-600)."' ORDER BY `date_last` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0)
{
	echo '<div class="mess">';
	echo 'Сейчас на сайте никого нет';
	echo '</div>';
}

while ($ank = mysql_fetch_assoc($q))
{
	$ank['ank_age'] = null;
		
	if ($ank['ank_d_r'] != NULL && $ank['ank_m_r'] != NULL && $ank['ank_g_r'] != NULL)
	{
		$ank['ank_age'] = date("Y")-$ank['ank_g_r'];
		if (date("n") < $ank['ank_m_r'])
		$ank['ank_age'] = $ank['ank_age'] - 1;
		
		elseif (date("n") == $ank['ank_m_r']&& date("j") < $ank['ank_d_r'])
		$ank['ank_age'] = $ank['ank_age'] - 1;
	}
	
	// Лесенка
	echo '<table with="100%" cellpadding="0" cellspacing="0" class="' . ($num % 2 ? "nav1" : "nav2") . '"><tr>';
	$num++;
echo '<td width="55px">';
	echo avatar($ank['id'], false);
	echo "</td><td>";
	echo group($ank['id']) . user::nick($ank['id'], 1, 0, 0) . (($ank['pol'] == 1) ? '<img src="/style/icons/pol_1.png">' : '<img src="/style/icons/pol_0.png">');
if (isset($user) && $ank['id']!=$user['id']){
	echo " <a href=\"/mail.php?id=$ank[id]\"><img src='/style/icons/mails.png' alt='*' /></a>";
}	
	echo '<br/>'.(($ank['ank_age'] == null) ? '' : ''.ages($ank['ank_age']).'<br/>');
	echo 'Где: ' . otkuda($ank['url']) . ' <br />';
		if ($ank['ank_city'] != NULL)
		echo text($ank['ank_city']).'<br/>';	
		echo 'Последняя активность: ' . vremja($ank['date_last']);
echo '</td></tr></table>';
}


if ($k_page>1)str("?",$k_page,$page); // Вывод страниц

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