Файл: sysadm/top.php
Строк: 151
<?
define('ROOT','../');
require_once (ROOT.'system/power.php');
$fuser->aut();
$admin->user_can('settings_site',$ya['id'],true,ROOT.'sysadm/');
$diz -> head('Статистика');
$diz -> title('Статистика');
switch($do){
case 'on':
if($db->settings('top')==0){
$db -> query("UPDATE `settings` SET `parametr`='1' where `name`='top'");
}else{
$db -> query("UPDATE `settings` SET `parametr`='0' where `name`='top'");
}
header('Location: ?');
break;
case 'clear':
if(!isset($_GET['true'])){
echo'<div class="fon">'.language('Вы подтверждаете это действие').'?</div>';
echo '<div class="dialog">
<a class="dialog_m" href="?do=clear&true">'.language('Да').'</a>
<a class="dialog_m" href="?">'.language('Нет').'</a>
</div>';
}else{
$db -> query("DELETE FROM `top`");
header('Location: ?');
}
break;
default:
if($db->settings('top')==1)$on='Модуль включен'; else $on='Модуль выключен';
echo '<div class="menu"><a class="menutuch" href="?do=on">'.$diz -> icon('settings.png').' '.language($on).'</a></div>';
echo '<div class="menu"><a class="menutuch" href="?do=clear">'.$diz -> icon('settings.png').' '.language('Очистка').'</a></div>';
echo '<div class="new">'.language('Общие сведения').'</div>';
$all = $db -> dbcount('COUNT(`id`)','top');
if($all>0){
$all_hits = $db -> dbcount('SUM(`hits`)','top');
$all_h_24 = $db -> dbcount('COUNT(`id`)','top',"`time`>'".(time()-86400)."'");
echo '<div class="fon">
'.language('Всего хостов').': <span class="count">'.$all.'</span><br/>
'.language('За последние 24 часа').': <span class="count">'.$all_h_24.'</span><br/>
'.language('Всего переходов').': <span class="count">'.$all_hits.'</span><br/>
</div>';
echo '<div class="new">'.language('Рекорд').'</div>';
$max_h_hits=$max_h_day=$max_h_month=0;
$max_h = $db -> query("SELECT `day`,`month`,COUNT(`id`),`year` FROM `top` group by `day`");
while ($mh = $max_h -> fetch_assoc()) {
if($mh['COUNT(`id`)']>$max_h_hits){
$max_h_hits=$mh['COUNT(`id`)'];
$max_h_day=$mh['day'];
$max_h_month=$mh['month'];
$max_h_year=$mh['year'];
}
}
$max_p_hits=$max_p_day=$max_p_month=0;
$max_p = $db -> query("SELECT `day`,`month`,SUM(`hits`),`year` FROM `top` group by `day`");
while ($mp = $max_p -> fetch_assoc()) {
if($mp['SUM(`hits`)']>$max_p_hits){
$max_p_hits=$mp['SUM(`hits`)'];
$max_p_day=$mp['day'];
$max_p_month=$mp['month'];
$max_p_year=$mp['year'];
}
}
echo '<div class="fon">
'.language('Самая большая посещаемость').' (<span class="count">'.$max_h_hits.'</span>) '.language('была').': <span class="date">'.$max_h_day.' '.$func->mes($max_h_month).' '.$max_h_year.'</span><br/>
'.language('Самое большое количество переходов').' (<span class="count">'.$max_p_hits.'</span>) '.language('было').': <span class="date">'.$max_p_day.' '.$func->mes($max_p_month).' '.$max_h_year.'</span><br/>
</div>';
echo '<div class="new">'.language('Подробная статистика').'</div>';
$day_top = ((!empty($_POST['day']))&&($_POST['day']>0 and $_POST['day']<32)) ? abs(intval($_POST['day'])) : date('d');
$month_top = ((!empty($_POST['month']))&&($_POST['month']>0 and $_POST['month']<13)) ? abs(intval($_POST['month'])) : date('m');
$year_top = ((!empty($_POST['year']))&&($_POST['year']>=date('Y')-1 and $_POST['year']<=date('Y'))) ? abs(intval($_POST['year'])) : date('Y');
$d = 1;
while ($d <= 31) {
if ($d == $day_top) $day .= '<option selected value="'.$d.'">'.$d.'</option>';
else $day .= '<option value="'.$d.'">'.$d.'</option>';
++$d;
}
$m = 1;
while ($m <= 12) {
if ($m == $month_top) $month .= '<option selected value="'.$m.'">'.$func->mes($m).'</option>';
else $month .= '<option value="'.$m.'">'.$func->mes($m).'</option>';
++$m;
}
$year .= '<option selected value="'.date('Y').'">'.date('Y').'</option>';
$year .= '<option value="'.(date('Y')-1).'">'.(date('Y')-1).'</option>';
echo '<div class="fon">
<form action="?" method="POST">
'.language('Выберите дату').':<br/>
<div class="date">
<select name="day">'.$day.'</select>
<select name="month">'.$month.'</select>
<select name="year">'.$year.'</select></div>
<input type="submit" name="submit" value="'.language('Показать').'"/></form>
</div>';
$top_vicible = $db -> query("SELECT * FROM `top` where `day`='".$day_top."' and `month`='".$month_top."' and `year`='".$year_top."' order by `time` DESC");
if($top_vicible->num_rows>0){
while ($st = $top_vicible -> fetch_assoc()) {
echo '<div class="fon">
<b>IP:</b> '.$st['ip'].'<br/>
<b>'.language('Браузер').':</b> '.$st['agent'].'<br/>
<b>'.language('ОС').':</b> '.$st['user'].'<br/>
<b>'.language('Версия').':</b> '.language($st['version']).'<br/>
<b>'.language('Переходов').':</b> '.$st['hits'].'<br/>';
if($st['id']!=0)echo '<b>'.language('Пользователь').':</b> '.$fuser->famname($st['id']).'<br/>';
echo '<b>'.language('Последний переход').':</b> '.$func -> vremja($st['time']).'';
echo '</div>';
}
}else echo '<div class="fon">'.language('Список пуст').'</div>';
}else echo '<div class="fon">'.language('Данных нет').'</div>';
}
echo '<div class="levo"><a href="./" class="levo_tuch">'.$diz -> icon('back.png').' '.language('Управление').'</a></div>';
echo '<div class="levo"><a href="/index.php" class="levo_tuch">'.$diz -> icon('home.png').' '.language('На главную').'</a></div>';
#####Копирайт#######
$diz -> out($msg);
?>