saversites Posted June 12, 2019 Report Posted June 12, 2019 The following fails to grab the user's real ip. I testing on my Xamp (localhost). The code is supposed to grab real ip even if user hiding behind proxy. Why not showing my dynamic ip ? I can see my ip on whatismyip.com but that code fails to show it. I been testing on localhost using Mini Proxy. function getUserIpAddr() { if(!empty($_SERVER['http_client_ip'])){ //IP from Shared Internet $ip = $_SERVER['HTTP_CLIENT_IP']; }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ //IP from Proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; }else{ $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } echo 'User real Ip - '.getUserIpAddr(); I get this as output: ::1 What does that output mean ?
administrator Posted June 13, 2019 Report Posted June 13, 2019 Could be what the proxy is sending out. Or more likely, your code might be just returning a binary - true or false ... or in other words, 1 or 0. Have you tried this code on a live server? ... Could also be a Xamp issue? Stef
saversites Posted June 17, 2019 Author Report Posted June 17, 2019 On 6/14/2019 at 2:21 AM, administrator said: Could be what the proxy is sending out. Or more likely, your code might be just returning a binary - true or false ... or in other words, 1 or 0. Have you tried this code on a live server? ... Could also be a Xamp issue? Stef Thank you Stef. I have not tried on a live server. I guess I should do that first! Cheers!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now