code = $code; $this->day = strtotime(date('Y-m-d')); if($errcount) $this->errcount = true; } //检查IP白名单 public function checkIP(){ global $Array_API_IP_WhiteList; $ip = getIP();//This Function in lib/function_common@WiiPHP if(!in_array($ip, $Array_API_IP_WhiteList)) $this->ApiError('999', 'IP不在白名单'); } //发生错误 public function ApiError($errcode, $errmsg){ $this->error = true; //统计 if($this->errcount) $this->apicount(); $err = array(); $err['code'] = $errcode; $err['message'] = $errmsg; $err['data'] = null; $err_json = json_encode_cn($err); echo $err_json; exit();//发生错误直接退出 } //API调用统计 public function apicount(){ if($this->is_newday()){ $this->count_newday(); }else{ $this->count_update(); } } //API 设置来源 public function setsource($source){ $this->source = $source; } } ?>