Do you have a question? Post it now! No Registration Necessary. Now with pictures!
October 5, 2004, 5:17 am
rate this thread
define('TIME24h', time() - 86400);
$marker_array = file($marker_file);
$marker_array_r = array_reverse($marker_array);
if ($marker_array_r < TIME24h)
$rolltime = $marker_array_r + 86400;
while ($rolltime < TIME24h) //if no visits in last 24hrs
$rolltime = $rolltime + 86400;
$fp = fopen($marker_file,"a");
//code that needs to run once a day goes here
The next visit to the site after a 24-hour interval will trigger the code.
The marker_file will also serve as a log showing each day the scheduled code
was run. Of course this assumes you seed the marker_file with a unix
timestamp of your choice, and that you only need your code to run once each
day, not at a particular time each day.