<?php
$now = date("d-m-Y");
$dot = explode ("-",$now);
$nowdate = $dot[0];
$nowmonth = $dot[1];
$nowyear = $dot[2];
function Stats($total) {
global $hlpfile,$nowyear,$nowmonth,$nowdate,$nowhour, $sitename, $startdate, $prefix, $db, $now, $module_name;
$row = $db->sql_query("SELECT count from ".$prefix."_counter order by type desc");
list($total) = $db->sql_fetchrow($row);
$total++;
OpenTable();
$row4 = $db->sql_fetchrow($db->sql_query("SELECT year, month, date, hour, hits from ".$prefix."_stats_hour order by hits DESC limit 0,1"));
$year = intval($row4['year']);
$month = intval($row4['month']);
$date = intval($row4['date']);
$hour = intval($row4['hour']);
$hits = intval($row4['hits']);
if ($hour < 10) {
$hour = "0$hour:00 - 0$hour:59";
} else {
$hour = "$hour:00 - $hour:59";
}
echo "<BR><BR>";
showHourlyStats($nowyear,$nowmonth,$nowdate);
CloseTable();
}
function showHourlyStats($year,$month,$date){
global $prefix,$bgcolor1,$bgcolor2,$db, $ThemeSel;
$l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
$m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
$r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
$resulttotal = $db->sql_query("SELECT sum(hits) as TotalHitsHour from ".$prefix."_stats_hour where year='$year' and month='$month' and date='$date'");
list($TotalHitsHour) = $db->sql_fetchrow($resulttotal);
$db->sql_freeresult($resulttotal);
$nowdate = date("d-m-Y");
$nowdate_arr = explode("-",$nowdate);
echo "<table width=\"70%\"align=\"center\" bgcolor=\"#000000\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
echo "<tr><td width=\"15%\" bgcolor=\"$bgcolor2\">Время</td><td bgcolor=\"$bgcolor2\" width=\"70%\">Просмотрено страниц</td></tr>";
for ($k = 0;$k<=23;$k++) {
$result = $db->sql_query("select hour,hits from ".$prefix."_stats_hour where year='$year' and month='$month' and date='$date' and hour='$k'");
if ($db->sql_numrows($result) == 0){
$hits=0;
} else {
$row = $db->sql_fetchrow($result);
$hour = intval($row['hour']);
$hits = intval($row['hits']);
}
echo "<tr><td bgcolor=\"$bgcolor1\">";
if ($k < 10) {
$a = "0$k";
} else {
$a = $k;
}
echo "$a:00 - $a:59";
$a = "";
echo "</td><td bgcolor=\"$bgcolor1\">";
if ($hits == 0) {
$WidthIMG = 0;
$d_percent = 0;
} else {
$WidthIMG = round(100 * $hits/$TotalHitsHour,0);
$d_percent = substr(100 * $hits / $TotalHitsHour, 0, 5);
}
echo "<img src=\"themes/$ThemeSel/images/leftbar.gif\" Alt=\"\" width=\"$l_size[0]\" height=\"$l_size[1]\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" height=\"$m_size[1]\" width=",$WidthIMG * 2," Alt=\"\">"
."<img src=\"themes/$ThemeSel/images/rightbar.gif\" Alt=\"\" width=\"$r_size[0]\" height=\"$r_size[1]\"> $d_percent% ($hits хитов)</td></tr>"
."</td></tr>";
}
$db->sql_freeresult($result);
echo "</table>";
}
switch($op) {
case "Stats":
Stats($total);
break;
}
?>
|