<?php
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
if ($aut == true) {
switch($do) {
////////////////////////////////////
//		  Список Юзеров			 //
///////////////////////////////////
case 'users':
if (!$id) $id = $ya['id'];
$diz -> head('Список пользователей');
$count = $db -> dbcount('COUNT(`id`)','users');
$diz -> title('Пользователей: '.$count.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if($count>0){
$sql = $db -> query("SELECT `id`,`login`,`sex` FROM `users` ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
$msg .= '<a href="../my/id'.$users['id'].'">'.$func -> user($users['id']).'</a><br/>';
}}else{$msg .='Нет ни одной регистрации..';}
$act = 'statistic.php?do=users';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
////////////////////////////////////
//		  Список парней 		 //
///////////////////////////////////
case 'boys':
if (!$id) $id = $ya['id'];
$diz -> head('Список парней');
$count = $db -> dbcount('COUNT(`id`)','users',"`sex`='m'");
$diz -> title('Парней: '.$count.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if($count>0){
$sql = $db -> query("SELECT `id`,`login` FROM `users` where `sex`='m' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
$msg .= '<a href="../my/id'.$users['id'].'">'.$func -> user($users['id']).'</a><br/>';
}}else{$msg .='Парней ещё нет..';}
$act = 'statistic.php?do=boys';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
////////////////////////////////////
//		  Список девушек		 //
///////////////////////////////////
case 'girls':
if (!$id) $id = $ya['id'];
$diz -> head('Список девушек');
$count = $db -> dbcount('COUNT(`id`)','users',"`sex`='w'");
$diz -> title('Девушек: '.$count.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if($count>0){
$sql = $db -> query("SELECT `id`,`login` FROM `users` where `sex`='w' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
$msg .= '<a href="../my/id'.$users['id'].'">'.$func -> user($users['id']).'</a><br/>';
}}else{$msg .='Девушек ещё нет..';}
$act = 'statistic.php?do=girls';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
////////////////////////////////////
//		  Новенькие      		 //
///////////////////////////////////
case 'newus':
if (!$id) $id = $ya['id'];
$diz -> head('Новички');
$k_u = $db -> dbcount('COUNT(*)','users','`time` > '.(time()-86400).'');
if ($k_u==0)$k_u=0;
else $k_u=''.$k_u;
$diz -> title('Новичков: '.$k_u.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if($k_u>0){
$sql = $db -> query("SELECT `id`,`login`,`sex` FROM `users` where `time` > '".(time()-86400)."' ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
$msg .= '<a href="../my/id'.$users['id'].'">'.$func -> user($users['id']).'</a><br/>';
}}else{$msg .='Новичков пока нет..';}
$act = 'statistic.php?do=newus';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
////////////////////////////////////
//		  Забаненые        		 //
///////////////////////////////////
case 'ban':
if (!$id) $id = $ya['id'];
$diz -> head('Забаненых');
$k_u = $db -> dbcount('COUNT(*)','ban');
$diz -> title('Забаненые: '.$k_u.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
if($k_u>0){
$sql = $db -> query("SELECT * FROM `ban` ORDER BY `id` LIMIT ".$start.",".$num);
while ($users = $sql -> fetch_assoc()) {
$msg .= '<a href="../my/id'.$users['iduser'].'">'.$func -> user($users['iduser']).'</a><br/>';
}}else{$msg .='Забаненых пользователей нет!';}
$act = 'statistic.php?do=ban';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
////////////////////////////////////
//		  В онлайне       		 //
///////////////////////////////////
case 'online':
if (!$id) $id = $ya['id'];
$diz -> head('В онлайне');
$k_u = $db -> dbcount('COUNT(*)','online',"`login`!=''");
$diz -> title('В онлайне: '.$k_u.'');
$msg.='<div class="fon">';
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$sql = $db -> query("SELECT * FROM `online` where `login`!='' ORDER BY `time`  LIMIT ".$start.",".$num);
if($k_u>0){
while ($users = $sql -> fetch_assoc()) {
$u = $db -> query("SELECT `id` FROM `users` where `login`='$users[login]'")->fetch_assoc();
$msg .= '<a href="../my/id'.$users['iduser'].'">'.$func -> user($u['id']).'</a><br/>';
}}else{$msg .='В онлайне ни кого..';}
$act = 'statistic.php?do=online';
$msg .= $func -> pagenav($act,$page,$total);
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="statistic.php">Статистика</a>';
$msg .= '<br/>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
break;
///////////////////////////
//     главная
//////////////////////////
default:
$diz -> head('Статистика');
$diz -> title('Статистика');
$msg.='<div class="fon">';
$users = $db -> dbcount('COUNT(*)','users');
$ulr = $db -> query("SELECT * FROM `users`");
$bans = $db -> dbcount('COUNT(*)','ban');
while($a = $ulr -> fetch_assoc()){
if (strftime("%d.%m.%Y",$a['time']) == date("d.m.Y"))
$cr++;
}
$cre= $cr+0;
$msg .= '<a href="statistic.php?do=users">Всего юзеров: </a><b>'.$users.'</b></br>';
$m = $db -> dbcount('COUNT(`login`)','users',"`sex` = 'm'");
$w = $db -> dbcount('COUNT(`login`)','users',"`sex` = 'w'");
$msg.="<a href='statistic.php?do=boys'>Парней:</a> $m  </br><a href='statistic.php?do=girls'>Девушек:</a> $w <b></b></br>";
$online = $db -> dbcount('COUNT(`session`)','online');
$us = $db -> dbcount('COUNT(`login`)','online',"`login` != ''");
$msg .= "<a href='statistic.php?do=online'>В онлайне:</a> $us</br>";
$msg .= '<a href="statistic.php?do=newus">Новеньких: </a><b>'.$cre.'</b></br>
<a href="statistic.php?do=ban">Забаненых: </a><b>'.$bans.'</b></br>---</br>';

$countmess = $db -> dbcount('COUNT(*)','forum_posts');
$countthem = $db -> dbcount('COUNT(*)','forum_tems');
$r_forum = $db -> dbcount('COUNT(*)','forum_razdel');
$pguest = $db -> dbcount('COUNT(*)','guest');
$fao = $db -> dbcount('COUNT(*)','load_files');
$fs = $db -> dbcount('SUM(`size`)','load_files');
$r_book = $db -> dbcount('COUNT(*)','book_razdel');
$books = $db -> dbcount('COUNT(*)','books');
$chat = $db -> dbcount('SUM(`posts`)','users');
$msg .= 'Тем на <a href="/forum/">форуме:</a> '.$countthem.'</br>
Сообщений на <a href="/forum/">форуме:</a> '.$countmess.'</br>
Разделов на <a href="/forum/">форуме:</a> '.$r_forum.'</br>
Разделов в <a href="/book/">библиотеке:</a> '.$r_book.'</br>
Статей в <a href="/book/">библиотеке:</a> '.$books.'</br>
Файлов в <a href="/load/">загрузках:</a> '.$fao.' ('.$func->size($fs).')</br>
Сообщений в <a href="/guest/">гостевой</a> '.$pguest.'</br>
Сообщений в <a href="/chat/">чате</a> '.$chat.'</br>';
$msg.='</div>';
$msg .= '<div class="levo">'.$diz -> img('back.png').'<a href="./">Назад</a>';
$msg .= '</br>'.$diz -> img('home.png').'<a href="../">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);
}
} else {
header('location: ../aut.php');
}
?>