$RangE= $RecNo;
}
$this->getStartIp ( $RangB ) ;
$this->getEndIp ( ) ;
if ( ( $this->StartIp <= $ip ) && ( $this->EndIp >= $ip ) ){
$nRet=0 ;
$this->getCountry ( ) ;
//这样不太好..............所以..........
$this->Local=str_replace("(我们一定要解放台湾!!!)", "", $this->Local);
}
else{
$nRet=3 ;
$this->Country='未知' ;
$this->Local='' ;
}
fclose ( $this->fp );
$this->Country=preg_replace("/(CZ88.NET)|(纯真网络)/","局域网/未知",$this->Country);
$this->Local=preg_replace("/(CZ88.NET)|(纯真网络)/","局域网/未知",$this->Local);
//////////////看看 $nRet在上面的值是什么0和3,于是将下面的行注释掉
return $nRet ;
//return "$this->Country $this->Local";#如此直接返回位置和国家便可以了
}
function IpToInt($Ip) {
$array=explode('.',$Ip);
$Int=($array[0] * 256*256*256) + ($array[1]*256*256) + ($array[2]*256) + $array[3];
return $Int;
}
}
function GetIP(){//获取IP
return $_SERVER[REMOTE_ADDR]?$_SERVER[REMOTE_ADDR]:$GLOBALS[HTTP_SERVER_VARS][REMOTE_ADDR];
}
?>
[/php]
-----------------------------------------------
解决方案是:
是因为 QQWry.dat 默认就是gb2312编码的。
解决的方法有两种:
1. 在这个代码的后面直接进行转码后,再返回。例如
return iconv('gb2312', 'utf-8', "$this->Country $this->Local";#如此直接返回位置和国家便可以了
2. 就是把 QQWry.dat 转换为 utf-8 编码的。这个效率最高,当然这个需要有一个生成工具。