Hey,
I\'m very green to the whole PHP/MySQl world so go easy on me.
First of all I\'m installing PHP-Nuke 6.5 and I\'m using MySQLadmin to access the MySQL. Now then, I have two issues occurring in the same counter.
First.
I\'ve installed a Total Hits counter block. The counter tracks hourly hits, daily hits, as well as averages per hour, day, month and year. When I installed the counter the nuke_stats_date and nuke_stats_month were set to zero variables and had no tables established.
What I did was build a table for A day in nuke_stats_date and A table for the month in nuke_stats_month. All seemed good, my \"warning: division by zero error went away and the counter was counting. We I got up this morning the counter was no longer counting NEW hits for the day. I had to go back in and make a table for today.
My question is.... Do I have to build the tables for every day of the year, or can the daily rollover be automated somehow?
If my nuke_stats_date isn\'t updating automatically them I bet come October my nuke_stats_month won\'t either.
Obviously I’m not much of a MySQL wiz so I could use someone pointing me in the right direction.
Second
The Nuke Total Hits counter I have will show today\'s hits, yesterday\'s hits and then average hits per hour, day, month and year. As well as total hits for the site. The problem is as part of the nuke it counts everything... it counts me over and over, it counts every single page click regardless where it is, it counts reloads, it just counts everything.
I really like the counters features, but I only want to count unique page views on the index in like 12-hour blocks.
How could the script be modified to make that happen?
Here\'s my site.
http://www.right2left.org
and here\'s the counter script.
[php:1:8889ef7164] <?php /********************************************************/ /* Block for PHP-Nuke 6.0 thru 6.5 */ /* By: fun-room (Webmaster@fun-room.com) */ /* http://www.fun-room.com/ */ /* Copyright © 2003 by Fun-room Network */ /********************************************************/ if (eregi(\"block-Hits.php\", $PHP_SELF)) {Header(\"Location: index.php\"); die();} global $nukeurl, $prefix, $startdate, $dbi; $nbhits = \"<center>\"; $content = \"\"; /////////////////////////////////////////////////////////////////////////////////////////////////////// $type = \"text\"; // defines type of counter (text or gfx) //////////////////////////////////////////////////////////////////////////////////////////////////////// /* Hits Total */ $result = sql_query(\"SELECT count FROM $prefix\"._counter.\" WHERE type=\'total\' AND var=\'hits\'\", $dbi); $count_holder = sprintf (\"%07d\", implode(mysql_fetch_row($result), $dbi)); mysql_free_result ($result); if ($type == \"text\") $nbhits .= $count_holder; else for ($n = 0; $n < strlen($count_holder); $n++) ($nbhits .= \"<img src=\"images/led/{$count_holder[$n]}.gif\" bordercolor=\"#FFFFFF\" border=\"1\">\"); /* Hits for Today */ $t_time = time(); $t_year = date(\"Y\", $t_time); $t_month = date(\"n\", $t_time); $t_date = date(\"j\", $t_time); $result = sql_query(\"SELECT hits FROM $prefix\"._stats_date.\" WHERE year=\'$t_year\' AND month=\'$t_month\' AND date=\'$t_date\'\", $dbi); list($today) = sql_fetch_row($result, $dbi); /* Hits for Yesterday */ $y_time = $t_time - 86400; $y_year = date(\"Y\", $y_time); $y_month = date(\"n\", $y_time); $y_date = date(\"j\", $y_time); $result = sql_query(\"SELECT hits FROM $prefix\"._stats_date.\" WHERE year=\'$y_year\' AND month=\'$y_month\' AND date=\'$y_date\'\", $dbi); list($yesterday) = sql_fetch_row($result, $dbi); /* Hourly Hits */ $result = sql_query(\"SELECT count(*) FROM $prefix\"._stats_hour.\"\", $dbi); list($hours) = sql_fetch_row($result, $dbi); $hourly = number_format($count_holder/$hours, 0); /* Daily Hits */ $result = sql_query(\"SELECT count(*) FROM $prefix\"._stats_date.\"\", $dbi); list($days) = sql_fetch_row($result, $dbi); $daily = number_format($count_holder/$days, 0); /* Monthly Hits */ $result = sql_query(\"SELECT count(*) FROM $prefix\"._stats_month.\"\", $dbi); list($months) = sql_fetch_row($result, $dbi); $monthly = number_format($count_holder/$months, 0); /* Yearly Hits */ $result = sql_query(\"SELECT count(*) FROM $prefix\"._stats_year.\"\", $dbi); list($years) = sql_fetch_row($result, $dbi); $yearly = number_format($count_holder/$years, 0); /* Server Time */ $Time = date(\"d M Y\"); $Today = date(\"H:i:s\"); $Offset = date(\"O\"); $nbhits .= \" </center>\"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* TOTAL HITS */ $content .= \"<div align=\"center\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"95%\">n\"; $content .= \"<tr><td><center><small>\"._WERECEIVED.\"</small><br><br>$nbhits<br><small>\"._PAGESVIEWS.\" $startdate</small></center></td></tr>n\"; $content .= \"</table><hr>n\"; $content .= \"<b><u>\"._BHITS.\"</u></b><br>\"; $content .= \"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"95%\">n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BTD.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\"><b><a href=\"modules.php?name=Statistics&op=DailyStats&year=$t_year&month=$t_month&date=$t_date\">$today</a></b></td></tr>n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BYD.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\"><b><a href=\"modules.php?name=Statistics&op=DailyStats&year=$y_year&month=$y_month&date=$y_date\">$yesterday</a></b></td></tr>n\"; $content .= \"</table><hr>n\"; $content .= \"<b><u>\"._BHITA.\"</u></b><br>\"; $content .= \"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"95%\">n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BHOUR.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\">$hourly</td></tr>n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BDAIL.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\">$daily</td></tr>n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BMONT.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\">$monthly</td></tr>n\"; $content .= \"<tr><td width=\"65%\"><big><b>·</b></big> \"._BYEAR.\"</td>n\"; $content .= \"<td width=\"35%\"><p align=\"right\">$yearly</td></tr>n\"; $content .= \"</table><hr>\"; $content .= \"<b><u>Server \"._BTIME.\"</u></b><br>\"; $content .= \"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"95%\">n\"; $content .= \"<tr><td width=\"40%\"><big><b>·</b></big> \"._BTIME.\"</td>n\"; $content .= \"<td width=\"60%\"><p align=\"right\">$Today</td></tr>n\"; $content .= \"<tr><td width=\"40%\"><big><b>·</b></big> \"._BDATE.\"</td>n\"; $content .= \"<td width=\"60%\"><p align=\"right\">$Time</td></tr>n\"; $content .= \"<tr><td width=\"40%\"><big><b>·</b></big> \"._BZONE.\"</td>n\"; $content .= \"<td width=\"60%\"><p align=\"right\">$Offset</td></tr>n\"; $content .= \"</table></div>\"; ?> ?>[/php:1:8889ef7164] ?>[/code]