Last active
December 19, 2015 01:19
-
-
Save micc83/5875218 to your computer and use it in GitHub Desktop.
Find current client IP
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
<?php | |
/** | |
* Trova l'ip del cliente | |
*/ | |
function mc_get_user_ip() { | |
// Tiro giù l'ip del client | |
if ( isset( $_SERVER["REMOTE_ADDR"] ) ) { | |
$ip = $_SERVER["REMOTE_ADDR"]; | |
} elseif ( 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 = '1.1.1.1'; | |
} | |
return $ip; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment