Jump to content

Recommended Posts

Posted

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 ?
Posted

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

Posted
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!

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...