die('ERROR: Page ID is missing or contains only invalid chars. Please use only these chars for the page ID: a-z, A-Z, 0-9, ".", "-" and "_"');
// Set values for cookie, log file and style flye names
$cname='gcount_unique_'.$page;
$logfile='logs/'.$page.'.txt';
$style_dir='styles/'.$style.'/';
// Does the log file exist?
if(!file_exists($logfile)){
die('ERROR: Log file not found. Make sure there is a file called <b>'.$page.'.txt</b> inside your <b>logs</b> folder. On most servers file names are CaSe SeNSiTiVe!');
// If counting unique hits is enabled make sure it's a unique hit
if($count_unique==0||!isset($_COOKIE[$cname])){
// Update count by 1 and write the new value to the log file
$count=$count+1;
rewind($fp);
fwrite($fp,$count);
// Print the Cookie and P3P compact privacy policy
header('P3P: CP="NOI NID"');
setcookie($cname,1,time()+60*60*$unique_hours);
}
}
else{
// Lock not successful. Better to ignore than to damage the log file
$count=1;
}
// Release file lock and close file handle
flock($fp,LOCK_UN);
fclose($fp);
}
else{
die("ERROR: Can't read/write to the log file ($logfile). Make sure this file is writable by PHP scripts. On UNIX servers, CHMOD the log file to 666 (rw-rw-rw-).");
}
// Is zero-padding enabled? If yes, add zeros if required