Nice and Simple
-
There is a problem looking up IP addresses that are behind a proxy. The following update to the “display_user_ip” ensures that you get the correct IP address even if it is behind a proxy.
// shortcode [user_ip]
function display_user_ip()
{
$user_ip = $_SERVER[‘REMOTE_ADDR’];
$proxy = $_SERVER[“HTTP_X_FORWARDED_FOR”];
if(ereg(“^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$”,$proxy))
$user_ip = $_SERVER[“HTTP_X_FORWARDED_FOR”];
return $user_ip;
}
- The topic ‘Nice and Simple’ is closed to new replies.