Error opening counter file!
\n");
exit -1;
}
$filename="/home/www/logs/$counterfile";
if (!file_exists($filename)) {
$counter=0;
$fd=fopen($filename,"w+");
} else {
$fd=fopen($filename,"r+");
$buffer=fread($fd,8);
sscanf($buffer,"%d",$counter);
}
$counter++;
if (isset($REMOTE_ADDR) && $REMOTE_ADDR!='217.168.237.106') {
fseek($fd,0,SEEK_SET);
$buffer=sprintf("%08d",$counter);
fwrite($fd,$buffer,8);
}
fclose($fd);
$cyear=0;
if (strlen($counterdate)==8 || is_long($counterdate)) {
$cyear=intval(substr($counterdate,0,4));
$cmonth=intval(substr($counterdate,4,2));
$cday=intval(substr($counterdate,6,2));
if ($cmonth<1 || $cmonth>12 || $cday<1 || $cday>31)
$cyear=0; //error
}
whichlang();
/* write results in the specified language */
if ($lang=="en") {
print("This page was accessed $counter times");
if ($cyear>0)
printf(" since %s %d, %d", $month_en[$cmonth-1], $cday,$cyear);
printf("
\nLast update on %s
\n",date("r",filemtime($SCRIPT_FILENAME)));
return;
} else if ($lang=="it") {
print("Pagina visitata $counter volte");
if ($cyear)
printf(" dal %d %s %d",$cday,$month_it[$cmonth-1],$cyear);
print("
\nUltimo aggiornamento il ".date("d/m/Y",filemtime($SCRIPT_FILENAME))." alle ore ".date("H:i:s",filemtime($SCRIPT_FILENAME))."
\n");
return;
}
}
function addirc($channel) {
global $lang;
whichlang();
print('');
print('
');
}
?>