Jump to content
Killersites Community
Sign in to follow this  
saversites

Why Code Fails To Grab User Real IP ?

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×