Created
February 22, 2016 14:18
-
-
Save phsantiago/11c3a1c325b744b00874 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetUserIP() { | |
if (isset($_SERVER)) { if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) | |
{ $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } | |
elseif(isset($_SERVER["HTTP_CLIENT_IP"])) | |
{ $ip = $_SERVER["HTTP_CLIENT_IP"]; } | |
else { $ip = $_SERVER["REMOTE_ADDR"]; } | |
} | |
else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) | |
{ $ip = getenv( 'HTTP_X_FORWARDED_FOR' ); } | |
elseif ( getenv( 'HTTP_CLIENT_IP' ) ) | |
{ $ip = getenv( 'HTTP_CLIENT_IP' ); } | |
else { $ip = getenv( 'REMOTE_ADDR' ); } | |
} | |
return $ip; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment