= 0) { return $key; } else { return ('没有这个用户ID'); } } // 通过ID查找用户Token function getIDToken($id) { global $tokenList; $id = preg_replace('/[\W]/', '', $id); // 过滤非字母数字,删除空格 foreach ($tokenList as $key => $value) { if ($key == $id) { return $value; } } } /** * 检查是否开启api上传 * code:201 访问成功但是服务端关闭API上传 * code:202 访问成功但是Token错误 */ function check_api($token) { global $config; global $tokenList; if (!$config['apiStatus']) { // API关闭 服务端关闭API上传 $reJson = array( "result" => 'failed', 'code' => 201, 'message' => 'API Closed', ); exit(json_encode($reJson, JSON_UNESCAPED_UNICODE)); } if (!in_array($token, $tokenList)) { // Token错误 Token错误 $reJson = array( "result" => 'failed', 'code' => 202, 'message' => 'Token Error', ); exit(json_encode($reJson, JSON_UNESCAPED_UNICODE)); } }