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 ? Quote
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 Quote
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! Quote
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.
Note: Your post will require moderator approval before it will be visible.