sql_query("update ".$prefix."_counter set count=count+1 where (type='total' and var='hits') or (var='$browser' and type='browser') or (var='$os' and type='os')", $dbi);
/* Start Detailed Statistics */
$dot = date("d-m-Y-H");
$now = explode ("-",$dot);
$nowHour = $now[3];
$nowYear = $now[2];
$nowMonth = $now[1];
$nowDate = $now[0];
$resultyear = sql_query("select year from ".$prefix."_stats_year where year='$nowYear'",$dbi);
$jml = sql_num_rows($resultyear,$dbi);
if ($jml <= 0) {
sql_query("insert into ".$prefix."_stats_year values('$nowYear','0')",$dbi);
for ($i=1;$i<=12;$i++) {
sql_query("insert into ".$prefix."_stats_month values('$nowYear','$i','0')",$dbi);
if ($i == 1) $TotalDay = 31;
if ($i == 2) {
/*
if (date("L") == true) {
$TotalDay = 29;
} else {
$TotalDay = 28;
}
*/
if (($nowYear % 4) == 0) {
$TotalDay = 28;
} else {
$TotalDay = 29;
}
}
if ($i == 3) $TotalDay = 31;
if ($i == 4) $TotalDay = 30;
if ($i == 5) $TotalDay = 31;
if ($i == 6) $TotalDay = 30;
if ($i == 7) $TotalDay = 31;
if ($i == 8) $TotalDay = 31;
if ($i == 9) $TotalDay = 30;
if ($i == 10) $TotalDay = 31;
if ($i == 11) $TotalDay = 30;
if ($i == 12) $TotalDay = 31;
for ($k=1;$k<=$TotalDay;$k++) {
sql_query("insert into ".$prefix."_stats_date values('$nowYear','$i','$k','0')",$dbi);
}
}
}
$resulthour = sql_query("select hour from ".$prefix."_stats_hour where (year='$nowYear') and (month='$nowMonth') and (date='$nowDate')",$dbi);
if (sql_num_rows($resulthour,$dbi) <= 0) {
for ($z = 0;$z<=23;$z++) {
sql_query("insert into ".$prefix."_stats_hour values('$nowYear','$nowMonth','$nowDate','$z','0')",$dbi);
}
}
sql_query("update ".$prefix."_stats_year set hits=hits+1 where year='$nowYear'",$dbi);
sql_query("update ".$prefix."_stats_month set hits=hits+1 where (year='$nowYear') and (month='$nowMonth')",$dbi);
sql_query("update ".$prefix."_stats_date set hits=hits+1 where (year='$nowYear') and (month='$nowMonth') and (date='$nowDate')",$dbi);
sql_query("update ".$prefix."_stats_hour set hits=hits+1 where (year='$nowYear') and (month='$nowMonth') and (date='$nowDate') and (hour='$nowHour')",$dbi);