PHP Code:
<?php
$file = "iplog.txt";
$ip = $_SERVER['REMOTE_ADDR'];
if(is_writable($file)){
$open = fopen($file,"a");
fwrite($open,$ip);
fclose($open);
}else{
chmod($file,0777) or die("Attempted to chmod the file, it was unsuccessful, please chmod ".$file." to 0777 yourself");
echo 'File was unwritable. Please refresh the page to try again';
}
?>
Put that at the top of the page you want to log the ip's on