Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

php ip logger issuses


ghost's Avatar
0 0

The correct variable for a visitor's ip is $_SERVER['REMOTE_ADDR'];. What is your code giving you? It shouldn't give anything unless PHP is getting $_SERVER since it doesn't have the variable defined anywhere else.


ghost's Avatar
0 0

The correct code would be:

<?
$log_file = "log.txt";
$date_time = date('d-m-Y/H:i:s');
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_SERVER['REQUEST_URI'];
$fp = fopen("$log_file", "a");


fputs ($fp," ($date_time) ($ip) $page");
flock($fp, 3);
fclose($fp);
?>

You missed a quotation and a parentheses and $ip=$REMOTE_ADDR; needs to be changed to $_SERVER['REMOTE_ADDR'];


BlackW0lf's Avatar
Member
0 0

ahh yeah i see that thanks for spotting that im still kinda new to php :/ and just try it again but its still not logging my ip so onlything i could think of it being is awardspace.com my hosting website isnt alowing the php?


ghost's Avatar
0 0

It works on my server. Try doing <?php echo "test"; ?> and see if it outputs. Are you saving in a .html or a .php file?


BlackW0lf's Avatar
Member
0 0

the php is working fine on the site but when it logs an ip it logs the servise providers ip not there computer which i want


spyware's Avatar
Banned
0 0

BlackW0lf wrote: the php is working fine on the site but when it logs an ip it logs the servise providers ip not there computer which i want

Post a sample IP (be sure to change some numbers).


BlackW0lf's Avatar
Member
0 0

ok say this is my ip 82.38..*

when i vist my iploggers page the ip that is logged is 62.30..

which when tracked points to my service provider


ghost's Avatar
0 0

BlackW0lf wrote: ok say this is my ip 82.38..*

when i vist my iploggers page the ip that is logged is 62.30..

which when tracked points to my service provider

Does your ISP proxy your connection? If so, then that's your problem. http://whatsmyip.org/ <—what does that say when you go to it?


BlackW0lf's Avatar
Member
0 0

it says my ip ive checked this and ive asked 2 other people who trust me knowing there ip and it has the same results both got logged as there service providers ip not there computers ip


ghost's Avatar
0 0

That's really weird :/. I don't get why it would be logging the ISP for you, here's from my log file:

(25-08-2008/06:56:42) (24.213.194.119) /test2.php It's showing my I.P. The only reasons I can think of are that your web-host is somehow making it so you can't log individual I.P.s. I'll do some googling and see if that's possible to do. If you have access to the apache access logs, does it show your real I.P. in it or the service provider's?