t3chb0yg3n13
04-26-2005, 03:41 AM
well here's the link I found for a PHP IP Log Script but when I inputted it into my PHP index.php file on the appropriate spot...
It won't log down the IP...
http://www.developerz.com/php_iplogger.htm
JustinH
04-26-2005, 04:18 AM
<?php
# The full path to log file: #
$log_file = "ip.txt";
$ip = $_SERVER['REMOTE_ADDR'];
$fp = fopen ($log_file, "a");
if (flock($fp, LOCK_EX))
{
fwrite($fp, $ip . "\n");
flock($fp, LOCK_UN);
} else {
echo "Couldn't lock the file !";
}
fclose ($fp);
echo "Your IP Address has been logged: " . $ip;
?>
t3chb0yg3n13
04-27-2005, 01:10 AM
still doesn't work well....
Go to the bottom of my blog and tell me what's wrong....
http://t3chb0yg3n13.gameblock.net/blog
JustinH
04-27-2005, 01:32 AM
Your host is the problem... it's saying that writable connections aren't allowed, so there is no way to make it work.
t3chb0yg3n13
04-27-2005, 01:34 AM
o no wonder.......some of my installed PHP scripts didn't work due to the same problem
Insert_Name_Here
04-27-2005, 06:26 AM
You can't modify/create/delete files if you give a "http://" path because the file is actually being requested over the internet rather than from the same machine, so it will get executed by whichever pre-processor it requires.
That is why you are getting the error:
HTTP wrapper does not support writeable connections
You need to use a relative path, or an absolute path that does not use http://....
instead of
fopen("http:///t3chb0yg3n13.gameblock.net/blog/ip.txt")
which should have been:
fopen("http://t3chb0yg3n13.gameblock.net/blog/ip.txt");
try
fopen("./ip.txt");
or
fopen("ip.txt");
JustinH
04-27-2005, 01:59 PM
That's exactly what he's using.
JustinH
04-27-2005, 02:10 PM
Hmmm interesting... it appears that it is being wrapped in the HTTP protocol, which doesn't make much sense, since my code doesn't ask for that.
Try changing this:
fopen("ip.txt");
to:
fopen("/home/block/public_html/t3chb0yg3n13/blog/ip.txt");
I'm guessing your host, or blog software is automatically appending a URL to it, so using a full path should void that.
Pheaton
04-27-2005, 05:25 PM
Make sure that the file has write permissions as well.
plexone
04-27-2005, 05:40 PM
For debugging purposes chmod everything to 777, once it works set it to a more suitable setting and something more secure for this purpose.
VolkNet
04-27-2005, 07:41 PM
oh no you got my ip. lol ;)
t3chb0yg3n13
04-27-2005, 07:54 PM
rofl....one again thx guys ....This forum is the best!!!!!!