<?php
/*
 * Ourphp - CMS建站系统
 * Copyright (C) 2014 ourphp.net
 * 开发者：哈尔滨伟成科技有限公司
 *-------------------------------
 * IP接口
 *-------------------------------
*/
if(!defined('OURPHPNO')){exit('no!');}
if(getenv('HTTP_CLIENT_IP')) { 

	$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR')) { 

	$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR')) { 

	$onlineip = getenv('REMOTE_ADDR');
} else {
	$onlineip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
}

if(empty($_SESSION['ourphp_ip']))
{
	if($onlineip != '127.0.0.1'){
		$url = 'http://ip-api.com/json/'.$onlineip.'?lang=zh-CN';
		$info = file_get_contents($url);
		$info = json_decode($info,true);
		
		$taobaoip = $info['regionName'];
		$_SESSION['ourphp_ip'] = $taobaoip;
		
	}else{
		
		$taobaoip = '本地IP';
	}
	
}else{
	
	$taobaoip = $_SESSION['ourphp_ip'];
}

?>