/* 获取用户的真实IP */
function getIP()
{
static $ip;
if (isset($_SERVER))
{
if (isset($_SERVER['HTTP-X-FORWARDED_FOR']))
{
$ip = $_SERVER['HTTP-X-FORWARDED_FOR'];
}
elseif (isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
else
{
if (getenv('HTTP-X-FORWARDED_FOR'))
{
$ip = getenv('HTTP-X-FORWARDED_FOR');
}
elseif (getenv('HTTP_CLIENT_IP'))
{
$ip = getenv('HTTP_CLIENT_IP');
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
return $ip;
}
function getIP()
{
static $ip;
if (isset($_SERVER))
{
if (isset($_SERVER['HTTP-X-FORWARDED_FOR']))
{
$ip = $_SERVER['HTTP-X-FORWARDED_FOR'];
}
elseif (isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
else
{
if (getenv('HTTP-X-FORWARDED_FOR'))
{
$ip = getenv('HTTP-X-FORWARDED_FOR');
}
elseif (getenv('HTTP_CLIENT_IP'))
{
$ip = getenv('HTTP_CLIENT_IP');
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}
return $ip;
}
来源:原创
发布时间:2020-08-03 22:28:08