标签:array 获取 code remote ips style ddr http pre
$ip = false; if (!empty($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } if (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR‘])) { $ips = explode(", ", $_SERVER[‘HTTP_X_FORWARDED_FOR‘]); if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } for ($i = 0; $i < count($ips); $i++) { if (!eregi("^(10│172.16│192.168).", $ips[$i])) { $ip = $ips[$i]; break; } } } $ipName = $ip ? $ip : $_SERVER[‘REMOTE_ADDR‘]; $this->ip = $ipName; return $this->ip;
标签:array 获取 code remote ips style ddr http pre
原文地址:https://www.cnblogs.com/shaoing/p/9296486.html