<?php

//设置编码为UTF-8
header("Content-type:text/txt; charset=utf-8");

//引入核心文件
require_once '../common.php';

//通过GET方式接收ip地址参数
if(isset($_GET['clientip'])){
	$clientip = $_GET['clientip'];
}

//IP解析方式（1.系统数据库；2.淘宝解析；3.其他方式待增加）
$ParsingMode = 1;

//IP解析
switch($ParsingMode){
	case 1:
		$iplocation = new Helper_IpLocation(SITE_DIR.'include/ipinfo/ipinfo.dat');
		$location = $iplocation->getlocation($clientip);
		if($location['country'] == '本机地址' || $location['country'] == '局域网'){
			echo CreateJsWriteCode('本地局域网');
		}
		else{
			echo CreateJsWriteCode($location['country']);
		}
		break;
	case 2:
		echo CreateJsWriteCode(GetIpInfo($clientip));
		break;
	case 3:
		echo "未知地区";
		break;
	default:
		echo "未知地区";
}

?>