View Full Version : Is there a scipt that logs IP adresses of visitors in a .TXT File?
01-03-2004, 06:36 PM
I really wanna know a php script that logs the ip adresses of visitors into a .TXT file on the website. I searched around these forums and tried the search engine but didn't found what i wanted. Please help me.
01-03-2004, 06:46 PM
$file = "iplog.txt";
$ip = $_SERVER['REMOTE_ADDR'];
$open = fopen($file,"a");
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
01-03-2004, 07:09 PM
Thanks! but i also found this:
$filename= "hits.txt" ;
$fd = fopen ($filename , "r") or die ("Uhoh! The PHP script cant open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
$fd = fopen ($filename , "w") or die ("Uhoh! The PHP script cant open $filename") ;
$fcounted = $fstring + 1 ;
$fout= fwrite ($fd , $fcounted ) ;
01-03-2004, 07:11 PM
Well that's not logging IP's of visitors, that's a hit counter.
01-03-2004, 07:14 PM
Then i got the wrong code from a guy. I had my doubts already, for not containing REMOTE_ADDR thing.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.