<?php
include_once "connectmysql.php";
session_start();
header("Content-Type:text/json;charset=utf-8");
//文件名:hfxWeather.php
try
{
$citysn=json_decode(file_get_contents('php://input'),true); //true表示返回array
$link='';
$cid='';
#初步纠错,特殊处理
if($citysn['cid']=='CN') //错误就默认为深圳
$cid='440300';
else if($citysn['cid']=='88')
$cid='421126';
else
$cid=$citysn['cid'];
//中间城市代码为00就改为01
if(substr($citysn['cid'],2,2)=='00')
{
$citysn['cid']=substr_replace($citysn['cid'],'01',2,2);
}
$exist=exist_ipAdm($conne,$citysn['cip']);
if($exist)
{
$count=querycounter_ipAdm($conne,$citysn['cip']);
updateCounter_ipAdm($conne,$citysn['cip'],$count+1);
/*if(exist_ipadmjoinfxlink($conne,$citysn['cip']))
$link=queryfxLink_ipadmjoinfxlink($conne,$citysn['cip']);*/
if(existadcode_ipAdm($conne,$citysn['cip']))
{
$code=queryadcode_ipAdm($conne,$citysn['cip']);
if(substr($code,2,2)=='00')
{
$code=substr_replace($code,'01',2,2);
}
if(existlink_hfxLink($conne,$code))
$link=queryfxLink($conne,$code);
else
hfxgeo_Request($conne,$code);
}
else
{
hfxgeo_Request($conne,$citysn['cid']);
}
}
else
{
insert_ipAdm($conne,$citysn['cip'],$cid,$citysn['cname']);
hfxgeo_Request($conne,$cid);
}
exit(json_encode($link));
}
catch(Exception $err)
{
error_log($err->getMessage(),$err->getCode(),$err->getFile(),$err->getTraceAsString());
}
?>
|