Here's a flatfile IP logger I wrote and would like to share it with you guys just in case you find it useful
Set $variable to whatever you want to log.
I might come back with a mySQL one later.
Set $variable to whatever you want to log.
PHP:
$logfile = "LOG.txt"; //change this line if you want to change the file it writes to (must exist and CHMOD 0777)
$IP = $_SERVER['REMOTE_ADDR']; //sets the variable for $IP (gets the ip address)
$data = "$variable => $IP \n"; // sets the text to write to $logfile & adds a new line for the next one (nice and clean)
$fp = fopen("$logfile", "a"); //opens the log file
flock($logfile, LOCK_EX); // start an exclusive lock - prevents the file from being wiped if two people write at same time
fwrite($fp, $data); //writes to the log file
flock($fp, LOCK_UN); // release lock
fclose($fp); //closes the logfile (important!)
echo "<br /><br />Your IP ($IP) has been Logged with accordance of our T.O.S."; //tells people the've been warned!
I might come back with a mySQL one later.