From 02d6d5a3f6ffb7385c7e7c3a64009d59e7499686 Mon Sep 17 00:00:00 2001 From: icret Date: Sun, 2 Jan 2022 20:12:16 +0800 Subject: [PATCH] =?UTF-8?q?API=20=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/admin.inc.php | 2 +- admin/counts.php | 2 +- admin/zui.chart.php | 2 +- api/apiTest/index.php | 38 --------------- .../apiFunction.php => function_API.php} | 47 +++++++++++++------ api/index.php | 34 +++++++------- application/footer.php | 1 - config/config.php | 2 +- 8 files changed, 53 insertions(+), 75 deletions(-) delete mode 100755 api/apiTest/index.php rename api/{application/apiFunction.php => function_API.php} (51%) diff --git a/admin/admin.inc.php b/admin/admin.inc.php index 58cbe9d..2d37a72 100755 --- a/admin/admin.inc.php +++ b/admin/admin.inc.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/../application/function.php'; require_once APP_ROOT . '/application/header.php'; require_once APP_ROOT . '/config/api_key.php'; -require_once APP_ROOT . '/api/application/apiFunction.php'; +require_once APP_ROOT . '/api/function_API.php'; if (!is_online()) { echo ' diff --git a/admin/counts.php b/admin/counts.php index 10034fc..7fb4db1 100755 --- a/admin/counts.php +++ b/admin/counts.php @@ -4,7 +4,7 @@ */ require_once '../application/header.php'; require_once APP_ROOT . '/config/api_key.php'; -require_once APP_ROOT . '/api/application/apiFunction.php'; +require_once APP_ROOT . '/api/function_API.php'; require_once APP_ROOT . '/application/chart.php'; // 检测登录 diff --git a/admin/zui.chart.php b/admin/zui.chart.php index 14089bf..d818800 100755 --- a/admin/zui.chart.php +++ b/admin/zui.chart.php @@ -4,7 +4,7 @@ */ require_once '../application/header.php'; require_once APP_ROOT . '/config/api_key.php'; -require_once APP_ROOT . '/api/application/apiFunction.php'; +require_once APP_ROOT . '/api/function_API.php'; require_once APP_ROOT . '/application/chart.php'; // 检测登录 diff --git a/api/apiTest/index.php b/api/apiTest/index.php deleted file mode 100755 index 1954a2e..0000000 --- a/api/apiTest/index.php +++ /dev/null @@ -1,38 +0,0 @@ - - EasyImage2.0'; -require_once '../../application/function.php'; -require_once APP_ROOT . '/application/header.php'; -require_once APP_ROOT . '/config/api_key.php'; - -// 如果关闭Api上传并且没有登录的情况下关闭测试接口 -if (!$config['apiStatus'] and !is_online()) { - exit(''); -} - -?> -
-
-
-

测试Token:

-
-
- -
-
- -
- -
-
- - - - - '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)); + } +} diff --git a/api/index.php b/api/index.php index 5c85ffb..558116f 100755 --- a/api/index.php +++ b/api/index.php @@ -1,20 +1,15 @@ uploaded) { $delUrl = $config['domain'] . '/application/del.php?hash=' . urlHash(config_path() . $handle->file_dst_name, 0); $reJson = array( - "result" => 'success', - "url" => $imageUrl, - "del" => $delUrl, + "result" => "success", + "code" => 200, + "url" => $imageUrl, + "del" => $delUrl, ); - echo json_encode($reJson); + echo json_encode($reJson,JSON_UNESCAPED_UNICODE); $handle->clean(); } else { - // 上传错误 返回错误信息 + // 上传错误 code:403 客户端文件有问题 $reJson = array( - "result" => 'failed', + "result" => "failed", + "code" => 403, "message" => $handle->error, - "log" => $handle->log, + //"log" => $handle->log, ); - echo json_encode($reJson, JSON_UNESCAPED_UNICODE); + + unset($handle); + header('Content-Type:application/json; charset=utf-8'); + exit(json_encode($reJson, JSON_UNESCAPED_UNICODE)); } // 上传日志控制 diff --git a/application/footer.php b/application/footer.php index 06fef3b..6690e21 100755 --- a/application/footer.php +++ b/application/footer.php @@ -65,7 +65,6 @@ 二维码 - API 退出 '; diff --git a/config/config.php b/config/config.php index 3b7e752..ff792fc 100755 --- a/config/config.php +++ b/config/config.php @@ -23,7 +23,7 @@ $config=Array 'waterImg'=>'/public/images/watermark.png', 'extensions'=>'bmp,jpg,png,tif,gif,pcx,tga,svg,webp,jpeg,tga,svg,ico', 'compress'=>0, - 'thumbnail'=>0, + 'thumbnail'=>1, 'imgConvert'=>'', 'maxWidth'=>10240, 'maxHeight'=>10240,