In the script below, the counter increses the date only at 09:55AM
How to make it increase by one at 12:01 AM?
Our time zone is GMT+05:30
I think i uploaded this file @ 9:55 AM.
Plz tell me is that the reason?
counter.php
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$file_ip = fopen('counter/ip.db', 'rb');
while (!feof($file_ip)) {
$line[]=fgets($file_ip,1024);
}
for ($i=0; $i<(count($line)); $i++) {
list($ip_x) = split("
",$line[$i]);
if ($ip == $ip_x) {$found = 1;}
}
fclose($file_ip);
if (!$found) {
$file_ip2 = fopen('counter/ip.db', 'ab');
$line = "$ip
";
fwrite($file_ip2, $line, strlen($line));
$file_count = fopen('counter/count.db', 'rb');
$data = '';
while (!feof($file_count)) {
$data .= fread($file_count, 4096);
}
fclose($file_count);
list($today, $yesterday, $total, $date, $days) = split("%", $data);
if ($date == date("Y m d")) {
$today++;
} else {
$yesterday = $today;
$today = 1;
$days++;
$date = date("Y m d");
}
$total++;
$line = "$today%$yesterday%$total%$date%$days";
$file_count2 = fopen('counter/count.db', 'wb');
fwrite($file_count2, $line, strlen($line));
fclose($file_count2);
fclose($file_ip2);
}
?>
and this is shown in this file showcounter.php
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
<table width="237" border="0" cellpadding="5" cellspacing="5" bgcolor="#CCCCCC" style="border-collapse:collapse">
<tr>
<td width="161"><div align="left">
<?php
$file_count = fopen('counter/count.db', 'rb');
$data = '';
while (!feof($file_count)) {
$data .= fread($file_count, 4096);
}
fclose($file_count);
list($today, $yesterday, $total, $date, $days) = split("%", $data);
?>
You are visitor number </div></td>
<td width="8"><div align="left">:</div></td>
<td width="18">
<div align="left" style="font-weight:bold"><?php
echo $total;
?>
</div></td>
</tr>
<tr>
<td><div align="left">Total visitors today</div></td>
<td><div align="left">
<div align="left">:</div>
</div></td>
<td>
<div align="left" style="font-weight:bold"><?php echo $today; ?></div></td>
</tr>
<tr>
<td><div align="left">Visitors yesterday</div></td>
<td><div align="left">
<div align="left">:</div>
</div></td>
<td>
<div align="left" style="font-weight:bold">
<?php
echo $yesterday;
?>
</div></td>
</tr>
<tr>
<td><div align="left">Daily average</div></td>
<td><div align="left">
<div align="left">:</div>
</div></td>
<td>
<div align="left" style="font-weight:bold">
<?php
echo ceil($total/$days);
?>
</div></td>
</tr>
</table>
I mean, the total visitors today is the same till 9:54 am in the next day,
after 9:55 it resets…
i have to solve this problem, and the date should reset at 12:01 AM.
PLZ HELP…