function IP($ip='',$charset='gbk',$file='QQWry.dat') {
static $_ip = array();
if(isset($_ip[$ip])) {
return $_ip[$ip];
}else{
import("ORG.Net.IpLocation");
$iplocation = new IpLocation($file);
$location = $iplocation->getlocation($ip);
$_ip[$ip] = $location['country'].$location['area'];
}
if('utf-8' != $charset) {
$_ip[$ip] = iconv($charset,'utf-8',$_ip[$ip]);
}
return $_ip[$ip];
}