Revision: 60105
Updated Code
at October 20, 2012 10:37 by o0110o
Updated Code
function get_ip(){ if(!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } // Check if the IP is from a shared internet connection else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } // Check if the IP is passed from a proxy else{ $ip = $_SERVER['REMOTE_ADDR']; } // The real IP address return $ip; }
Revision: 60104
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 20, 2012 10:36 by o0110o
Initial Code
function get_ip(){ if(!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } //check if the IP is from a shared internet connection else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } //check if the IP is passed from a proxy else{ $ip = $_SERVER['REMOTE_ADDR']; } // Real IP address return $ip; }
Initial URL
Initial Description
This function performs several checks to make sure it's getting the correct IP address.
Initial Title
A function to get the real IP address.
Initial Tags
php, function, ip
Initial Language
PHP