...

View Full Version : Users Online IP/Page



Blatch
08-29-2009, 09:23 PM
http://elouai.com/users.php

I'm using this and it seems to work great, except it's not adding the IP or the page to the sql db. Can anyone figure this out??

Fou-Lu
08-29-2009, 10:25 PM
That code is really old. I mean, pre 4.2 old.
$REMOTE_ADDR only exists where a register_globals environment exists. Use $_SERVER['REMOTE_ADDR'] to retrieve the IP.

Zangeel
08-30-2009, 01:58 AM
If you want to add the IP to the database, you need to add it in your login script, so if the login is successful, update a row in the user database like adda row called, "loginIP" and use the UPDATE clause everytime they login using $_SERVER['REMOTE_ADDR'] to add the ip in the db.

like

mysql_query("UPDATE `users` SET `loginIP` = '".$_SERVER['REMOTE_ADDR']."' WHERE `user` = '".$usernameHere."'");

SKDevelopment
08-30-2009, 02:00 PM
Also if a user has passed through a proxy server, $_SERVER['REMOTE_ADDR'] would contain the IP address of the proxy server.

In this case (if the proxy is not anonymous), the proxy server could send the original user IP address in a separate header, which you could get from $_SERVER["HTTP_X_FORWARDED_FOR"]. So you could also consider saving the value obtained from $_SERVER["HTTP_X_FORWARDED_FOR"] (if any).

Fou-Lu
08-30-2009, 05:29 PM
Also if a user has passed through a proxy server, $_SERVER['REMOTE_ADDR'] would contain the IP address of the proxy server.

In this case (if the proxy is not anonymous), the proxy server could send the original user IP address in a separate header, which you could get from $_SERVER["HTTP_X_FORWARDED_FOR"]. So you could also consider saving the value obtained from $_SERVER["HTTP_X_FORWARDED_FOR"] (if any).

Yep, that is true. There is also HTTP_FROM and HTTP_VIA, but I've never seen the latter used before. I think I have seen HTTP_FROM in use once.
When using the HTTP_X_FORWARDED_FOR if the user is using an internal proxy on their network, you can check to see if its an internal IP as well: 10.*, 192.168.* or 172.16.* - 172.31.*. If it is, dump it and go with HTTP_VIA if it exists or REMOTE_ADDR.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum