diff --git a/application/admin/controller/api/Plugs.php b/application/admin/controller/api/Plugs.php index f5501a10f..5c6791e76 100644 --- a/application/admin/controller/api/Plugs.php +++ b/application/admin/controller/api/Plugs.php @@ -28,14 +28,13 @@ class Plugs extends Controller { /** - * Plugs constructor. + * 系统选择器图标 */ - public function __construct() + public function icon() { - parent::__construct(); - if (!NodeService::islogin()) { - $this->error('访问授权失败,请重新登录授权再试!'); - } + $this->title = '图标选择器'; + $this->field = input('field', 'icon'); + $this->fetch(); } /** @@ -46,13 +45,16 @@ class Plugs extends Controller */ public function plupload() { + if (!NodeService::islogin()) { + $this->error('访问授权失败,请重新登录授权再试!'); + } if (!($file = $this->getUploadFile()) || empty($file)) { return json(['uploaded' => false, 'error' => ['message' => '文件上传异常,文件可能过大或未上传']]); } if (!$file->checkExt(strtolower(sysconf('storage_local_exts')))) { return json(['uploaded' => false, 'error' => ['message' => '文件上传类型受限,请在后台配置']]); } - if ($file->checkExt('php')) { + if ($file->checkExt('php,sh')) { return json(['uploaded' => false, 'error' => ['message' => '可执行文件禁止上传到本地服务器']]); } $this->safe = boolval(input('safe')); @@ -95,14 +97,4 @@ class Plugs extends Controller } } - /** - * 系统选择器图标 - */ - public function icon() - { - $this->title = '图标选择器'; - $this->field = input('field', 'icon'); - $this->fetch(); - } - } diff --git a/application/admin/controller/api/Update.php b/application/admin/controller/api/Update.php index 9ce9b6a9b..bafad5c76 100644 --- a/application/admin/controller/api/Update.php +++ b/application/admin/controller/api/Update.php @@ -36,7 +36,7 @@ class Update extends Controller */ public function tree() { - $sync = new Sync('update'); + $sync = new Sync('Update'); $this->success('获取当前文件列表成功!', $sync->build()); } @@ -46,13 +46,14 @@ class Update extends Controller */ public function read($encode) { - $file = env('root_path') . decode($encode); - if (!file_exists($file)) { - $this->error('获取文件内容失败!'); - } else { - $this->success('获取文件内容成功!', [ - 'format' => 'base64', 'content' => base64_encode(file_get_contents($file)), + $this->file = env('root_path') . decode($encode); + if (file_exists($this->file)) { + $this->success('读取文件成功!', [ + 'format' => 'base64', + 'content' => base64_encode(file_get_contents($this->file)), ]); + } else { + $this->error('获取文件内容失败!'); } }