php获取用户ip

时间:2014-08-27 12:44:17   收藏:0   阅读:269
function getip(){
	if (getenv(‘HTTP_CLIENT_IP‘))
	{
		$ip = getenv(‘HTTP_CLIENT_IP‘); //可伪造
	}
	elseif (getenv(‘HTTP_X_FORWARDED_FOR‘))
	{
		$ip = getenv(‘HTTP_X_FORWARDED_FOR‘); //可伪造
	}
	elseif (getenv(‘HTTP_X_FORWARDED‘))
	{
		$ip = getenv(‘HTTP_X_FORWARDED‘);
	}
	elseif (getenv(‘HTTP_FORWARDED_FOR‘))
	{
		$ip = getenv(‘HTTP_FORWARDED_FOR‘);
	}
	elseif (getenv(‘HTTP_FORWARDED‘))
	{
		$ip = getenv(‘HTTP_FORWARDED‘);
	}
	else
	{
		$ip = $_SERVER[‘REMOTE_ADDR‘];
	}
	return $ip;
}

  php获取用户ip

原文:http://www.cnblogs.com/chenzhaojx/p/3939049.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!