<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle(homeurl.' - Кто online');
$title->GetHeader();
if ($b['level'] == 0) {
header('location:/');
die();
}

$us = DB::$dbs->querySingle("SELECT count(id) FROM `blogger` WHERE `last` > ?", [time()-3600]);
$g = DB::$dbs->querySingle("SELECT count(*) FROM `guests` WHERE `date` > ?", [time()-3600]);
echo '<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/administration/"style="text-decoration:none; color:white;"> Дата-центр</a> :: Кто Online</div></div></div>';
echo '<div class="list-group-item media"><a href="?">Авторизованных ('.$us.')</a> :: <a href="?do=guest">Неавторизованных ('.$g.')</a></div>';

$do = isset($_GET['do']) ? check($_GET['do']) : false;
switch($do) {
default:
//$look = DB::$dbs->querySingle("SELECT count(id) FROM `blogger` WHERE `last` > ? AND `id` != ?", [time()-3600,1]);
$look = DB::$dbs->querySingle("SELECT count(id) FROM `blogger` WHERE `last` > ?", [time()-3600]);

if ($look == 0) {
err('Никого нет...');
}
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
//$sql = DB::$dbs->query("SELECT * FROM `blogger` WHERE `last` > ? AND `id` != ? ORDER BY `last` DESC LIMIT $start,$num",[time()-3600,1]);
$sql = DB::$dbs->query("SELECT * FROM `blogger` WHERE `last` > ? ORDER BY `last` DESC LIMIT $start,$num",[time()-3600]);
while($a = $sql->fetch()) {
echo '<div class="list-group-item media"> '.Nick($a['id']).' </br>'.($a['row']>=0 ? strtr($a['row'], $row).'<br/>':NULL).'Регистрация: '.vr($a['reg']).'<br/>Посл. активность: '.vr($a['last']).'</div>';

}
if ($k_page>1) {
str('?', $k_page,$page);
}
break;
case 'guest':
$look = DB::$dbs->querySingle("SELECT count(*) FROM `guests` WHERE `date` > ?", [time()-3600]);
if ($look == 0) {
err('Никого нет...');
}
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
$sql = DB::$dbs->query("SELECT * FROM `guests` WHERE `date` > ? ORDER BY `date` DESC LIMIT $start,$num",[time()-3600]);
while($a = $sql->fetch()) {
echo '<div class="list-group-item media">IP: '.$a['ip'].'<br/>Soft: '.$a['ua'].'<br/>Посл. активность: '.vr($a['date']).'</div>';
}
if ($k_page>1) {
str('?do=guest&', $k_page,$page);
}
break;
}
echo'</div></div>';

$title->GetMenu();
$title->GetFooter();
?>
