andre3 Posted July 24, 2009 Share Posted July 24, 2009 Hey guys, when i use this to return someones ip: $_SERVER['REMOTE_ADDR']; it returns the server ip address, an it happends because www is handled as a forward on my server , however i use this function to get the persons real ip address: public function original_ip() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } but when i capture the ip address in a sql table, some of them are like this: 195.189.142.252 , 10.22.333.33 that i want to know is, which is the persons real ip address ? i did a explode on it, to get one ip address instead of 2, an it worked farely well.. although ive done that the mystery questions remains, 'which is the real ip' i would really appreciate some help. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/ Share on other sites More sharing options...
MadTechie Posted July 24, 2009 Share Posted July 24, 2009 The first one is the clients IP and the ones after (maybe more then one) is the proxies IP EDIT: okay I should also say that this is true for transparent proxies but NOT true for anonymous proxies. if HTTP_X_FORWARDED_FOR exists then a proxy is being used but a distorting proxy with give you a random number in HTTP_X_FORWARDED_FOR, but in a highly anonymity proxy you will not see HTTP_X_FORWARDED_FOR or HTTP_VIA Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-882257 Share on other sites More sharing options...
andre3 Posted July 24, 2009 Author Share Posted July 24, 2009 so what are you implying ? i do not understand Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-882331 Share on other sites More sharing options...
xcoderx Posted July 24, 2009 Share Posted July 24, 2009 Pmpl andre man how hightech u plan to go with the wap world? Atleast spear the ip of poor mobile users hehe. Oopz sory to distract. Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-882355 Share on other sites More sharing options...
MadTechie Posted July 24, 2009 Share Posted July 24, 2009 What part don't you understand ? The first IP is the likely clients IP, but that's not always true, for example distorting proxy will give you fake info and a highly anonymity will only give you the proxy IP without setting HTTP_X_FORWARDED_FOR or HTTP_VIA Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-882389 Share on other sites More sharing options...
andre3 Posted July 26, 2009 Author Share Posted July 26, 2009 i understand, so practically there isnt any way with php to grab the real ip address at one shot? Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-883117 Share on other sites More sharing options...
GingerRobot Posted July 26, 2009 Share Posted July 26, 2009 i understand, so practically there isnt any way with php to grab the real ip address at one shot? That's about the size of it. Quote Link to comment https://forums.phpfreaks.com/topic/167319-http_x_forwarded_for-issue/#findComment-883123 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.