Log in

View Full Version : How do I make a counter that only displays today's visits?



jacksont123
02-03-2007, 04:03 PM
How can I have a counter that displays only today's (current day) hits/page views and it doesn't use mysql?

Here's an example of one that logs all page hits (not the ones for the current day):


<?php
$stored = "data/hits.txt";
function displayHitThingy($stored) {
$fp = fopen($stored,rw);
$stuff = fgets($fp,9999);
fclose($fp);
$fp = fopen($stored,w);
$stuff += 1;
print "$stuff";
fputs($fp, $stuff);
fclose($fp);
}
?>


and to display it I just put


Page Hits: <?php displayHitThingy($stored); ?>