|
$remoteaddr = getenv('REMOTE_ADDR');
$same_ip_mins = 30;
$output = array();
$clear_outdated = exec("find counter -amin +$same_ip_mins | awk '{print \"rm \" $0}' | sh",$output,$retval);
$counter = intval(file_get_contents("../../log/counter_ccowe8.dat"));
$ls = exec("ls counter/$remoteaddr-*",$output,$retval);
if($ls == ''){
$now_time = time();
touch("counter/$remoteaddr-$now_time");
chmod("counter/$remoteaddr-$now_time",777);
$counter++;
$fp = fopen("../../log/counter_ccowe8.dat", "w");
flock($fp, LOCK_EX); // do an exclusive lock
fwrite($fp, $counter);
flock($fp, LOCK_UN); // release the lock
fclose($fp);
tmpWriteLog("COUNT\t$counter\t".getenv("REMOTE_ADDR")."\t".date("Y-m-d h:i:s")."\t".getenv("REQUEST_URI")."\t".getenv("HTTP_REFERER")."\n");
} else {
tmpWriteLog("NTCNT\t$counter\t".getenv("REMOTE_ADDR")."\t".date("Y-m-d h:i:s")."\t".getenv("REQUEST_URI")."\t".getenv("HTTP_REFERER")."\n");
}
// GET TOTAL FLAGS
$totals = exec("find counter -type f | wc -l",$output,$retval);
$display_counter_online = lang_str($GLOBALS["COUNTER_ONLINE"]["CHI"],$GLOBALS["COUNTER_ONLINE"]["ENG"],$GLOBALS["COUNTER_ONLINE"]["INDO"]);
$display_counter_main = lang_str($GLOBALS["COUNTER_MAIN"]["CHI"],$GLOBALS["COUNTER_MAIN"]["ENG"],$GLOBALS["COUNTER_MAIN"]["INDO"]);
?>
echo $display_counter_online; ?>
echo $display_counter_main; ?>
function tmpWriteLog($str){
$tmpDate = date("Ymd");
if(file_exists("../../log/$tmpDate") == false){
mkdir("../../log/$tmpDate", 0777);
}
$LOG = fopen("../../log/$tmpDate/counter_ccowe8_$tmpDate.log", "a");
fwrite($LOG,$str);
fclose($LOG);
chmod("../../log/$tmpDate/counter_ccowe8_$tmpDate.log",0777);
}
?>
|
|