Help - Search - Members - Calendar
Full Version: Simple Ip Log
Pixel2Life Forum > Member Tutorials and Requests > Forum Tutorial Archives > PHP Tutorials
filthy_13
Step 1. First of all you need to create a text document.
open up note pad and leave it blank and save it as ips.txt.
upload this to your ftp.

_____________________________________________________

Step 2.

Quote:
<?
$log_file = "ips.txt"; // This is the file to which the IPs are logged in.
$ip = getenv(\'REMOTE_ADDR\');
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fclose($fp);
PRINT("your IP has been logged.....$ip");
// "your IP has been logged....." .
?>

_____________________________________________________

Step 3. You can then put this code within your code and there you have it will log all visitors.

let me know if this is right
meadow
Yep works for me thanks for the ideas.
MaRmAR
You can also do e.g. this...

CODE
$date=date("d.m.Y", time());
$ip=$_SERVER["REMOTE_ADDR"];
$host=GetHostByIP($ip);
$separ=" ";
$nl="\r\n"; //newline
$output=$date.$separ.$ip.$separ.$host.$nl;


...and send the $output to file (via fputs()).
BTW: flock() all accessing programs have to use the same way of locking or it will not work (from PHP manual)
filthy_13
thanks guys first ever tut on here
MalDON
Also make sure the text file is chmodde correctly.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.