include_once('./qqwry.PHP');
$QQWry=new QQWry;
function get_real_ip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode (",",$_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip) { array_unshift($ips,$ip); $ip = FALSE; }
for ($i = 0; $i < count($ips); $i++) {
if (!eregi ("^(10|172.16|192.168).",$ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
return $ip;
}
function is_ip($str) {
$ip = explode(".",$str);
if (count($ip)<4 || count($ip)>4) return 0;
foreach($ip as $ip_addr) {
if ( !is_numeric($ip_addr) ) return 0;
if ( $ip_addr<0 || $ip_addr>255 ) return 0;
}
return 1;
}
$ip=$_SERVER['REMOTE_ADDR'];
$ifErr=$QQWry->QQWry($ip);
$city = $QQWry->Country.$QQWry->Local;
//echo $city;*/
if (strpos($city,'玄武区')!==false){
$city = "玄武区";
}
else if(strpos($city,'仙林')!==false){
$city = "仙林";
}
else if(strpos($city,'秦淮区')!==false){
$city = "秦淮区";
}
else if(strpos($city,'江宁')!==false){
$city = "江宁";
}
else if(strpos($city,'鼓楼')!==false){
$city = "鼓楼";
}
else{
$city = "栖霞";
}
if (isset($_GET['chengshi'])) { //Ê×Ïȼì²âÊÇ·ñ»ñµÃÁË GET ´«µÝµÄÊý¾Ý
setcookie("cookie_city",$_GET['chengshi'],time()+360024);
$city = $_GET['chengshi'];
}
else if (isset($_COOKIE["cookie_city"])) { //¼ì²âÊÇ·ñ´æÔÚêdzÆCookie
$city = $_COOKIE["cookie_city"]; //ÏÔʾCookie±£´æµÄÊý¾Ý
}
else {
setcookie("cookie_city",$city,time()+360024); //´¿³õʼ»¯´Ë±äÁ¿
$_COOKIE["cookie_city"] = $city;
}
?>