I want to know how the whole function looks. In 1.2.1 it should look like this:
function get_remote_address()
{
$remote_address = $_SERVER['REMOTE_ADDR'];
// If HTTP_X_FORWARDED_FOR is set, we try to grab the first non-LAN IP
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
if (preg_match_all('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_SERVER['HTTP_X_FORWARDED_FOR'], $address_list))
{
$lan_ips = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/');
$address_list = preg_replace($lan_ips, null, $address_list[0]);
while (list(, $cur_address) = each($address_list))
{
if ($cur_address)
{
$remote_address = $cur_address;
break;
}
}
}
}
return $remote_address;
}
"Programming is like sex: one mistake and you have to support it for the rest of your life."