From df40389b3613e60c88581e05657d7ef5eba3ca13 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 23 Nov 2019 16:43:22 +0800 Subject: [PATCH] =?UTF-8?q?ComposerUpdate=20&=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Login.php | 68 ++++----- app/admin/view/login/index.html | 6 +- composer.json | 6 + composer.lock | 130 +++++++++++++++--- public/static/login.js | 3 +- vendor/composer/installed.json | 128 ++++++++++++++--- vendor/services.php | 2 +- .../think-library/src/Controller.php | 33 ++++- .../zoujingli/think-library/src/Service.php | 6 +- .../think-library/src/queue/ListenQueue.php | 2 +- .../think-library/src/queue/QueryQueue.php | 2 +- .../think-library/src/queue/StateQueue.php | 2 +- .../think-library/src/queue/StopQueue.php | 2 +- .../src/service/CaptchaService.php | 13 ++ .../src/service/SystemService.php | 16 +++ .../think-library/src/storage/bin/mimes.php | 1 + 16 files changed, 335 insertions(+), 85 deletions(-) diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 84ede00d5..283439e6c 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -18,6 +18,7 @@ namespace app\admin\controller; use think\admin\Controller; use think\admin\service\AuthService; use think\admin\service\CaptchaService; +use think\admin\service\SystemService; /** * 用户登录管理 @@ -36,43 +37,46 @@ class Login extends Controller { if ($this->app->request->isGet()) { if (AuthService::instance()->isLogin()) { - $this->redirect(url('@admin')->suffix(false)->build()); + $this->redirect(url('@admin')->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 = CaptchaService::instance(); + $this->captcha = CaptchaService::instance()->getAttrs(); + $this->devmode = SystemService::instance()->checkRunMode('dev'); $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 (!CaptchaService::instance()->check(input('verify'), input('uniqid'))) { - $this->error('图形验证码验证失败,请重新输入!'); - } - // 用户信息验证 - $map = ['username' => $data['username'], 'is_deleted' => '0']; - $user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find(); - if (empty($user)) { - $this->error('登录账号或密码错误,请重新输入!'); - } - if (md5("{$user['password']}{$user['username']}") !== $data['password']) { - $this->error('登录账号或密码错误,请重新输入!'); - } - if (empty($user['status'])) { - $this->error('账号已经被禁用,请联系管理员!'); - } - $this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([ - 'login_ip' => $this->app->request->ip(), - 'login_at' => $this->app->db->raw('now()'), - 'login_num' => $this->app->db->raw('login_num+1'), - ]); - $this->app->session->set('user', $user); - sysoplog('用户登录', "用户登录系统后台成功"); - $this->success('登录成功', url('@admin')->build()); } + $data = $this->_vali([ + 'username.require' => '登录账号不能为空!', + 'username.min:4' => '登录账号长度不能少于4位有效字符!', + 'password.require' => '登录密码不能为空!', + 'password.min:4' => '登录密码长度不能少于4位有效字符!', + 'verify.require' => '图形验证码不能为空!', + 'uniqid.require' => '图形验证标识不能为空!' + ]); + if (!CaptchaService::instance()->check($data['verify'], $data['uniqid'])) { + $this->error('图形验证码验证失败,请重新输入!'); + } + // 用户信息验证 + $map = ['username' => $data['username'], 'is_deleted' => '0']; + $user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find(); + if (empty($user)) { + $this->error('登录账号或密码错误,请重新输入!'); + } + if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) { + $this->error('登录账号或密码错误,请重新输入!'); + } + if (empty($user['status'])) { + $this->error('账号已经被禁用,请联系管理员!'); + } + $this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([ + 'login_ip' => $this->app->request->ip(), + 'login_at' => $this->app->db->raw('now()'), + 'login_num' => $this->app->db->raw('login_num+1'), + ]); + $this->app->session->set('user', $user); + sysoplog('用户登录', "用户登录系统后台成功"); + $this->success('登录成功', url('@admin')->build()); + } /** diff --git a/app/admin/view/login/index.html b/app/admin/view/login/index.html index ad9b21181..1420e049e 100644 --- a/app/admin/view/login/index.html +++ b/app/admin/view/login/index.html @@ -28,10 +28,10 @@
  • - img - + img +
  • diff --git a/composer.json b/composer.json index 4f6e0704f..8d967f164 100644 --- a/composer.json +++ b/composer.json @@ -38,5 +38,11 @@ "@php think service:discover", "@php think vendor:publish" ] + }, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://mirrors.aliyun.com/composer" + } } } diff --git a/composer.lock b/composer.lock index 12a9395bd..59904928c 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": "25a15eb2c8beff5d87d174b5d6f25052", + "content-hash": "44a6bc247971794be9edd9df4f3dd0b9", "packages": [ { "name": "league/flysystem", @@ -18,7 +18,13 @@ "type": "zip", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-fileinfo": "*", @@ -102,7 +108,13 @@ "type": "zip", "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/08ef74e9be88100807a3b92cc9048a312bf01d6f", "reference": "08ef74e9be88100807a3b92cc9048a312bf01d6f", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "league/flysystem": "~1.0", @@ -149,7 +161,13 @@ "type": "zip", "url": "https://api.github.com/repos/opis/closure/zipball/e79f851749c3caa836d7ccc01ede5828feb762c7", "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": "^5.4 || ^7.0" @@ -210,7 +228,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -256,7 +280,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -305,7 +335,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -352,7 +388,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -400,7 +442,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/framework/zipball/79c555aab0313d1a33ddcdb3c395f2c47f37f597", "reference": "79c555aab0313d1a33ddcdb3c395f2c47f37f597", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-json": "*", @@ -462,7 +510,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-helper/zipball/4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", "reference": "4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0" @@ -501,7 +555,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/215f4a6bb88e53ad41b448c61957336eb55ce6f9", "reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -545,7 +605,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-orm/zipball/ff5f112f5559497222f2716385b5a709ab82741b", "reference": "ff5f112f5559497222f2716385b5a709ab82741b", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-json": "*", @@ -590,7 +656,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-template/zipball/e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", "reference": "e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -627,7 +699,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-view/zipball/90803b73f781db5d42619082c4597afc58b2d4c5", "reference": "90803b73f781db5d42619082c4597afc58b2d4c5", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -664,7 +742,13 @@ "type": "zip", "url": "https://api.github.com/repos/zoujingli/ip2region/zipball/f898a7d90cfacd54433de4028190c336164f2ae4", "reference": "f898a7d90cfacd54433de4028190c336164f2ae4", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3" @@ -699,13 +783,19 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "00fe6b75407a6dbde28add584886ad7e48abc604" + "reference": "f4227bd9d2d2d1634bd749cf47642f61a43c507e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/00fe6b75407a6dbde28add584886ad7e48abc604", - "reference": "00fe6b75407a6dbde28add584886ad7e48abc604", - "shasum": "" + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/f4227bd9d2d2d1634bd749cf47642f61a43c507e", + "reference": "f4227bd9d2d2d1634bd749cf47642f61a43c507e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-curl": "*", @@ -742,7 +832,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2019-11-22T02:07:09+00:00" + "time": "2019-11-23T08:36:34+00:00" } ], "packages-dev": [], diff --git a/public/static/login.js b/public/static/login.js index e16105d0c..2f1ee50b3 100644 --- a/public/static/login.js +++ b/public/static/login.js @@ -18,8 +18,7 @@ $(function () { that = this; require(["md5"], function (md5) { $("form").vali(function (data) { - data['password'] = md5.hash(md5.hash(data['password']) + data['username']); - if (data['skey']) delete data['skey']; + data['password'] = md5.hash(md5.hash(data['password']) + data['uniqid']); $.form.load(location.href, data, "post", function (ret) { if (parseInt(ret.code) !== 1) { $(that).find('.verify.layui-hide').removeClass('layui-hide'); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index db47234df..45b78fb6d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -12,7 +12,13 @@ "type": "zip", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-fileinfo": "*", @@ -98,7 +104,13 @@ "type": "zip", "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/08ef74e9be88100807a3b92cc9048a312bf01d6f", "reference": "08ef74e9be88100807a3b92cc9048a312bf01d6f", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "league/flysystem": "~1.0", @@ -147,7 +159,13 @@ "type": "zip", "url": "https://api.github.com/repos/opis/closure/zipball/e79f851749c3caa836d7ccc01ede5828feb762c7", "reference": "e79f851749c3caa836d7ccc01ede5828feb762c7", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": "^5.4 || ^7.0" @@ -210,7 +228,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -258,7 +282,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -309,7 +339,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -358,7 +394,13 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3.0" @@ -408,7 +450,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/framework/zipball/79c555aab0313d1a33ddcdb3c395f2c47f37f597", "reference": "79c555aab0313d1a33ddcdb3c395f2c47f37f597", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-json": "*", @@ -472,7 +520,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-helper/zipball/4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", "reference": "4d85dfd3778623bbb1de3648f1dcd0c82f4439f4", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0" @@ -513,7 +567,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/215f4a6bb88e53ad41b448c61957336eb55ce6f9", "reference": "215f4a6bb88e53ad41b448c61957336eb55ce6f9", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -559,7 +619,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-orm/zipball/ff5f112f5559497222f2716385b5a709ab82741b", "reference": "ff5f112f5559497222f2716385b5a709ab82741b", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-json": "*", @@ -606,7 +672,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-template/zipball/e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", "reference": "e98bdbb4a4c94b442f17dfceba81e0134d4fbd19", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -645,7 +717,13 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-view/zipball/90803b73f781db5d42619082c4597afc58b2d4c5", "reference": "90803b73f781db5d42619082c4597afc58b2d4c5", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=7.1.0", @@ -684,7 +762,13 @@ "type": "zip", "url": "https://api.github.com/repos/zoujingli/ip2region/zipball/f898a7d90cfacd54433de4028190c336164f2ae4", "reference": "f898a7d90cfacd54433de4028190c336164f2ae4", - "shasum": "" + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.3" @@ -721,13 +805,19 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "00fe6b75407a6dbde28add584886ad7e48abc604" + "reference": "f4227bd9d2d2d1634bd749cf47642f61a43c507e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/00fe6b75407a6dbde28add584886ad7e48abc604", - "reference": "00fe6b75407a6dbde28add584886ad7e48abc604", - "shasum": "" + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/f4227bd9d2d2d1634bd749cf47642f61a43c507e", + "reference": "f4227bd9d2d2d1634bd749cf47642f61a43c507e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "ext-curl": "*", @@ -736,7 +826,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2019-11-22T02:07:09+00:00", + "time": "2019-11-23T08:36:34+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index ba0dc8626..565e9587a 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/Controller.php b/vendor/zoujingli/think-library/src/Controller.php index 96fb97a1e..63cd8d32b 100644 --- a/vendor/zoujingli/think-library/src/Controller.php +++ b/vendor/zoujingli/think-library/src/Controller.php @@ -70,7 +70,7 @@ class Controller extends \stdClass $this->app = $app; $this->request = $app->request; $this->app->bind('think\admin\Controller', $this); - if (in_array($this->app->request->action(), get_class_methods(__CLASS__))) { + if (in_array($this->request->action(), get_class_methods(__CLASS__))) { $this->error('Access without permission.'); } $this->initialize(); @@ -218,6 +218,37 @@ class Controller extends \stdClass return FormHelper::instance()->init($dbQuery, $template, $field, $where, $data); } + /** + * 快捷输入并验证( 支持 规则 # 别名 ) + * @param array $rules 验证规则( 验证信息数组 ) + * @param string $type 输入方式 ( post. 或 get. ) + * @return array + */ + protected function _vali(array $rules, $type = '') + { + list($data, $rule, $info) = [[], [], []]; + foreach ($rules as $name => $message) { + if (stripos($name, '#') !== false) { + list($name, $alias) = explode('#', $name); + } + if (stripos($name, '.') === false) { + $data[$name] = empty($alias) ? $name : $alias; + } else { + list($_rgx) = explode(':', $name); + list($_key, $_rule) = explode('.', $name); + $info[$_rgx] = $message; + $data[$_key] = empty($alias) ? $_key : $alias; + $rule[$_key] = empty($rule[$_key]) ? $_rule : "{$rule[$_key]}|{$_rule}"; + } + } + foreach ($data as $key => $name) $data[$key] = input("{$type}{$name}"); + if ($this->app->validate->rule($rule)->message($info)->check($data)) { + return $data; + } else { + $this->error($this->app->validate->getError()); + } + } + /** * 快捷更新逻辑器 * @param string|Query $dbQuery diff --git a/vendor/zoujingli/think-library/src/Service.php b/vendor/zoujingli/think-library/src/Service.php index 6dd924dc2..d70c75e06 100644 --- a/vendor/zoujingli/think-library/src/Service.php +++ b/vendor/zoujingli/think-library/src/Service.php @@ -37,9 +37,7 @@ abstract class Service */ public function __construct(App $app) { - $this->app = $app; - $this->initialize(); } /** @@ -55,6 +53,8 @@ abstract class Service */ public static function instance() { - return Container::getInstance()->make(static::class); + $service = Container::getInstance()->make(static::class); + $service->initialize(); + return $service; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/queue/ListenQueue.php b/vendor/zoujingli/think-library/src/queue/ListenQueue.php index 52d00eba1..be7a80dcc 100644 --- a/vendor/zoujingli/think-library/src/queue/ListenQueue.php +++ b/vendor/zoujingli/think-library/src/queue/ListenQueue.php @@ -21,7 +21,7 @@ use think\console\Input; use think\console\Output; /** - * 启动监听异步任务守护的主进程 + * 启动监听任务的主进程 * Class ListenQueue * @package think\admin\queue */ diff --git a/vendor/zoujingli/think-library/src/queue/QueryQueue.php b/vendor/zoujingli/think-library/src/queue/QueryQueue.php index b4500c70b..bbfdbf13c 100644 --- a/vendor/zoujingli/think-library/src/queue/QueryQueue.php +++ b/vendor/zoujingli/think-library/src/queue/QueryQueue.php @@ -21,7 +21,7 @@ use think\console\Input; use think\console\Output; /** - * 查询正在执行中的进程PID信息 + * 查询正在执行的进程PID * Class QueryQueue * @package think\admin\queue */ diff --git a/vendor/zoujingli/think-library/src/queue/StateQueue.php b/vendor/zoujingli/think-library/src/queue/StateQueue.php index 6d375dde5..d1d687385 100644 --- a/vendor/zoujingli/think-library/src/queue/StateQueue.php +++ b/vendor/zoujingli/think-library/src/queue/StateQueue.php @@ -21,7 +21,7 @@ use think\console\Input; use think\console\Output; /** - * 查看异步任务监听的主进程状态 + * 查看任务监听的主进程状态 * Class StateQueue * @package think\admin\queue */ diff --git a/vendor/zoujingli/think-library/src/queue/StopQueue.php b/vendor/zoujingli/think-library/src/queue/StopQueue.php index 0e501d397..5225ca589 100644 --- a/vendor/zoujingli/think-library/src/queue/StopQueue.php +++ b/vendor/zoujingli/think-library/src/queue/StopQueue.php @@ -21,7 +21,7 @@ use think\console\Input; use think\console\Output; /** - * 平滑停止异步任务守护的主进程 + * 平滑停止任务的所有进程 * Class StopQueue * @package think\admin\queue */ diff --git a/vendor/zoujingli/think-library/src/service/CaptchaService.php b/vendor/zoujingli/think-library/src/service/CaptchaService.php index 6a8811295..5c45b8f30 100644 --- a/vendor/zoujingli/think-library/src/service/CaptchaService.php +++ b/vendor/zoujingli/think-library/src/service/CaptchaService.php @@ -83,6 +83,19 @@ class CaptchaService extends Service return $this->uniqid; } + /** + * 获取验证码数据 + * @return array + */ + public function getAttrs() + { + return [ + 'code' => $this->getCode(), + 'data' => $this->getData(), + 'uniqid' => $this->getUniqid(), + ]; + } + /** * 检查验证码是否正确 * @param string $code 需要验证的值 diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 91eeb238c..1dd3851df 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -176,4 +176,20 @@ class SystemService extends Service $new ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND); } + /** + * 判断运行环境 + * @param string $type 运行模式(dev|demo|local) + * @return boolean + */ + public function checkRunMode($type = 'dev') + { + $domain = $this->app->request->host(true); + $isDemo = is_numeric(stripos($domain, 'thinkadmin.top')); + $isLocal = in_array($domain, ['127.0.0.1', 'localhost']); + if ($type === 'dev') return $isLocal || $isDemo; + if ($type === 'demo') return $isDemo; + if ($type === 'local') return $isLocal; + return true; + } + } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/storage/bin/mimes.php b/vendor/zoujingli/think-library/src/storage/bin/mimes.php index 0ed89ecd7..831911f81 100644 --- a/vendor/zoujingli/think-library/src/storage/bin/mimes.php +++ b/vendor/zoujingli/think-library/src/storage/bin/mimes.php @@ -997,4 +997,5 @@ return [ 'movie' => 'video/x-sgi-movie', 'smv' => 'video/x-smv', 'ice' => 'x-conference/x-cooltalk', + 'pem' => 'application/x-pem-file', ]; \ No newline at end of file