--- fenglin/lib/client_addr.inc.php 2004/06/27 00:39:39 1.5 +++ fenglin/lib/client_addr.inc.php 2010/01/07 01:28:59 1.9 @@ -10,12 +10,12 @@ function Client_Address($addr=null,$x_ad if ($addr == null) $addr = $_SERVER["REMOTE_ADDR"]; - if ($x_addr == null && isset($_SERVER["HTTP_X_CLIENT_ADDR"])) - $x_addr = $_SERVER["HTTP_X_CLIENT_ADDR"]; + if ($x_addr == null && isset($_SERVER["HTTP_X_FORWARDED_FOR"])) + $x_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; - foreach($proxy_ip as $ip) + foreach($proxy_ip as $tmp => $ip) { - if (ereg($ip,$addr)) + if (preg_match("/".$ip."/",$addr)) { if ($x_addr != null) { @@ -23,9 +23,9 @@ function Client_Address($addr=null,$x_ad for($i=count($client_addr)-1;$i>=0;$i--) { $proxy = false; - foreach($proxy_ip as $ip) + foreach($proxy_ip as $tmp => $ip) { - if (ereg($ip,$client_addr[$i])) + if (preg_match("/".$ip."/",$client_addr[$i])) $proxy = true; } if (!$proxy)