jwk811 Posted October 26, 2006 Share Posted October 26, 2006 How can you catch someones IP address when they're veiwing a page? Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/ Share on other sites More sharing options...
php_joe Posted October 26, 2006 Share Posted October 26, 2006 use:[b]$IP = $_SERVER['REMOTE_ADDR'];[/b]Joe Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/#findComment-114813 Share on other sites More sharing options...
.josh Posted October 26, 2006 Share Posted October 26, 2006 FYI, that's not 100% reliable. people can hide their ip address or change it. Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/#findComment-114819 Share on other sites More sharing options...
php_joe Posted October 26, 2006 Share Posted October 26, 2006 Aside from death, what is 100% reliable? ;) Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/#findComment-114830 Share on other sites More sharing options...
.josh Posted October 26, 2006 Share Posted October 26, 2006 getting taxed. Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/#findComment-114832 Share on other sites More sharing options...
xsist10 Posted October 26, 2006 Share Posted October 26, 2006 The closest I've come to 100% (call it 86.563%)[code]<?phppublic function getValidIP() { if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) $ip = getenv("HTTP_CLIENT_IP"); else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) $ip = getenv("HTTP_X_FORWARDED_FOR"); else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) $ip = getenv("REMOTE_ADDR"); else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) $ip = $_SERVER['REMOTE_ADDR']; else $ip = "unknown"; return($ip);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/25189-catch-an-ip/#findComment-114837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.