<?php
$title = 'Полная статистика рейтинга';
require_once ('Sys/head.php');
if (file_exists('Cache/statsAllTop.cache') AND ($time-60) < filemtime('Cache/statsAllTop.cache') AND $cache['AllTopStats'] > 0)
{
echo implode('', file ('Cache/statsAllTop.cache'));
}
else
{
ob_start();
$stats = array();
$query = $mysqli->query("SELECT * FROM `".$prefix."stats`");
while($queryy = $query->fetch_assoc())
{
$stats[$queryy['name']] = $queryy['value'];
}
$plaformsNoMod = $mysqli->query("SELECT `id` FROM `".$prefix."sait` WHERE `status` = '0'")->num_rows;
$plaformsMod = $mysqli->query("SELECT `id` FROM `".$prefix."sait` WHERE `status` = '1'")->num_rows;
$plaformsAll = $mysqli->query("SELECT `id` FROM `".$prefix."sait`")->num_rows;
$usersAll = $mysqli->query("SELECT `id` FROM `".$prefix."users`")->num_rows;
$newsAll = $mysqli->query("SELECT `id` FROM `".$prefix."news`")->num_rows;
$catAll = $mysqli->query("SELECT `id` FROM `".$prefix."cat`")->num_rows;
$daym = date("d");
$yesterdayHosts = 0;
$yesterdayHits = 0;
$yesterdayIn = 0;
$yesterdayOut = 0;
if($daym - 1 > 0)
{
$yd = $daym - 1;
if(strlen($yd) == 1)
{
$yd = '0'.$yd;
}
$month = date("m");
$yday1 = $mysqli->query("SELECT * FROM `".$prefix."days` WHERE `month` = '".$month."'");
if($yday1->num_rows > 0)
{
while($row = $yday1->fetch_assoc())
{
if(!empty($row[''.$yd.'']))
{
$yday = explode('|',$row[''.$yd.'']);
$yesterdayHosts += $yday[0];
$yesterdayHits += $yday[1];
$yesterdayIn += $yday[2];
$yesterdayOut += $yday[3];
}
}
}
}
else
{
if(date("m") - 1 > 0)
{
$month = date("m") - 1;
if(strlen($month) == 1)
{
$month = '0'.$month;
}
$yd = cal_days_in_month(CAL_GREGORIAN, $month, date("Y"));
$yday1 = $mysqli->query("SELECT * FROM `".$prefix."days` WHERE `month` = '".$month."'");
if($yday1->num_rows > 0)
{
while($row = $yday1->fetch_assoc())
{
if(!empty($row[''.$yd.'']))
{
$yday = explode('|',$row[''.$yd.'']);
$yesterdayHosts += $yday[0];
$yesterdayHits += $yday[1];
$yesterdayIn += $yday[2];
$yesterdayOut += $yday[3];
}
}
}
}
}
$daym7 = date("d");
$dayHosts = 0;
$dayHits = 0;
if($daym7 > 0)
{
$yd7 = $daym7 ;
if(strlen($yd) == 1)
{
$yd7 = '0'.$yd7;
}
$month7 = date("m");
$yday17 = $mysqli->query("SELECT * FROM `".$prefix."days` WHERE `month` = '".$month7."'");
if($yday17->num_rows > 0)
{
while($row = $yday17->fetch_assoc())
{
if(!empty($row[''.$yd7.'']))
{
$yday7 = explode('|',$row[''.$yd7.'']);
$dayHosts += $yday7[0];
$dayHits += $yday7[1];
}
}
}
}
else
{
if(date("m") > 0)
{
$month7 = date("m");
if(strlen($month7) == 1)
{
$month7 = '0'.$month7;
}
$yd7 = cal_days_in_month(CAL_GREGORIAN, $month7, date("Y"));
$yday17 = $mysqli->query("SELECT * FROM `".$prefix."days` WHERE `month` = '".$month7."'");
if($yday17->num_rows > 0)
{
while($row = $yday17->fetch_assoc())
{
if(!empty($row[''.$yd7.'']))
{
$yday7 = explode('|',$row[''.$yd7.'']);
$dayHosts += $yday7[0];
$dayHits += $yday7[1];
}
}
}
}
}
///////////////////////////////
$newsAll = $mysqli->query("SELECT `id` FROM `".$prefix."news`")->num_rows;
$itnewsAll = $mysqli->query("SELECT `id` FROM `".$prefix."itnews`")->num_rows;
$ban = $mysqli->query("SELECT `id` FROM `".$prefix."sait` WHERE `ban` = '1'")->num_rows;
///////////////////////////////
$newSait = $mysqli->query("SELECT `id`,`name` FROM `".$prefix."sait` ORDER BY `regdate` DESC LIMIT 1");
$nSait = $newSait->fetch_assoc();
$new = ($newSait->num_rows > 0) ? '<a href = "http://'.$_SERVER['HTTP_HOST'].'/stats/'.$nSait['id'].'">'.$nSait['name'].'</a>' : 'Нет';
$online = $mysqli->query("SELECT * FROM `".$prefix."saitsOnline`")->num_rows;
echo '<div class="block">Общее<br/></div>';
echo '<div class="l1">';
echo '- Всего пользователей: <strong>'.$usersAll.'</strong><br/>';
echo '- Всего площадок: <strong>'.$plaformsAll.'</strong><br/>';
echo '- Всего категорий: <strong>'.$catAll.'</strong><br/>';
echo '- Сайтов на модерации: <strong>'.$plaformsNoMod.'</strong><br/>';
echo '- <a href="http://'.$_SERVER['HTTP_HOST'].'/m/ban">Заблокированных: <b>'.$ban.'</b></a></br></div>';
echo '<div class="block">Сегодня<br/></div>';
echo '<div class="text"><table width="100%">
<tr>
<td class="smile">Хосты<div></td>
<td class="smile">Хиты<div></td>
<td class="smile">В топ<div></td>
<td class="smile">Из топа</div></td>
</tr>
<tr>
<td class="smile">'.$dayHosts.'<div></td>
<td class="smile">'.$dayHits.'<div></td>
<td class="smile">'.$stats['in'].'<div></td>
<td class="smile">'.$stats['out'].'</div></td>
</tr>
</table>
</div>';
/////////////////////////////////////////////
echo '<div class="block">Вчера</div>';
echo '<div class="text"><table width="100%">
<tr>
<td class="smile">Хосты<div></td>
<td class="smile">Хиты<div></td>
<td class="smile">В топ<div></td>
<td class="smile">Из топа</div></td>
</tr>
<tr>
<td class="smile">'.$yesterdayHosts.'<div></td>
<td class="smile">'.$yesterdayHits.'<div></td>
<td class="smile">'.$yesterdayIn.'<div></td>
<td class="smile">'.$yesterdayOut.'</div></td>
</tr>
</table>
</div>';
echo '<div class="block">За весь период<br/></div>';
echo '<div class="text"><table width="100%">
<tr>
<td class="smile">Хосты<div></td>
<td class="smile">Хиты<div></td>
<td class="smile">В топ<div></td>
<td class="smile">Из топа</div></td>
</tr>
<tr>
<td class="smile">'.$stats['allHosts'].'<div></td>
<td class="smile">'.$stats['allHits'].'<div></td>
<td class="smile">'.$stats['allIn'].'<div></td>
<td class="smile">'.$stats['allOut'].'</div></td>
</tr>
</table>
</div>';
$body = ob_get_contents();
ob_end_clean();
if($cache['AllTopStats'] > 0)
{
wCache($body, 'statsAllTop.cache');
echo $body;
}
else
{
echo $body;
}
}
?>