作者:嘻嘻嘻嘻 | 来源:互联网 | 2018-07-17 02:14
ec(2);获取用户IP地址与判断真实IPfunctiongetIp(){ if($_SERVER[HTTP_CLIENT_IP]) { return$_SERVER[HTTP_CLIENT_IP];&nbs
获取用户IP地址与判断真实IP
function getIp() {
if($_SERVER['HTTP_CLIENT_IP'])
{
return $_SERVER['HTTP_CLIENT_IP'];
} elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
return $_SERVER['REMOTE_ADDR'];
}
}
function get_real_ip()
{
$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
{
if (!eregi ("^(10|172.16|192.168).", $ips[$i]))
{
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}