$datearray = getdate();
Next we will define in the Year, Month, Day, Hour,
and Minute variables. $year = $datearray["year"];
$month = $datearray["mon"];
$day = $datearray["mday"];
$hour = $datearray["hours"];
$minute = $datearray["minutes"];
Now we choose define where this information will be written to. I
chose access.log. $filename = "access.log";
Then we create a variable that carries the information about the file to
write to. $fl=fopen($filename,'a');
Lastly we write the information to the text file. fwrite($fl, "[$REMOTE_ADDR on $month $day , $year at $hour
:$minute]\n\r");
echo ".\n";
The final code: <?
$datearray = getdate();
$year = $datearray["year"];
$month = $datearray["mon"];
$day = $datearray["mday"];
$hour = $datearray["hours"];
$minute = $datearray["minutes"];
$filename = "access.log";
$fl=fopen($filename,'a');
fwrite ($fl, "[$REMOTE_ADDR on $month $day , $year at $hour :$minute]\n\r");
echo ".\n";
?>
The output in the text file should appear as so: [IP ADDRESS on MONTH DAY, YEAR at HOUR: MINUTE]
Heres what it will look like when someone accesses it: [192.168.10.5 on 3 26 , 2009 at 12 :08]
Well this is the end of the tutorial!If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.