Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand the get real ip function #21

Open
ghost opened this issue May 1, 2014 · 2 comments
Open

Expand the get real ip function #21

ghost opened this issue May 1, 2014 · 2 comments
Milestone

Comments

@ghost
Copy link

ghost commented May 1, 2014

Expand the Your IP Address with perhaps the following function

function getRealIpAddr()
{
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;
}

@ldrrp
Copy link
Contributor

ldrrp commented Jan 23, 2015

This one supports cloudflare too.

public function GET_IP(){ return getenv('HTTP_CLIENT_IP')?: getenv('HTTP_X_FORWARDED_FOR')?: getenv('HTTP_X_FORWARDED')?: getenv('HTTP_FORWARDED_FOR')?: getenv('HTTP_FORWARDED')?: getenv('REMOTE_ADDR')?: getenv('HTTP_CF_CONNECTING_IP')?: 'UNKNOWN'; }

@telephone
Copy link
Owner

Leaving v1 as is for IP retrieval. This will be pushed to v2.

@telephone telephone added this to the v2.0.0 milestone Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants