--- fenglin/lib/client_addr.inc.php 2004/06/27 00:39:39 1.5 +++ fenglin/lib/client_addr.inc.php 2025/03/02 02:32:22 1.10 @@ -3,42 +3,11 @@ require_once "common.inc.php"; function Client_Address($addr=null,$x_addr=null) { - global $SYS_proxy_ip; - - $proxy_ip = $SYS_proxy_ip; - if ($addr == null) $addr = $_SERVER["REMOTE_ADDR"]; - if ($x_addr == null && isset($_SERVER["HTTP_X_CLIENT_ADDR"])) - $x_addr = $_SERVER["HTTP_X_CLIENT_ADDR"]; - - foreach($proxy_ip as $ip) - { - if (ereg($ip,$addr)) - { - if ($x_addr != null) - { - $client_addr = explode(",",$x_addr); - for($i=count($client_addr)-1;$i>=0;$i--) - { - $proxy = false; - foreach($proxy_ip as $ip) - { - if (ereg($ip,$client_addr[$i])) - $proxy = true; - } - if (!$proxy) - return trim($client_addr[$i]); - } - return trim($client_addr[0]); - } - else - { - return $_SERVER["REMOTE_ADDR"]; - } - } - } + if ($x_addr == null && isset($_SERVER["HTTP_X_FORWARDED_FOR"])) + $x_addr = $_SERVER["HTTP_X_FORWARDED_FOR"]; return $_SERVER["REMOTE_ADDR"]; }