From 56cd916948941fbaaa5bb5de44fb9ab6e8a8a392 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sun, 26 Apr 2020 10:49:10 +0800 Subject: [PATCH] ComposerUpdate --- app/admin/controller/api/Plugs.php | 10 ++++---- app/admin/view/index/index.html | 2 +- composer.json | 2 ++ composer.lock | 14 ++++++----- vendor/composer/installed.json | 8 +++---- vendor/services.php | 2 +- .../src/service/AdminService.php | 23 ++++++++++++------- 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php index 6d0fa360e..11a905160 100644 --- a/app/admin/controller/api/Plugs.php +++ b/app/admin/controller/api/Plugs.php @@ -42,10 +42,10 @@ class Plugs extends Controller * 网站压缩发布 * @login true */ - public function online() + public function push() { try { - if (AdminService::instance()->getUserName() !== 'admin') { + if (AdminService::instance()->isSuper()) { $this->error('只有超级管理员才能操作!'); } $this->app->console->call('optimize:route'); @@ -65,7 +65,7 @@ class Plugs extends Controller public function clear() { try { - if (AdminService::instance()->getUserName() !== 'admin') { + if (AdminService::instance()->isSuper()) { $this->error('只有超级管理员才能操作!'); } $data = SystemService::instance()->getRuntime(); @@ -86,7 +86,7 @@ class Plugs extends Controller public function debug() { if (input('state')) { - if (AdminService::instance()->getUserName() !== 'admin') { + if (AdminService::instance()->isSuper()) { $this->error('只有超级管理员才能操作!'); } SystemService::instance()->productMode(true); @@ -103,7 +103,7 @@ class Plugs extends Controller */ public function optimize() { - if (AdminService::instance()->getUserName() !== 'admin') { + if (AdminService::instance()->isSuper()) { $this->error('只有超级管理员才能操作!'); } $this->_queue('优化数据库所有数据表', 'xadmin:dbOptimize', 0, [], 0, 0); diff --git a/app/admin/view/index/index.html b/app/admin/view/index/index.html index 830da04a1..ab170b8b9 100644 --- a/app/admin/view/index/index.html +++ b/app/admin/view/index/index.html @@ -51,7 +51,7 @@
基本资料
安全设置
{if session('user.username') eq 'admin'} -
缓存加速
+
缓存加速
清理缓存
{/if}
退出登录
diff --git a/composer.json b/composer.json index 5a5493ded..7a87ba461 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,14 @@ "require": { "php": ">=7.1.0", "ext-gd": "*", + "ext-xml": "*", "ext-soap": "*", "ext-json": "*", "ext-curl": "*", "ext-iconv": "*", "ext-openssl": "*", "ext-mbstring": "*", + "ext-simplexml": "*", "endroid/qr-code": "^1.9", "topthink/framework": "^6.0", "topthink/think-view": "^1.0", diff --git a/composer.lock b/composer.lock index 254c12098..c1bd354b4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c55d51d2e1cb52e013e7635caf4fb45c", + "content-hash": "ca7a0ef3ca75a7287eb4c5ecf7e156f3", "packages": [ { "name": "endroid/qr-code", @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "e4c99cc5188f842c2842b0822e9e93328932900d" + "reference": "692d1f717a5010707d7bd4148d028602f0e3ba00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e4c99cc5188f842c2842b0822e9e93328932900d", - "reference": "e4c99cc5188f842c2842b0822e9e93328932900d", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/692d1f717a5010707d7bd4148d028602f0e3ba00", + "reference": "692d1f717a5010707d7bd4148d028602f0e3ba00", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-04-23T09:59:16+00:00" + "time": "2020-04-26T02:44:32+00:00" }, { "name": "zoujingli/wechat-developer", @@ -1037,12 +1037,14 @@ "platform": { "php": ">=7.1.0", "ext-gd": "*", + "ext-xml": "*", "ext-soap": "*", "ext-json": "*", "ext-curl": "*", "ext-iconv": "*", "ext-openssl": "*", - "ext-mbstring": "*" + "ext-mbstring": "*", + "ext-simplexml": "*" }, "platform-dev": [] } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 846c17666..f52a2e7cf 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "e4c99cc5188f842c2842b0822e9e93328932900d" + "reference": "692d1f717a5010707d7bd4148d028602f0e3ba00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e4c99cc5188f842c2842b0822e9e93328932900d", - "reference": "e4c99cc5188f842c2842b0822e9e93328932900d", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/692d1f717a5010707d7bd4148d028602f0e3ba00", + "reference": "692d1f717a5010707d7bd4148d028602f0e3ba00", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-04-23T09:59:16+00:00", + "time": "2020-04-26T02:44:32+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 0d9ed628c..2266fa1ae 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/service/AdminService.php b/vendor/zoujingli/think-library/src/service/AdminService.php index 013f7518d..3927e1e03 100644 --- a/vendor/zoujingli/think-library/src/service/AdminService.php +++ b/vendor/zoujingli/think-library/src/service/AdminService.php @@ -27,12 +27,21 @@ class AdminService extends Service { /** - * 判断是否已经登录 + * 是否已经登录 * @return boolean */ public function isLogin() { - return $this->app->session->get('user.id') ? true : false; + return $this->getUserId() > 0; + } + + /** + * 是否为超级用户 + * @return boolean + */ + public function isSuper() + { + return $this->getUserName() === 'admin'; } /** @@ -62,8 +71,8 @@ class AdminService extends Service */ public function check($node = '') { + if ($this->isSuper()) return true; $service = NodeService::instance(); - if ($this->app->session->get('user.username') === 'admin') return true; list($real, $nodes) = [$service->fullnode($node), $service->getMethods()]; if (!empty($nodes[$real]['isauth'])) { return in_array($real, $this->app->session->get('user.nodes', [])); @@ -80,11 +89,9 @@ class AdminService extends Service */ public function getTree($checkeds = []) { - list($nodes, $pnodes) = [[], []]; - $methods = array_reverse(NodeService::instance()->getMethods()); + list($nodes, $pnodes, $methods) = [[], [], array_reverse(NodeService::instance()->getMethods())]; foreach ($methods as $node => $method) { - $count = substr_count($node, '/'); - $pnode = substr($node, 0, strripos($node, '/')); + list($count, $pnode) = [substr_count($node, '/'), substr($node, 0, strripos($node, '/'))]; if ($count === 2 && !empty($method['isauth'])) { in_array($pnode, $pnodes) or array_push($pnodes, $pnode); $nodes[$node] = ['node' => $node, 'title' => $method['title'], 'pnode' => $pnode, 'checked' => in_array($node, $checkeds)]; @@ -110,7 +117,7 @@ class AdminService extends Service */ public function apply($force = false) { - if ($force) $this->app->cache->delete('system_auth_node'); + if ($force) $this->clearCache(); if (($uid = $this->app->session->get('user.id'))) { $user = $this->app->db->name('SystemUser')->where(['id' => $uid])->find(); if (($aids = $user['authorize'])) {