Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I'm trying to make an IP logger for a webpage and I found this script on the internet:<?
$log_file = "ip.txt";
$ip = getenv('REMOTE_ADDR');
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fclose($fp);
PRINT("Your Ip was logged.....$ip");
?>All I want is a simple page that loggs the IP so I saved the above code into an Index.php file and uploaded it into a directory on my site. MY HOST DOES SUPPORT PHP. The directory does have write permissions. And I did CHOMD the ip.txt file to 777. It should all work right? But nothing appears in the ip.txt file, nothing atall.
What am I doing wrong, thanks
Ed

try putting these on top:
<?
error_reporting (E_ALL);
$log_file = "ip.txt";
and see if theres any error messages

Warning: fopen(ip.txt): failed to open stream: Permission denied in /usr/local/apache2/htdocs/edhardie/Site2/log.php on line 5Notice: Undefined variable: iprn in /usr/local/apache2/htdocs/edhardie/Site2/log.php on line 6
Warning: fputs(): supplied argument is not a valid stream resource in /usr/local/apache2/htdocs/edhardie/Site2/log.php on line 6
Warning: flock(): supplied argument is not a valid stream resource in /usr/local/apache2/htdocs/edhardie/Site2/log.php on line 7
Warning: fclose(): supplied argument is not a valid stream resource in /usr/local/apache2/htdocs/edhardie/Site2/log.php on line 8
your IP has been logged.....82.38.204.215I got that when put that extra line on top.
Does it think that ip.txt is in /usr/local/apach...? because it's not.

hiya ed,
althouh you said that you've already CHMOD ip.txt to 777, but the first notice said that the script don't have permission to write to the file...
you might want to make sure (again) that the ip.txt is chmod'd to 777 OR 666 (sometimes 777 wont work but 666 will, dont ask me why it's a little out of my logic :D -- but maybe it's related to the server settings set by the admin)
---
about the ip.txt location, nothing wrong with it... the php notice shows you the path to the file from the server's viewpoint
---
about IP logger, do you want something like this?
if so, take a look here
---
keep us posted :)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |