<?php
define('NTLCMS', 1);
$module = 'who';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
$chatonline = DB :: run() -> querySingle("select count(`id`) from `users` where `where` = 'chat' and `ontime` > ?", array(TIME - 180));
if ($set['chat'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><b>'.razd.' Беседка - '.$chatonline.' чел</b></div>';
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Модуль закрыт администратором!</center></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
exit;
}
echo '<div class="title"><b>'.razd.' Кто в беседке?</b></div>';
$k_post = DB :: run() -> querySingle("select count(`id`) from `users` where `where` = 'chat' and `ontime` > ?", array(TIME - 180));
$k_page = k_page($k_post, $onpage); 
$page = page($k_page); 
$start = $onpage * $page - $onpage;
$sql = DB :: run() -> query("select (`login`), (`ontime`) from `users` where `where` = 'chat' and `ontime` > ? limit ".$start.", ".$onpage, array(TIME - 180));
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> В беседке никого нет!</center></div>';
} else {
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<div class="menu">'.ava($row -> login).' '.login($row -> login, 1).' <sup>'.lasttime($row -> ontime).'</sup></div>';
}
if ($k_page > 1) navigation(URL.'/chat_who?', $k_page, $page);
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/chats">В беседку</a></div>';
include ('../system/foot.php');
?>