Jump to content


Photo
- - - - -

Simple Ip Log


  • Please log in to reply
4 replies to this topic

#1 filthy_13

filthy_13

    Young Padawan

  • Members
  • Pip
  • 144 posts

Posted 06 May 2005 - 05:49 AM

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

#2 meadow

meadow

    Young Padawan

  • Members
  • Pip
  • 224 posts
  • Location:Devon, England
  • Interests:Php, Hockey, mysql, web design.

Posted 07 May 2005 - 10:16 AM

Yep works for me thanks for the ideas.

#3 MaRmAR

MaRmAR

    Young Padawan

  • Members
  • Pip
  • 18 posts
  • Location:Slovakia

Posted 08 May 2005 - 03:16 AM

You can also do e.g. this...

$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)

#4 filthy_13

filthy_13

    Young Padawan

  • Members
  • Pip
  • 144 posts

Posted 09 May 2005 - 07:17 PM

thanks guys first ever tut on here

#5 MalDON

MalDON

    Young Padawan

  • Members
  • Pip
  • 127 posts
  • Location:Southern California
  • Interests:DeviantART, PHP, Techno, Empire Earth 2, Halo 2

Posted 09 May 2005 - 10:36 PM

Also make sure the text file is chmodde correctly.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users