diff --git a/app/admin/controller/Auth.php b/app/admin/controller/Auth.php index dcecf53e6..a635d1765 100644 --- a/app/admin/controller/Auth.php +++ b/app/admin/controller/Auth.php @@ -15,11 +15,8 @@ namespace app\admin\controller; -use app\admin\service\AuthService; -use app\admin\service\MenuService; -use app\admin\service\NodeService; use think\admin\Controller; -use think\Db; +use think\admin\service\AuthService; /** * 系统权限管理 @@ -112,7 +109,7 @@ class Auth extends Controller $action = strtolower(input('action', '')); if ($action === 'get') { $checkeds = $this->app->db->name('SystemAuthNode')->where($map)->column('node'); - $this->success('获取权限节点成功!', AuthService::getTree($checkeds)); + $this->success('获取权限节点成功!', AuthService::instance($this->app)->getTree($checkeds)); } elseif ($action === 'save') { list($post, $data) = [$this->request->post(), []]; foreach (isset($post['nodes']) ? $post['nodes'] : [] as $node) { @@ -120,7 +117,7 @@ class Auth extends Controller } $this->app->db->name('SystemAuthNode')->where($map)->delete(); $this->app->db->name('SystemAuthNode')->insertAll($data); - AuthService::apply(true); + AuthService::instance($this->app)->apply(true); $this->success('权限授权更新成功!', 'javascript:history.back()'); } else { $this->title = '权限配置节点'; diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index 1de55bfd9..ef4d6d23f 100644 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -48,7 +48,7 @@ class Config extends Controller * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function config() + public function system() { $this->_applyFormToken(); if ($this->request->isGet()) { diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 12ffd80e1..90887a8b3 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -15,10 +15,10 @@ namespace app\admin\controller; -use app\admin\service\AuthService; -use app\admin\service\MenuService; use think\admin\Controller; use think\admin\extend\DataExtend; +use think\admin\service\AuthService; +use think\admin\service\MenuService; /** * 后台界面入口 @@ -38,9 +38,9 @@ class Index extends Controller public function index() { $this->title = '系统管理后台'; - AuthService::apply(true); - $this->menus = MenuService::getTree(); - if (empty($this->menus) && !AuthService::isLogin()) { + AuthService::instance($this->app)->apply(true); + $this->menus = MenuService::instance($this->app)->getTree(); + if (empty($this->menus) && !AuthService::instance($this->app)->isLogin()) { $this->redirect(url('@admin/login')); } else { $this->fetch(); @@ -59,6 +59,7 @@ class Index extends Controller /** * 修改用户资料 + * @login true * @param integer $id 会员ID * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException @@ -66,9 +67,6 @@ class Index extends Controller */ public function info($id = 0) { - if (!AuthService::isLogin()) { - $this->error('需要登录才能操作哦!'); - } $this->_applyFormToken(); if (intval($this->app->session->get('user.id')) === intval($id)) { $this->_form('SystemUser', 'admin@user/form', 'id', [], ['id' => $id]); @@ -79,6 +77,7 @@ class Index extends Controller /** * 修改当前用户密码 + * @login true * @param integer $id * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException @@ -86,9 +85,6 @@ class Index extends Controller */ public function pass($id = 0) { - if (!AuthService::isLogin()) { - $this->error('需要登录才能操作哦!'); - } $this->_applyFormToken(); if (intval($this->app->session->get('user.id')) !== intval($id)) { $this->error('只能修改当前用户的密码!'); diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index b6a043c79..bfb4e4b9c 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -15,9 +15,9 @@ namespace app\admin\controller; -use app\admin\service\AuthService; use think\admin\Controller; -use think\admin\extend\CaptchaExtend; +use think\admin\service\AuthService; +use think\admin\service\CaptchaService; /** * 用户登录管理 @@ -35,21 +35,21 @@ class Login extends Controller public function index() { if ($this->app->request->isGet()) { - if (AuthService::isLogin()) { + if (AuthService::instance($this->app)->isLogin()) { $this->redirect(url('@admin')->suffix(false)->build()); } else { $this->title = '系统登录'; $this->domain = $this->app->request->host(true); $this->devmode = in_array($this->domain, ['127.0.0.1', 'localhost']); $this->devmode = $this->devmode ?: is_numeric(stripos($this->domain, 'thinkadmin.top')); - $this->captcha = CaptchaExtend::instance(); + $this->captcha = CaptchaService::instance($this->app); $this->fetch(); } } elseif ($this->app->request->isPost()) { $data = ['username' => input('username'), 'password' => input('password')]; if (empty($data['username'])) $this->error('登录账号不能为空!'); if (empty($data['password'])) $this->error('登录密码不能为空!'); - if (!CaptchaExtend::check(input('verify'), input('uniqid'))) { + if (!CaptchaService::instance($this->app)->check(input('verify'), input('uniqid'))) { $this->error('图形验证码验证失败,请重新输入!'); } // 用户信息验证 @@ -80,7 +80,7 @@ class Login extends Controller */ public function captcha() { - $image = CaptchaExtend::instance(); + $image = CaptchaService::instance($this->app); $this->success('生成验证码成功', [ 'image' => $image->getData(), 'uniqid' => $image->getUniqid(), diff --git a/app/admin/controller/Menu.php b/app/admin/controller/Menu.php index fbde8f4d9..b797c8339 100644 --- a/app/admin/controller/Menu.php +++ b/app/admin/controller/Menu.php @@ -15,9 +15,9 @@ namespace app\admin\controller; -use app\admin\service\MenuService; use think\admin\Controller; use think\admin\extend\DataExtend; +use think\admin\service\MenuService; /** * 系统菜单管理 @@ -111,7 +111,7 @@ class Menu extends Controller $vo['pid'] = $this->request->get('pid', '0'); } // 读取系统功能节点 - $this->nodes = MenuService::getList(); + $this->nodes = MenuService::instance($this->app)->getList(); } } diff --git a/app/admin/controller/Oplog.php b/app/admin/controller/Oplog.php index 8af46eca2..deffbd0df 100644 --- a/app/admin/controller/Oplog.php +++ b/app/admin/controller/Oplog.php @@ -16,7 +16,6 @@ namespace app\admin\controller; use think\admin\Controller; -use think\Db; /** * 系统日志管理 diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index 3563c7ce3..b5a03f109 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -15,9 +15,9 @@ namespace app\admin\controller; -use app\admin\service\AuthService; use think\admin\Controller; use think\admin\extend\DataExtend; +use think\admin\service\AuthService; /** * 系统用户管理 @@ -111,7 +111,7 @@ class User extends Controller { if ($this->request->isPost()) { // 刷新系统授权 - AuthService::apply(); + AuthService::instance($this->app)->apply(); // 用户权限处理 $data['authorize'] = (isset($data['authorize']) && is_array($data['authorize'])) ? join(',', $data['authorize']) : ''; // 用户账号重复检查 diff --git a/app/admin/controller/api/Update.php b/app/admin/controller/api/Update.php index e88e7a7e1..8703b5f86 100644 --- a/app/admin/controller/api/Update.php +++ b/app/admin/controller/api/Update.php @@ -16,7 +16,7 @@ namespace app\admin\controller\api; use think\admin\Controller; -use think\admin\install\ExtendInstall; +use think\admin\service\InstallService; /** * 安装服务端支持 @@ -32,7 +32,7 @@ class Update extends Controller { $this->rules = unserialize($this->request->post('rules', 'a:0:{}', '')); $this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', '')); - $this->success('获取文件列表成功!', ExtendInstall::instance($this->app)->getList($this->rules, $this->ignore)); + $this->success('获取文件列表成功!', InstallService::instance($this->app)->getList($this->rules, $this->ignore)); } /** diff --git a/app/admin/sys.php b/app/admin/sys.php index 42ce5641a..9e7d6ba64 100644 --- a/app/admin/sys.php +++ b/app/admin/sys.php @@ -1,4 +1,5 @@ db->name('SystemOplog')->insert([ - 'node' => NodeExtend::getCurrent(), + 'node' => NodeService::instance()->getCurrent(), 'action' => $action, 'content' => $content, 'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : app()->request->ip(), 'username' => PHP_SAPI === 'cli' ? 'cli' : app()->session->get('user.username'), diff --git a/app/admin/view/config/index.html b/app/admin/view/config/index.html index 888d2ac00..de2df9f66 100644 --- a/app/admin/view/config/index.html +++ b/app/admin/view/config/index.html @@ -5,7 +5,7 @@ {if auth('config')}
系统参数配置: - 修改系统配置 + 修改系统配置
{/if} diff --git a/app/admin/view/config/config.html b/app/admin/view/config/system.html similarity index 100% rename from app/admin/view/config/config.html rename to app/admin/view/config/system.html diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index b439b4f5e..7a070ebda 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -1,9 +1,26 @@ =7.1.0", "ext-gd": "*", "ext-json": "*", + "ext-curl": "*", + "ext-iconv": "*", "topthink/framework": "^6.0", "topthink/think-view": "^1.0", "topthink/think-multi-app": "^1.0", diff --git a/composer.lock b/composer.lock index e0b7d8692..31d2262f6 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": "387856954688245acf7e8623d243fb5d", + "content-hash": "44a6bc247971794be9edd9df4f3dd0b9", "packages": [ { "name": "league/flysystem", @@ -783,12 +783,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "8fe807f96681e800b32c5fe775e2b92def2396d3" + "reference": "e561d021e18776a9851646236e6af556c77eec6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8fe807f96681e800b32c5fe775e2b92def2396d3", - "reference": "8fe807f96681e800b32c5fe775e2b92def2396d3", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e561d021e18776a9851646236e6af556c77eec6a", + "reference": "e561d021e18776a9851646236e6af556c77eec6a", "shasum": "", "mirrors": [ { @@ -832,7 +832,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2019-11-04T11:04:29+00:00" + "time": "2019-11-09T08:03:23+00:00" } ], "packages-dev": [], @@ -846,7 +846,9 @@ "platform": { "php": ">=7.1.0", "ext-gd": "*", - "ext-json": "*" + "ext-json": "*", + "ext-curl": "*", + "ext-iconv": "*" }, "platform-dev": [] } diff --git a/route/demo.php b/route/demo.php new file mode 100644 index 000000000..594ad978e --- /dev/null +++ b/route/demo.php @@ -0,0 +1,46 @@ +rootDomain(), ['ctolog.com', 'thinkadmin.top'])) { + $app = app(); + $app->route->post('admin/user/pass', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); + }); + $app->route->post('admin/index/pass', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); + }); + $app->route->post('admin/config/config', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); + }); + $app->route->post('admin/config/storage', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); + }); + $app->route->post('admin/menu/index', function () { + return json(['code' => 0, 'info' => '演示环境禁止给菜单排序!']); + }); + $app->route->post('admin/menu/add', function () { + return json(['code' => 0, 'info' => '演示环境禁止添加菜单!']); + }); + $app->route->post('admin/menu/edit', function () { + return json(['code' => 0, 'info' => '演示环境禁止编辑菜单!']); + }); + $app->route->post('admin/menu/state', function () { + return json(['code' => 0, 'info' => '演示环境禁止禁用菜单!']); + }); + $app->route->post('admin/menu/remove', function () { + return json(['code' => 0, 'info' => '演示环境禁止删除菜单!']); + }); +} diff --git a/vendor/autoload.php b/vendor/autoload.php index 873dc194f..cfa6b03af 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af::getLoader(); +return ComposerAutoloaderInitb8e4029a37bf108c1da00ff988d7544f::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 67f6c39a0..595f23c20 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -106,8 +106,6 @@ return array( 'app\\admin\\controller\\api\\Plugs' => $baseDir . '/app/admin/controller/api/Plugs.php', 'app\\admin\\controller\\api\\Update' => $baseDir . '/app/admin/controller/api/Update.php', 'app\\admin\\controller\\api\\Upload' => $baseDir . '/app/admin/controller/api/Upload.php', - 'app\\admin\\service\\AuthService' => $baseDir . '/app/admin/service/AuthService.php', - 'app\\admin\\service\\MenuService' => $baseDir . '/app/admin/service/MenuService.php', 'app\\index\\controller\\Index' => $baseDir . '/app/index/controller/Index.php', 'think\\App' => $vendorDir . '/topthink/framework/src/think/App.php', 'think\\Cache' => $vendorDir . '/topthink/framework/src/think/Cache.php', @@ -141,33 +139,36 @@ return array( 'think\\Validate' => $vendorDir . '/topthink/framework/src/think/Validate.php', 'think\\View' => $vendorDir . '/topthink/framework/src/think/View.php', 'think\\admin\\Controller' => $vendorDir . '/zoujingli/think-library/src/Controller.php', + 'think\\admin\\Helper' => $vendorDir . '/zoujingli/think-library/src/Helper.php', 'think\\admin\\Queue' => $vendorDir . '/zoujingli/think-library/src/Queue.php', + 'think\\admin\\Service' => $vendorDir . '/zoujingli/think-library/src/Service.php', 'think\\admin\\Storage' => $vendorDir . '/zoujingli/think-library/src/Storage.php', 'think\\admin\\ThinkLibrary' => $vendorDir . '/zoujingli/think-library/src/ThinkLibrary.php', - 'think\\admin\\extend\\CaptchaExtend' => $vendorDir . '/zoujingli/think-library/src/extend/CaptchaExtend.php', 'think\\admin\\extend\\CodeExtend' => $vendorDir . '/zoujingli/think-library/src/extend/CodeExtend.php', 'think\\admin\\extend\\CsvExtend' => $vendorDir . '/zoujingli/think-library/src/extend/CsvExtend.php', 'think\\admin\\extend\\DataExtend' => $vendorDir . '/zoujingli/think-library/src/extend/DataExtend.php', 'think\\admin\\extend\\ExpressExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ExpressExtend.php', 'think\\admin\\extend\\HttpExtend' => $vendorDir . '/zoujingli/think-library/src/extend/HttpExtend.php', - 'think\\admin\\extend\\NodeExtend' => $vendorDir . '/zoujingli/think-library/src/extend/NodeExtend.php', 'think\\admin\\extend\\ProcessExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ProcessExtend.php', - 'think\\admin\\extend\\TokenExtend' => $vendorDir . '/zoujingli/think-library/src/extend/TokenExtend.php', 'think\\admin\\helper\\DeleteHelper' => $vendorDir . '/zoujingli/think-library/src/helper/DeleteHelper.php', 'think\\admin\\helper\\FormHelper' => $vendorDir . '/zoujingli/think-library/src/helper/FormHelper.php', - 'think\\admin\\helper\\Helper' => $vendorDir . '/zoujingli/think-library/src/helper/Helper.php', 'think\\admin\\helper\\PageHelper' => $vendorDir . '/zoujingli/think-library/src/helper/PageHelper.php', 'think\\admin\\helper\\QueryHelper' => $vendorDir . '/zoujingli/think-library/src/helper/QueryHelper.php', 'think\\admin\\helper\\SaveHelper' => $vendorDir . '/zoujingli/think-library/src/helper/SaveHelper.php', 'think\\admin\\helper\\TokenHelper' => $vendorDir . '/zoujingli/think-library/src/helper/TokenHelper.php', 'think\\admin\\install\\CommandInstall' => $vendorDir . '/zoujingli/think-library/src/install/CommandInstall.php', - 'think\\admin\\install\\ExtendInstall' => $vendorDir . '/zoujingli/think-library/src/install/ExtendInstall.php', 'think\\admin\\queue\\ListenQueue' => $vendorDir . '/zoujingli/think-library/src/queue/ListenQueue.php', 'think\\admin\\queue\\QueryQueue' => $vendorDir . '/zoujingli/think-library/src/queue/QueryQueue.php', 'think\\admin\\queue\\StartQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StartQueue.php', 'think\\admin\\queue\\StateQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StateQueue.php', 'think\\admin\\queue\\StopQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StopQueue.php', 'think\\admin\\queue\\WorkQueue' => $vendorDir . '/zoujingli/think-library/src/queue/WorkQueue.php', + 'think\\admin\\service\\AuthService' => $vendorDir . '/zoujingli/think-library/src/service/AuthService.php', + 'think\\admin\\service\\CaptchaService' => $vendorDir . '/zoujingli/think-library/src/service/CaptchaService.php', + 'think\\admin\\service\\InstallService' => $vendorDir . '/zoujingli/think-library/src/service/InstallService.php', + 'think\\admin\\service\\MenuService' => $vendorDir . '/zoujingli/think-library/src/service/MenuService.php', + 'think\\admin\\service\\NodeService' => $vendorDir . '/zoujingli/think-library/src/service/NodeService.php', + 'think\\admin\\service\\TokenService' => $vendorDir . '/zoujingli/think-library/src/service/TokenService.php', 'think\\admin\\storage\\LocalStorage' => $vendorDir . '/zoujingli/think-library/src/storage/LocalStorage.php', 'think\\admin\\storage\\QiniuStorage' => $vendorDir . '/zoujingli/think-library/src/storage/QiniuStorage.php', 'think\\app\\MultiApp' => $vendorDir . '/topthink/think-multi-app/src/MultiApp.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 06d7f7541..fb889ef4a 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af +class ComposerAutoloaderInitb8e4029a37bf108c1da00ff988d7544f { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitb8e4029a37bf108c1da00ff988d7544f', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitb8e4029a37bf108c1da00ff988d7544f', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit31a52c657911214987b8ff9fa2a257af::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInit31a52c657911214987b8ff9fa2a257af $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit31a52c657911214987b8ff9fa2a257af::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire31a52c657911214987b8ff9fa2a257af($fileIdentifier, $file); + composerRequireb8e4029a37bf108c1da00ff988d7544f($fileIdentifier, $file); } return $loader; } } -function composerRequire31a52c657911214987b8ff9fa2a257af($fileIdentifier, $file) +function composerRequireb8e4029a37bf108c1da00ff988d7544f($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 4f51d24c6..4dd0adc26 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit31a52c657911214987b8ff9fa2a257af +class ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f { public static $files = array ( '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', @@ -197,8 +197,6 @@ class ComposerStaticInit31a52c657911214987b8ff9fa2a257af 'app\\admin\\controller\\api\\Plugs' => __DIR__ . '/../..' . '/app/admin/controller/api/Plugs.php', 'app\\admin\\controller\\api\\Update' => __DIR__ . '/../..' . '/app/admin/controller/api/Update.php', 'app\\admin\\controller\\api\\Upload' => __DIR__ . '/../..' . '/app/admin/controller/api/Upload.php', - 'app\\admin\\service\\AuthService' => __DIR__ . '/../..' . '/app/admin/service/AuthService.php', - 'app\\admin\\service\\MenuService' => __DIR__ . '/../..' . '/app/admin/service/MenuService.php', 'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/app/index/controller/Index.php', 'think\\App' => __DIR__ . '/..' . '/topthink/framework/src/think/App.php', 'think\\Cache' => __DIR__ . '/..' . '/topthink/framework/src/think/Cache.php', @@ -232,33 +230,36 @@ class ComposerStaticInit31a52c657911214987b8ff9fa2a257af 'think\\Validate' => __DIR__ . '/..' . '/topthink/framework/src/think/Validate.php', 'think\\View' => __DIR__ . '/..' . '/topthink/framework/src/think/View.php', 'think\\admin\\Controller' => __DIR__ . '/..' . '/zoujingli/think-library/src/Controller.php', + 'think\\admin\\Helper' => __DIR__ . '/..' . '/zoujingli/think-library/src/Helper.php', 'think\\admin\\Queue' => __DIR__ . '/..' . '/zoujingli/think-library/src/Queue.php', + 'think\\admin\\Service' => __DIR__ . '/..' . '/zoujingli/think-library/src/Service.php', 'think\\admin\\Storage' => __DIR__ . '/..' . '/zoujingli/think-library/src/Storage.php', 'think\\admin\\ThinkLibrary' => __DIR__ . '/..' . '/zoujingli/think-library/src/ThinkLibrary.php', - 'think\\admin\\extend\\CaptchaExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/CaptchaExtend.php', 'think\\admin\\extend\\CodeExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/CodeExtend.php', 'think\\admin\\extend\\CsvExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/CsvExtend.php', 'think\\admin\\extend\\DataExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/DataExtend.php', 'think\\admin\\extend\\ExpressExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ExpressExtend.php', 'think\\admin\\extend\\HttpExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/HttpExtend.php', - 'think\\admin\\extend\\NodeExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/NodeExtend.php', 'think\\admin\\extend\\ProcessExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ProcessExtend.php', - 'think\\admin\\extend\\TokenExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/TokenExtend.php', 'think\\admin\\helper\\DeleteHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/DeleteHelper.php', 'think\\admin\\helper\\FormHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/FormHelper.php', - 'think\\admin\\helper\\Helper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/Helper.php', 'think\\admin\\helper\\PageHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/PageHelper.php', 'think\\admin\\helper\\QueryHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/QueryHelper.php', 'think\\admin\\helper\\SaveHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/SaveHelper.php', 'think\\admin\\helper\\TokenHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/TokenHelper.php', 'think\\admin\\install\\CommandInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/CommandInstall.php', - 'think\\admin\\install\\ExtendInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/ExtendInstall.php', 'think\\admin\\queue\\ListenQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/ListenQueue.php', 'think\\admin\\queue\\QueryQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/QueryQueue.php', 'think\\admin\\queue\\StartQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StartQueue.php', 'think\\admin\\queue\\StateQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StateQueue.php', 'think\\admin\\queue\\StopQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StopQueue.php', 'think\\admin\\queue\\WorkQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/WorkQueue.php', + 'think\\admin\\service\\AuthService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/AuthService.php', + 'think\\admin\\service\\CaptchaService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/CaptchaService.php', + 'think\\admin\\service\\InstallService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/InstallService.php', + 'think\\admin\\service\\MenuService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/MenuService.php', + 'think\\admin\\service\\NodeService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/NodeService.php', + 'think\\admin\\service\\TokenService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/TokenService.php', 'think\\admin\\storage\\LocalStorage' => __DIR__ . '/..' . '/zoujingli/think-library/src/storage/LocalStorage.php', 'think\\admin\\storage\\QiniuStorage' => __DIR__ . '/..' . '/zoujingli/think-library/src/storage/QiniuStorage.php', 'think\\app\\MultiApp' => __DIR__ . '/..' . '/topthink/think-multi-app/src/MultiApp.php', @@ -469,9 +470,9 @@ class ComposerStaticInit31a52c657911214987b8ff9fa2a257af public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit31a52c657911214987b8ff9fa2a257af::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit31a52c657911214987b8ff9fa2a257af::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit31a52c657911214987b8ff9fa2a257af::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitb8e4029a37bf108c1da00ff988d7544f::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 169f57177..ac1301f78 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -805,12 +805,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "8fe807f96681e800b32c5fe775e2b92def2396d3" + "reference": "e561d021e18776a9851646236e6af556c77eec6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8fe807f96681e800b32c5fe775e2b92def2396d3", - "reference": "8fe807f96681e800b32c5fe775e2b92def2396d3", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e561d021e18776a9851646236e6af556c77eec6a", + "reference": "e561d021e18776a9851646236e6af556c77eec6a", "shasum": "", "mirrors": [ { @@ -826,7 +826,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2019-11-04T11:04:29+00:00", + "time": "2019-11-09T08:03:23+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index efae33319..0f4a2b881 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/helper/Helper.php b/vendor/zoujingli/think-library/src/Helper.php similarity index 92% rename from vendor/zoujingli/think-library/src/helper/Helper.php rename to vendor/zoujingli/think-library/src/Helper.php index ec3c1e773..a1a11792e 100644 --- a/vendor/zoujingli/think-library/src/helper/Helper.php +++ b/vendor/zoujingli/think-library/src/Helper.php @@ -13,20 +13,18 @@ // | github 仓库地址 :https://github.com/zoujingli/ThinkLibrary // +---------------------------------------------------------------------- -namespace think\admin\helper; +namespace think\admin; -use think\admin\Controller; use think\App; use think\db\Query; /** - * 基础管理器 + * 控制器挂件 * Class Helper - * @package think\admin\helper + * @package think\admin */ -class Helper +abstract class Helper { - /** * 当前应用容器 * @var App @@ -70,11 +68,10 @@ class Helper * 实例对象反射 * @param Controller $controller * @param App $app - * @return $this + * @return static */ public static function instance(Controller $controller, App $app) { return new static($controller, $app); } - -} +} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/Service.php b/vendor/zoujingli/think-library/src/Service.php new file mode 100644 index 000000000..b756515d5 --- /dev/null +++ b/vendor/zoujingli/think-library/src/Service.php @@ -0,0 +1,70 @@ +app = $app; + $this->init(); + } + + /** + * 服务初始化 + */ + protected function init() + { + } + + /** + * 静态实例对象 + * @param App $app + * @return $this + */ + public static function instance(App $app = null) + { + if (is_null($app)) $app = app(); + $key = md5(get_called_class()); + if (!isset(self::$cache[$key])) { + self::$cache[$key] = new static($app); + } + return self::$cache[$key]; + } +} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/ThinkLibrary.php b/vendor/zoujingli/think-library/src/ThinkLibrary.php index 98af01abd..6361ab819 100644 --- a/vendor/zoujingli/think-library/src/ThinkLibrary.php +++ b/vendor/zoujingli/think-library/src/ThinkLibrary.php @@ -15,6 +15,8 @@ namespace think\admin; +use think\admin\service\AuthService; +use think\middleware\SessionInit; use think\Request; use think\Service; @@ -31,7 +33,7 @@ class ThinkLibrary extends Service public function register() { // 注册会话中间键 - $this->app->middleware->add(\think\middleware\SessionInit::class); + $this->app->middleware->add(SessionInit::class); // 动态加入应用函数 foreach (glob($this->app->getAppPath() . '*/sys.php') as $file) { \Composer\Autoload\includeFile($file); @@ -43,7 +45,7 @@ class ThinkLibrary extends Service */ public function boot() { - // 注册访问跨域中间键 + // 注册访问中间键 $this->app->middleware->add(function (Request $request, \Closure $next) { $header = []; if (($origin = $request->header('origin', '*')) !== '*') { @@ -52,10 +54,15 @@ class ThinkLibrary extends Service $header['Access-Control-Allow-Headers'] = 'Authorization,Content-Type,If-Match,If-Modified-Since,If-None-Match,If-Unmodified-Since,X-Requested-With'; $header['Access-Control-Expose-Headers'] = 'User-Form-Token'; } + // 访问模式及访问权限检查 if ($request->isOptions()) { return response()->code(204)->header($header); - } else { + } elseif (AuthService::instance($this->app)->check()) { return $next($request)->header($header); + } elseif (AuthService::instance($this->app)->isLogin()) { + return json(['code' => 0, 'msg' => '抱歉,没有访问该操作的权限!'])->header($header); + } else { + return json(['code' => 0, 'msg' => '抱歉,需要登录获取访问权限!', 'url' => url('@admin/login')])->header($header); } }); // 注册系统任务指令 diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php index 720f98349..09239da27 100644 --- a/vendor/zoujingli/think-library/src/common.php +++ b/vendor/zoujingli/think-library/src/common.php @@ -15,7 +15,8 @@ use think\admin\extend\DataExtend; use think\admin\extend\HttpExtend; -use think\admin\extend\TokenExtend; +use think\admin\service\AuthService; +use think\admin\service\TokenService; use think\db\Query; if (!function_exists('p')) { @@ -27,12 +28,25 @@ if (!function_exists('p')) { */ function p($data, $replace = false, $file = null) { - if (is_null($file)) $file = env('runtime_path') . date('Ymd') . '.txt'; + if (is_null($file)) $file = app()->getRuntimePath() . date('Ymd') . '.txt'; $str = (is_string($data) ? $data : (is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true)) . PHP_EOL; $replace ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND); } } +if (!function_exists('auth')) { + /** + * 访问权限检查 + * @param string $node + * @return boolean + * @throws ReflectionException + */ + function auth($node) + { + return AuthService::instance()->check($node); + } +} + if (!function_exists('systoken')) { /** * 生成 CSRF-TOKEN 参数 @@ -41,7 +55,7 @@ if (!function_exists('systoken')) { */ function systoken($node = null) { - return TokenExtend::buildFormToken($node)['token']; + return TokenService::instance()->buildFormToken($node)['token']; } } diff --git a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php index fedd013da..722f3c7c7 100644 --- a/vendor/zoujingli/think-library/src/helper/DeleteHelper.php +++ b/vendor/zoujingli/think-library/src/helper/DeleteHelper.php @@ -15,6 +15,7 @@ namespace think\admin\helper; +use think\admin\Helper; use think\db\Query; /** diff --git a/vendor/zoujingli/think-library/src/helper/FormHelper.php b/vendor/zoujingli/think-library/src/helper/FormHelper.php index 9b392f9e8..b3bda10b3 100644 --- a/vendor/zoujingli/think-library/src/helper/FormHelper.php +++ b/vendor/zoujingli/think-library/src/helper/FormHelper.php @@ -16,6 +16,7 @@ namespace think\admin\helper; use think\admin\extend\DataExtend; +use think\admin\Helper; use think\db\Query; /** diff --git a/vendor/zoujingli/think-library/src/helper/PageHelper.php b/vendor/zoujingli/think-library/src/helper/PageHelper.php index f03dd74c2..b198fc48c 100644 --- a/vendor/zoujingli/think-library/src/helper/PageHelper.php +++ b/vendor/zoujingli/think-library/src/helper/PageHelper.php @@ -15,6 +15,7 @@ namespace think\admin\helper; +use think\admin\Helper; use think\db\Query; /** diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index 6c2093d8d..5f049783e 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -15,6 +15,7 @@ namespace think\admin\helper; +use think\admin\Helper; use think\db\Query; /** diff --git a/vendor/zoujingli/think-library/src/helper/SaveHelper.php b/vendor/zoujingli/think-library/src/helper/SaveHelper.php index 1f9c8fa46..475fb6223 100644 --- a/vendor/zoujingli/think-library/src/helper/SaveHelper.php +++ b/vendor/zoujingli/think-library/src/helper/SaveHelper.php @@ -15,6 +15,7 @@ namespace think\admin\helper; +use think\admin\Helper; use think\db\Query; /** diff --git a/vendor/zoujingli/think-library/src/helper/TokenHelper.php b/vendor/zoujingli/think-library/src/helper/TokenHelper.php index 548a62063..973d8e834 100644 --- a/vendor/zoujingli/think-library/src/helper/TokenHelper.php +++ b/vendor/zoujingli/think-library/src/helper/TokenHelper.php @@ -15,7 +15,8 @@ namespace think\admin\helper; -use think\admin\extend\TokenExtend; +use think\admin\Helper; +use think\admin\service\TokenService; use think\exception\HttpResponseException; /** @@ -40,7 +41,7 @@ class TokenHelper extends Helper { $this->class->csrf_state = true; $this->token = $this->app->request->header('user-form-token', input('_csrf_', '')); - if ($this->app->request->isPost() && !TokenExtend::checkFormToken($this->token)) { + if ($this->app->request->isPost() && !TokenService::instance($this->app)->checkFormToken($this->token)) { if ($return) return false; $this->class->error($this->class->csrf_message); } else { @@ -54,7 +55,7 @@ class TokenHelper extends Helper public function clear() { $this->token = $this->app->request->header('user-form-token', input('_csrf_', '')); - if (!empty($this->token)) TokenExtend::clearFormToken($this->token); + if (!empty($this->token)) TokenService::instance($this->app)->clearFormToken($this->token); } /** @@ -67,7 +68,7 @@ class TokenHelper extends Helper { throw new HttpResponseException(view($tpl, $vars, 200, function ($html) use ($node) { return preg_replace_callback('/<\/form>/i', function () use ($node) { - $csrf = TokenExtend::buildFormToken($node); + $csrf = TokenService::instance($this->app)->buildFormToken($node); return ""; }, $html); })); diff --git a/vendor/zoujingli/think-library/src/install/CommandInstall.php b/vendor/zoujingli/think-library/src/install/CommandInstall.php index b50851929..eef053ac1 100644 --- a/vendor/zoujingli/think-library/src/install/CommandInstall.php +++ b/vendor/zoujingli/think-library/src/install/CommandInstall.php @@ -15,6 +15,7 @@ namespace think\admin\install; +use think\admin\service\InstallService; use think\console\Command; use think\console\Input; use think\console\input\Argument; @@ -47,9 +48,9 @@ class CommandInstall extends Command /** * 插件工具实例 - * @var ExtendInstall + * @var InstallService */ - protected $extend; + protected $service; /** * 规则配置 @@ -83,7 +84,7 @@ class CommandInstall extends Command if (empty($this->name)) { $this->output->error('在线安装的模块名称不能为空!'); } else { - $this->extend = ExtendInstall::instance($this->app); + $this->service = InstallService::instance($this->app); if (isset($this->bind[$this->name])) { $this->rules = empty($this->bind[$this->name]['rules']) ? [] : $this->bind[$this->name]['rules']; $this->ignore = empty($this->bind[$this->name]['ignore']) ? [] : $this->bind[$this->name]['ignore']; @@ -97,10 +98,10 @@ class CommandInstall extends Command protected function installFile() { - $data = $this->extend->grenerateDifference($this->rules, $this->ignore); + $data = $this->service->grenerateDifference($this->rules, $this->ignore); if (empty($data)) $this->output->info('文件比对一致不需更新文件!'); else foreach ($data as $file) { - list($state, $mode, $name) = $this->extend->fileSynchronization($file); + list($state, $mode, $name) = $this->service->fileSynchronization($file); if ($state) { if ($mode === 'add') $this->output->info("--- 下载 {$name} 添加成功"); if ($mode === 'mod') $this->output->info("--- 下载 {$name} 更新成功"); diff --git a/app/admin/service/AuthService.php b/vendor/zoujingli/think-library/src/service/AuthService.php similarity index 68% rename from app/admin/service/AuthService.php rename to vendor/zoujingli/think-library/src/service/AuthService.php index 155126181..86b06bdc3 100644 --- a/app/admin/service/AuthService.php +++ b/vendor/zoujingli/think-library/src/service/AuthService.php @@ -13,26 +13,26 @@ // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- -namespace app\admin\service; +namespace think\admin\service; -use library\tools\Data; use think\admin\extend\DataExtend; -use think\admin\extend\NodeExtend; +use think\admin\Service; /** - * 系统授权服务 - * Class MenuService - * @package app\admin\service + * 系统权限管理服务 + * Class AuthService + * @package think\admin\service */ -class AuthService +class AuthService extends Service { + /** * 判断是否已经登录 * @return boolean */ - public static function isLogin() + public function isLogin() { - return app()->session->get('user.id') ? true : false; + return $this->app->session->get('user.id') ? true : false; } /** @@ -42,12 +42,13 @@ class AuthService * @return boolean * @throws \ReflectionException */ - public static function check($node = '') + public function check($node = '') { - if (app()->session->get('user.username') === 'admin') return true; - list($real, $nodes) = [NodeExtend::fullnode($node), NodeExtend::getMethods()]; + $service = NodeService::instance($this->app); + 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, app()->session->get('user.nodes', [])); + return in_array($real, $this->app->session->get('user.nodes', [])); } return !(!empty($nodes[$real]['islogin']) && !self::isLogin()); } @@ -58,9 +59,10 @@ class AuthService * @return array * @throws \ReflectionException */ - public static function getTree($checkeds = []) + public function getTree($checkeds = []) { - list($nodes, $pnodes, $methods) = [[], [], array_reverse(NodeExtend::getMethods())]; + list($nodes, $pnodes) = [[], []]; + $methods = array_reverse(NodeService::instance($this->app)->getMethods()); foreach ($methods as $node => $method) { $count = substr_count($node, '/'); $pnode = substr($node, 0, strripos($node, '/')); @@ -81,25 +83,24 @@ class AuthService /** * 初始化用户权限 - * @param boolean $force 是否重置系统权限 + * @param boolean $force 强刷权限 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function apply($force = false) + public function apply($force = false) { - $app = app(); - if ($force) $app->cache->delete('system_auth_node'); - if (($uid = $app->session->get('user.id'))) { - $user = $app->db->name('SystemUser')->where(['id' => $uid])->find(); + if ($force) $this->app->cache->delete('system_auth_node'); + if (($uid = $this->app->session->get('user.id'))) { + $user = $this->app->db->name('SystemUser')->where(['id' => $uid])->find(); if (($aids = $user['authorize'])) { $where = [['status', 'eq', '1'], ['id', 'in', explode(',', $aids)]]; - $subsql = $app->db->name('SystemAuth')->field('id')->where($where)->buildSql(); - $user['nodes'] = array_unique($app->db->name('SystemAuthNode')->whereRaw("auth in {$subsql}")->column('node')); - $app->session->set('user', $user); + $subsql = $this->app->db->name('SystemAuth')->field('id')->where($where)->buildSql(); + $user['nodes'] = array_unique($this->app->db->name('SystemAuthNode')->whereRaw("auth in {$subsql}")->column('node')); + $this->app->session->set('user', $user); } else { $user['nodes'] = []; - $app->session->set('user', $user); + $this->app->session->set('user', $user); } } } diff --git a/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php b/vendor/zoujingli/think-library/src/service/CaptchaService.php similarity index 88% rename from vendor/zoujingli/think-library/src/extend/CaptchaExtend.php rename to vendor/zoujingli/think-library/src/service/CaptchaService.php index d644d2f5e..082d994b8 100644 --- a/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php +++ b/vendor/zoujingli/think-library/src/service/CaptchaService.php @@ -13,14 +13,16 @@ // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- -namespace think\admin\extend; +namespace think\admin\service; + +use think\admin\Service; /** - * 图形验证码扩展 - * Class CaptchaExtend - * @package app\admin\service + * 图形验证码服务 + * Class CaptchaService + * @package think\admin\service */ -class CaptchaExtend +class CaptchaService extends Service { private $code; // 验证码 private $uniqid; // 唯一序号 @@ -34,11 +36,10 @@ class CaptchaExtend private $fontcolor; // 指定字体颜色 /** - * 构造方法初始化 - * CaptchaService constructor. + * 服务初始化 * @param array $config */ - public function __construct($config = []) + protected function init($config = []) { // 动态配置属性 foreach ($config as $k => $v) if (isset($this->$k)) $this->$k = $v; @@ -52,7 +53,58 @@ class CaptchaExtend // 设置字体文件路径 $this->font = __DIR__ . '/bin/font.ttf'; // 缓存验证码字符串 - app()->cache->set($this->uniqid, $this->code, 360); + $this->app->cache->set($this->uniqid, $this->code, 360); + } + + /** + * 获取验证码值 + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * 获取图片内容 + * @return string + */ + public function getData() + { + return "data:image/png;base64,{$this->createImage()}"; + } + + /** + * 获取验证码编号 + * @return string + */ + public function getUniqid() + { + return $this->uniqid; + } + + + /** + * 检查验证码是否正确 + * @param string $code 需要验证的值 + * @param string $uniqid 验证码编号 + * @return boolean + */ + public function check($code, $uniqid = null) + { + $_uni = is_string($uniqid) ? $uniqid : input('uniqid', '-'); + $_val = $this->app->cache->get($_uni); + $this->app->cache->delete($_uni); + return is_string($_val) && strtolower($_val) === strtolower($code); + } + + /** + * 输出图形验证码 + * @return string + */ + public function __toString() + { + return $this->getData(); } /** @@ -88,63 +140,4 @@ class CaptchaExtend imagedestroy($this->img); return base64_encode($data); } - - /** - * 获取验证码值 - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * 获取图片内容 - * @return string - */ - public function getData() - { - return "data:image/png;base64,{$this->createImage()}"; - } - - /** - * 获取验证码编号 - * @return string - */ - public function getUniqid() - { - return $this->uniqid; - } - - /** - * 输出图形验证码 - * @return string - */ - public function __toString() - { - return $this->getData(); - } - - /** - * 返回当前对象 - * @return static - */ - public static function instance() - { - return new static(); - } - - /** - * 检查验证码是否正确 - * @param string $code 需要验证的值 - * @param string $uniqid 验证码编号 - * @return boolean - */ - public static function check($code, $uniqid = null) - { - $_uni = is_string($uniqid) ? $uniqid : input('uniqid', '-'); - $_val = app()->cache->get($_uni); - app()->cache->delete($_uni); - return is_string($_val) && strtolower($_val) === strtolower($code); - } -} +} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/install/ExtendInstall.php b/vendor/zoujingli/think-library/src/service/InstallService.php similarity index 91% rename from vendor/zoujingli/think-library/src/install/ExtendInstall.php rename to vendor/zoujingli/think-library/src/service/InstallService.php index 3458467d0..3814694d5 100644 --- a/vendor/zoujingli/think-library/src/install/ExtendInstall.php +++ b/vendor/zoujingli/think-library/src/service/InstallService.php @@ -13,24 +13,18 @@ // | github 仓库地址 :https://github.com/zoujingli/ThinkLibrary // +---------------------------------------------------------------------- -namespace think\admin\install; +namespace think\admin\service; use think\admin\extend\HttpExtend; -use think\App; +use think\admin\Service; /** - * 模块安装服务扩展 - * Class ExtendInstall - * @package think\admin\install + * 模块安装服务管理 + * Class InstallService + * @package think\admin\service */ -class ExtendInstall +class InstallService extends Service { - /** - * 当前应用 - * @var App - */ - private $app; - /** * 目录地址 * @var string @@ -62,31 +56,10 @@ class ExtendInstall protected $ignore = []; /** - * 当前实例 - * @var $this + * 服务初始化 */ - private static $class; - - /** - * 静态反射对象 - * @param App $app - * @return $this - */ - public static function instance(App $app) + protected function init() { - if (empty(self::$class)) { - self::$class = new static($app); - } - return self::$class; - } - - /** - * PlugsExtend constructor. - * @param App $app - */ - public function __construct(App $app) - { - $this->app = $app; // 应用框架版本 $this->version = $this->app->config->get('app.thinkadmin_ver'); if (empty($this->version)) $this->version = 'v4'; diff --git a/app/admin/service/MenuService.php b/vendor/zoujingli/think-library/src/service/MenuService.php similarity index 77% rename from app/admin/service/MenuService.php rename to vendor/zoujingli/think-library/src/service/MenuService.php index b0216d78c..f67b431cc 100644 --- a/app/admin/service/MenuService.php +++ b/vendor/zoujingli/think-library/src/service/MenuService.php @@ -13,29 +13,45 @@ // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- -namespace app\admin\service; +namespace think\admin\service; use think\admin\extend\DataExtend; -use think\admin\extend\NodeExtend; +use think\admin\Service; /** - * 系统菜单服务 + * 系统菜单管理服务 * Class MenuService * @package app\admin\service */ -class MenuService +class MenuService extends Service { + /** + * 应用节点服务 + * @var NodeService + */ + protected $nodeService; + + /** + * 服务初始化 + * @return $this + */ + protected function init() + { + $this->nodeService = NodeService::instance($this->app); + return $this; + } + /** * 获取可选菜单节点 * @return array * @throws \ReflectionException */ - public static function getList() + public function getList() { static $nodes = []; if (count($nodes) > 0) return $nodes; - foreach (NodeExtend::getMethods() as $node => $method) if ($method['ismenu']) { + foreach ($this->nodeService->getMethods() as $node => $method) if ($method['ismenu']) { $nodes[] = ['node' => $node, 'title' => $method['title']]; } return $nodes; @@ -49,10 +65,10 @@ class MenuService * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function getTree() + public function getTree() { $result = app()->db->name('SystemMenu')->where(['status' => '1'])->order('sort desc,id asc')->select(); - return self::buildData(DataExtend::arr2tree($result->toArray()), NodeExtend::getMethods()); + return self::buildData(DataExtend::arr2tree($result->toArray()), $this->nodeService->getMethods()); } /** @@ -62,7 +78,7 @@ class MenuService * @return array * @throws \ReflectionException */ - private static function buildData($menus, $nodes) + private function buildData($menus, $nodes) { foreach ($menus as $key => &$menu) { if (!empty($menu['sub'])) { @@ -74,7 +90,7 @@ class MenuService else { $node = join('/', array_slice(explode('/', preg_replace('/[\W]/', '/', $menu['url'])), 0, 3)); $menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}"); - if (!AuthService::check($node)) unset($menus[$key]); + if (!AuthService::instance($this->app)->check($node)) unset($menus[$key]); } } return $menus; diff --git a/vendor/zoujingli/think-library/src/extend/NodeExtend.php b/vendor/zoujingli/think-library/src/service/NodeService.php similarity index 79% rename from vendor/zoujingli/think-library/src/extend/NodeExtend.php rename to vendor/zoujingli/think-library/src/service/NodeService.php index fc52a083c..d4da68302 100644 --- a/vendor/zoujingli/think-library/src/extend/NodeExtend.php +++ b/vendor/zoujingli/think-library/src/service/NodeService.php @@ -1,7 +1,7 @@ getNamespace(); - $middle = '\\' . self::nameTolower(app()->request->controller()); - $suffix = ($type === 'controller') ? '' : ('\\' . app()->request->action()); + $prefix = $this->app->getNamespace(); + $middle = '\\' . self::nameTolower($this->app->request->controller()); + $suffix = ($type === 'controller') ? '' : ('\\' . $this->app->request->action()); return strtr(substr($prefix, stripos($prefix, '\\') + 1) . $middle . $suffix, '\\', '/'); } @@ -55,7 +56,7 @@ class NodeExtend * @param string $node * @return string */ - public static function fullnode($node) + public function fullnode($node) { if (empty($node)) return self::getCurrent(); if (count($attrs = explode('/', $node)) === 1) { @@ -72,18 +73,18 @@ class NodeExtend * @return array * @throws \ReflectionException */ - public static function getMethods($force = false) + public function getMethods($force = false) { static $data = []; if (empty($force)) { if (count($data) > 0) return $data; - $data = app()->cache->get('system_auth_node', []); + $data = $this->app->cache->get('system_auth_node', []); if (count($data) > 0) return $data; } else { $data = []; } $ignore = get_class_methods('\think\admin\Controller'); - foreach (self::scanDirectory(dirname(app()->getAppPath())) as $file) { + foreach (self::scanDirectory(dirname($this->app->getAppPath())) as $file) { if (preg_match("|/(\w+)/(\w+)/controller/(.+)\.php$|i", $file, $matches)) { list(, $namespace, $application, $baseclass) = $matches; $class = new \ReflectionClass(strtr("{$namespace}/{$application}/controller/{$baseclass}", '/', '\\')); @@ -95,7 +96,7 @@ class NodeExtend } } } - app()->cache->set('system_auth_node', $data); + $this->app->cache->set('system_auth_node', $data); return $data; } @@ -105,7 +106,7 @@ class NodeExtend * @param string $default * @return array */ - private static function parseComment($comment, $default = '') + private function parseComment($comment, $default = '') { $text = strtr($comment, "\n", ' '); $title = preg_replace('/^\/\*\s*\*\s*\*\s*(.*?)\s*\*.*?$/', '$1', $text); @@ -124,7 +125,7 @@ class NodeExtend * @param string $ext 有文件后缀 * @return array */ - private static function scanDirectory($path, $data = [], $ext = 'php') + private function scanDirectory($path, $data = [], $ext = 'php') { foreach (glob("{$path}*") as $item) { if (is_dir($item)) { diff --git a/vendor/zoujingli/think-library/src/extend/TokenExtend.php b/vendor/zoujingli/think-library/src/service/TokenService.php similarity index 62% rename from vendor/zoujingli/think-library/src/extend/TokenExtend.php rename to vendor/zoujingli/think-library/src/service/TokenService.php index 9870832e8..60c01f073 100644 --- a/vendor/zoujingli/think-library/src/extend/TokenExtend.php +++ b/vendor/zoujingli/think-library/src/service/TokenService.php @@ -1,7 +1,7 @@ session->get($token, [])]; + $service = NodeService::instance($this->app); + list($node, $cache) = [$service->getCurrent(), $this->app->session->get($token, [])]; if (empty($cache['node']) || empty($cache['time']) || empty($cache['token'])) return false; if ($cache['token'] !== $token || $cache['time'] + 600 < time() || $cache['node'] !== $node) return false; return true; @@ -41,9 +42,9 @@ class TokenExtend * 清理表单CSRF信息 * @param string $name */ - public static function clearFormToken($name = null) + public function clearFormToken($name = null) { - app()->session->delete($name); + $this->app->session->delete($name); } /** @@ -51,16 +52,16 @@ class TokenExtend * @param null|string $node * @return array */ - public static function buildFormToken($node = null) + public function buildFormToken($node = null) { list($token, $time) = [uniqid('csrf'), time()]; - foreach (app()->session->all() as $key => $item) { + foreach ($this->app->session->all() as $key => $item) { if (stripos($key, 'csrf') === 0 && isset($item['time'])) { if ($item['time'] + 600 < $time) self::clearFormToken($key); } } - $data = ['node' => NodeExtend::fullnode($node), 'token' => $token, 'time' => $time]; - app()->session->set($token, $data); + $data = ['node' => NodeService::instance($this->app)->fullnode($node), 'token' => $token, 'time' => $time]; + $this->app->session->set($token, $data); return $data; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/service/bin/font.ttf b/vendor/zoujingli/think-library/src/service/bin/font.ttf new file mode 100644 index 000000000..54a14ed1c Binary files /dev/null and b/vendor/zoujingli/think-library/src/service/bin/font.ttf differ