--- fenglin/lib/client_addr.inc.php 2010/01/07 01:28:59 1.9 +++ fenglin/lib/client_addr.inc.php 2025/04/29 11:55:32 1.13 @@ -1,46 +1,9 @@ - $ip) + function client_addr(int $mask_level = 0) : string { - if (preg_match("/".$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 $tmp => $ip) - { - if (preg_match("/".$ip."/",$client_addr[$i])) - $proxy = true; - } - if (!$proxy) - return trim($client_addr[$i]); - } - return trim($client_addr[0]); - } - else - { - return $_SERVER["REMOTE_ADDR"]; - } - } - } - - return $_SERVER["REMOTE_ADDR"]; -} + $ip = (isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : ""); -?> + return ip_mask($ip, $mask_level, "%"); + }