View Full Version : Is there a scipt that logs IP adresses of visitors in a .TXT File?

01-03-2004, 05: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, 05:46 PM
$file = "iplog.txt";

$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, 06: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" ;

fclose($fd) ;

$fd = fopen ($filename , "w") or die ("Uhoh! The PHP script cant open $filename") ;

$fcounted = $fstring + 1 ;

$fout= fwrite ($fd , $fcounted ) ;

fclose($fd) ;


01-03-2004, 06:11 PM
Well that's not logging IP's of visitors, that's a hit counter.

01-03-2004, 06:14 PM
Then i got the wrong code from a guy. I had my doubts already, for not containing REMOTE_ADDR thing.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum