HI! I'm a little at a loss, I have a combination of scripts that keep state between a couple flash movies. One of them (for sake of argument "poll.php") is hit every 10 seconds by a flash movie to see the state of a text file has changed. I log all "hits" to the scripts but in this case I don't want a huge amount of log entries as the script is hit often. The constant ($session_id) is the likely candidate for testing - how do I (without a lot of overhead) only log every "x" hits to this script? the code:
// define constants
define("SESSION_FILE_PATH", "..\sessions\");
//initalize slide
$pvtSlide = "";
// check for filename
If (empty($filename)) {
echo "you must specify a filename such as: slave.php?filename=123452231";
exit;
}
// open session file
$sessionFile = SESSION_FILE_PATH . $filename;
$session_id = $filename;
$fp = fopen ($sessionFile, "r");
If ($fp) {
// read file contents into variables
// get the first line (email)
$pvtMasterEmail = fgets ($fp, 50);
$pvtSlaveEmail = fgets ($fp, 50);
// get the second line (signal)
$secondLine = fgets($fp, 50);
$pvtSignal = substr(strchr($secondLine, ","), 1);
// if the signal is 1, get the next line
//If ($pvtSignal == 1) {
// get the third line (slide)$thirdLine = fgets($fp, 50);
$pvtSlide = substr(strchr($thirdLine, ","), 1);
//}
// close file
fflush ($fp);
fclose ($fp);
} else {
echo "cannot open file: " . $sessionFile;
exit;
}
// output file values?
echo "signal=" . rtrim($pvtSignal) . "&slide=" . rtrim($pvtSlide);
$logfile = "d:\inetpub\wwwroot\log\log.txt";
define('LOG', 1); # comment this out if you don't want to log hits.
if (defined("LOG"))
{
$cf = fopen($logfile, "a"); #open file in append mode
#$date=time();
$date = date("M d, Y H:i:s");
$log = "$date\t$session_id\t$REMOTE_ADDR\r";
fwrite($cf, $log);
fclose($cf);
}
Thanks in advance if you have any ideas!