/**
* auth:leishaofa
* php获取用户真实 IP
* 注意这种方式只适用于浏览器访问时
*/
function getUserIP()
{
$onlineip='';
if(getenv('HTTP_CLIENT_IP')&&strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')){
$onlineip=getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR')&&strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')){
$onlineip=getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR')&&strcasecmp(getenv('REMOTE_ADDR'),'unknown')){
$onlineip=getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')){
$onlineip=$_SERVER['REMOTE_ADDR'];
}
if($onlineip=='127.0.0.1'){
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 2
)
);
$headertop = stream_context_create($opts);
//$content=file_get_contents('http://'.date('Y').'.ip138.com/ic.asp',$headertop);
//$onlineip=substr($content,stripos($content,'[')+1,stripos($content,']')-//stripos($content,'[')-1);
// }
再就是截取网站div划分数组反正办法多
return $onlineip;
//dump(phpinfo());//所有PHP配置信息
}