Ho prelevato uno script di statistiche di accesso da freephp e funziona perfettamente. L'unico problema è che mi compare un ora di referrer americana come se il fuso orario fosse sbagliato va indietro di qualche ora.
Posto il file di log:
-------------------------------------
<?
### --- Hit logger/Counter Copyright burt@dotdragnet.co.uk 2001 --- ###
### --- No changes below this line --- ###
require "config.inc.php";
// Correct IP address:
if (getenv('HTTP_X_FORWARDED_FOR')){
$ip=getenv('HTTP_X_FORWARDED_FOR');
}
else {
$ip=getenv('REMOTE_ADDR');
}
// Referring page:
if ($HTTP_REFERER == "") $refer = "No referrer";
else $refer = $HTTP_REFERER;
// Browser information
if ($HTTP_USER_AGENT == "") $browser = "No browser";
else $browser = $HTTP_USER_AGENT;
// This page is:
$path = "$PHP_SELF";
$page = basename ($path);
// Date and Time
$time = date("F jS Y, h:iA");
// Is the referrer a page in your domain?
if (!(preg_match("/$domain/i", "$HTTP_REFERER"))) {
// Open the text file and record the information:
if (!file_exists($textname)){
echo "Warning \"Write to\" file does not exist - please make a text file named $textname and CHMOD it 777";
exit;
}
$fp = @fopen("$textname", "a");
if (!($fp)) {
echo "Warning The \"Write to\" file is not set CHMOD 777
";
exit;
}
fputs($fp, "$page // $time // $ip // $browser // $refer \n");
// close the textfile
fclose($fp);
}
?>
-----------------------------------------
Come posso risolvere il problema?