Hi,
i use some file to count access.
each file has 2/3 line.
The first is the counter, the second is logged ip, the last
if exist is the current day.
why sometime this update mysql table also if is not a new day ?
And the main count restart from 0...
<?php
// $name it's submitted...
if(substr_count($name,"main")>0) $main=1; else $main=0; //poor check for homepage access
$line[0]=0; $line[1]="10"; $line[2]=0; //init of array
$myip=$REMOTE_ADDR;
$curip=$myip.$REMOTE_PORT; //getting visitor information
$curip=substr($curip,0,strlen($curip)-2); //bcs behind firewall add the first number of port...
$line=@file($name); //read from file
$line[0]=trim($line[0]); //clean from \r \n and other
$line[1]=trim($line[1]);
$line[2]=trim($line[2]);
if($myip!="194.243.134.16" && $curip!=$line[1]){ //check if is my pc or a refresh
$line[0]++; // else count new access
$line[1]=$curip; // log this ip
$handle=fopen($name, "w+"); // open file (i have right rights..)
if ($main==0) { // if isn't hp access
fwrite($handle,$line[0]."\n".$line[1]); // just update info
} else {
if($line[2]!=date("d")) { // else LOOK FOR DAY
require("storedb.php"); // IF IS ANOTHER DAY INSERT STATS IN MYSQL TABLE
}
$line[2]=date("d"); // update DAY
fwrite($handle,$line[0]."\n".$line[1]."\n".$line[2]); // update all info
}
fclose($handle);
}
header('Content-type: image/gif'); // give a null img.
readfile("../graph/null.gif");
?>