diff --git a/api/icp/index.php b/api/icp/index.php new file mode 100644 index 0000000..52edf8b --- /dev/null +++ b/api/icp/index.php @@ -0,0 +1,110 @@ + +$url, 'type'=>$type]); + +class icp +{ + private $info = []; + private $array = []; + private $Message; + public function __construct(array $array) + { + /* php构造函数 类初始化时自动运行 */ + foreach($array as $k=>$v) + { + /* for循环获取参数并赋值到类中使用 */ + $this->info[$k] = $v; + } + $this->parameterException(); //调用类中方法 + } + private function parameterException() + { + /* 判断参数是否正常 */ + if(!stristr($this->info['url'], 'http')) + { + $this->info['url'] = 'http://'.$this->info['url']; + } + $host = parse_url($this->info['url'], PHP_URL_HOST); + if(!$host) + { + $this->evaluation(array('code'=>-1, 'text'=>'请输入正确的域名')); + return; + } + $this->run(); //调用方法 + return true; + } + private function Run() + { + $scheme = @parse_url($this->info['url'], PHP_URL_SCHEME); + $host = @parse_url($this->info['url'], PHP_URL_HOST); + $url = $scheme.'://'.$host; + $data = json_decode(trim(preg_replace('/([a-z]+):/i', '"$1":', preg_replace('/jQuery\((.*)\)/', '$1', need::teacher_curl('https://micp.chinaz.com/Handle/AjaxHandler.ashx?action=GetPermit&callback=jQuery&query='.$host.'&type=host&_=1672673081420'))))); + // print_r($data); + if(!isset($data->Typ)) + { + $this->evaluation(array('code'=>-2, 'text'=>'备案数据获取失败')); + return; + } + $String = ''; + $array = array( + 'unit'=>$data->ComName, + 'property'=>$data->Typ, + 'record'=>$data->Permit, + 'hostname'=>$data->WebName, + ); + $String = "主办单位:{$data->ComName}\n单位性质:{$data->Typ}\n网站名字:{$data->WebName}\n网站备案号:{$data->Permit}"; + $String = trim($String, PHP_EOL); + $this->evaluation(array('code'=>1, 'text'=>'获取成功', 'data'=>$array), $String); + return; + } + private function delete() : bool + { + /* 删除已有参数 */ + unset($this->array, $this->Message); + return true; + } + private function evaluation(array $array, $string = false) : bool + { + /* 输出数据 */ + $string = $string ? $string : $array['text']; //判断$string是否存在 + $this->delete(); //调用删除方法 + $this->array = $array; //赋值 + $this->Message = $string; //赋值 + $this->result(); //输出内容 + return true; + } + private function result() + { + $info = $this->info; + $type = isset($info['type']) ? $info['type'] : 'json'; + Switch($type) + { + case 'text': + need::send($this->Message, 'text'); + break; + default: + need::send($this->array, 'json'); + break; + } + return true; + } +} + + + + diff --git a/api/sjsp/index.php b/api/sjsp/index.php index a691b6e..626bb9a 100644 --- a/api/sjsp/index.php +++ b/api/sjsp/index.php @@ -1,3 +1,13 @@ + $msg, 'n'=>$b, 'num'=>$num, 'type'=>$type)); +class 三日天气多选{ + protected $info = []; + protected $Array = []; + protected $Msg; + public function __construct(Array $Array){ + foreach($Array as $k=>$v){ + $this->info[$k] = $v; + } + $this->ParameterException(); + } + protected function ParameterException(){ + $name = $this->info['name']; + if(empty($name)){ + $this->Array = Array('code'=>-1, 'text'=>'请输入地名'); + $this->send(); + return; + } + $n = $this->info['n']; + if($n > 0 && is_numEric($n)){ + $this->info['n'] = $n - 1; + }else{ + $this->info['n'] = false; + } + $num = $this->info['num']; + if($num < 1 && is_numEric($num)){ + $this->info['num'] = 10; + }else{ + $this->info['num'] = 10; + } + $this->Getdata(); + return; + } + protected function Getdata(){ + $name = ($this->info['name']); + $data = need::teacher_curl('http://m.moji.com/api/citysearch/'.$name); + $result = preg_match_all("/{\"cityId\":(.*?),\"city_lable\":(.*?),\"counname\":\"(.*?)\",\"id\":(.*?),\"localCounname\":\"(.*?)\",\"localName\":\"(.*?)\",\"localPname\":\"(.*?)\",\"name\":\"(.*?)\",\"pname\":\"(.*?)\"}/",$data,$nute); + $n = $this->info['n']; + //print_r($nute);exit; + $Array = []; + $num = $this->info['num']; + if($n === false){ + for ($x=0; $x < $result && $x < $num; $x++) { + $jec=$nute[6][$x]; + $je=$nute[7][$x]; + $echo .= ($x+1).":".$je."-".$jec."\n"; + $Array[] = Array('city'=>$je, 'city_t'=>$jec); + } + $this->Msg = trim($echo); + $this->Array = Array('code'=>1, 'text'=>'获取成功', 'data'=>$Array); + $this->send(); + return; + } + $je=$nute[1][$n]; + $jec=$nute[6][$n]; + $data = file_Get_Contents("http://m.moji.com/api/redirect/".$je); + $bb=jiequ($data,"