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

echo '<div class="container-fluid page_header"><div class="container"><div class="row"><div class="col-xs-12 col-sm-8 col-md-9 col-lg-9"><h1>Сейчас в сети </h1><ol class="breadcrumb" xmlns:v="http://'.homeurl.'/#"><li typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">'.homeurl.'</a></li><li class="active" typeof="v:Breadcrumb"><span property="v:title">Кто online</span></li></ol></div></div></div></div>';
echo'<div class="container page_body"><div class="row"><div class="col-xs-12 page_content col-lg-9"><div class="navbar page_content_navbar collapse hidden-lg"><div class="container-fluid"><div class="navbar-collapse"></div></div></div><div class="text_box hidden-lg pr_block_small hidden"></div><div class="container-fluid cols_table">';

echo '<div class="catSides"><a href="/"><i class="md-format-list-bulleted"></i> Главная </a> - Кто online</div>';
$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="row text_box"><i class="md-apps"></i> <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="row"><div class="col-xs-3 col-sm-1"><div class="user_brief"> '.Nick($a['id']).' </br>'.($a['row']>=0 ? strtr($a['row'], $row).'<br/>':NULL).'Регистрация: '.vr($a['reg']).'<br/>Посл. активность: '.vr($a['last']).' </div></div></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="row text_box">IP: '.$a['ip'].'<br/>Soft: '.$a['ua'].'<br/>Посл. активность: '.vr($a['date']).'</div>';
}
if ($k_page>1) {
str('?do=guest&', $k_page,$page);
}
break;
}

///Подключаем меню
$title->GetMenu();

///Подключаем футер
$title->GetFooter();
?>
