From 1cd51dce076028e9a97e13e98056ae838acb99be Mon Sep 17 00:00:00 2001 From: hdm Date: Tue, 23 Feb 2021 13:52:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E5=90=8E?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + app/admin/controller/Api.php | 24 ++++++++ app/admin/middleware/Auth.php | 37 ++++++++----- app/admin/middleware/Install.php | 4 +- app/admin/view/common/layui.html | 4 +- app/admin/view/index/index.html | 6 +- app/admin/view/index/main.html | 6 +- app/admin/view/login/index.html | 10 ++-- app/common.php | 91 +++++++++++++++++++++++++++++++ app/home/middleware/Install.php | 5 +- app/home/view/common/footer.html | 2 +- app/home/view/index/index.html | 2 +- app/home/view/login/index.html | 4 +- app/home/view/login/reg.html | 4 +- app/home/view/user/index.html | 2 +- app/home/view/user/info_edit.html | 2 +- app/install/controller/Index.php | 8 +-- config/install.lock | 1 - public/index.php | 10 ---- 19 files changed, 167 insertions(+), 56 deletions(-) delete mode 100644 config/install.lock diff --git a/.gitignore b/.gitignore index 6163fd2..7bbd717 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /runtime /public/.user.ini /public/backup +/config/install.lock diff --git a/app/admin/controller/Api.php b/app/admin/controller/Api.php index 9dbe048..273c558 100644 --- a/app/admin/controller/Api.php +++ b/app/admin/controller/Api.php @@ -200,6 +200,30 @@ class Api extends BaseController } } + // 测试邮件发送 + public function email_test(){ + $sender = Request::param('email'); + //检查是否邮箱格式 + if (!is_email($sender)) { + return json(['error' => 1, 'msg' => '测试邮箱码格式有误']); + } + $data = \app\common\model\Config::where('inc_type','smtp') + ->select(); + $config = convert_arr_kv($data,'name','value'); + $content = $config['test_eamil_info']; + //所有项目必须填写 + if (empty($config['smtp_server']) || empty($config['smtp_port']) || empty($config['smtp_user']) || empty($config['smtp_pwd'])) { + return json(['error' => 1, 'msg' => '请完善邮件配置信息!']); + } + + $send = send_email($sender, '测试邮件',$content); + if ($send) { + return ['error' => 0, 'msg' => '邮件发送成功!']; + } else { + return ['error' => 1, 'msg' => '邮件发送失败!']; + } + } + //首页获取 public function get_admin_list() { diff --git a/app/admin/middleware/Auth.php b/app/admin/middleware/Auth.php index 167713d..edc478d 100644 --- a/app/admin/middleware/Auth.php +++ b/app/admin/middleware/Auth.php @@ -48,18 +48,18 @@ class Auth */ protected function checkAuth($controller, $pathInfo, $action, $uid) { - Cache::delete('RulesSrc' . $uid); - if ($uid == 8) { + //Cache::delete('RulesSrc' . $uid); + if ($uid == 1) { // id=1的管理员默认拥有所有权限 return true; } else { - if (!Cache::get('RulesSrc' . $uid)) { + if (!Cache::get('RulesSrc' . $uid) || !Cache::get('RulesSrc0')) { //用户所在权限组及所拥有的权限 // 执行查询 $user_groups = Db::name('admin_group_access') ->alias('a') - ->join("admin_group w", "a.group_id=w.id", 'LEFT') - ->where("a.uid='{$uid}' and w.status='1'") + ->join("admin_group g", "a.group_id=g.id", 'LEFT') + ->where("a.uid='{$uid}' and g.status='1'") ->select() ->toArray(); $groups = $user_groups ?: []; @@ -69,23 +69,34 @@ class Auth $ids = array_merge($ids, explode(',', trim($g['rules'], ','))); } $ids = array_unique($ids); + //读取所有权限规则 + $rules_all = Db::name('admin_rule')->field('src')->select(); //读取用户组所有权限规则 $rules = Db::name('admin_rule')->where('id', 'in', $ids)->field('src')->select(); //循环规则,判断结果。 - $authList = []; // + $auth_list_all = []; + $auth_list = []; + foreach ($rules_all as $rule_all) { + $auth_list_all[] = strtolower($rule_all['src']); + } foreach ($rules as $rule) { - //只要存在就记录 - $authList[] = strtolower($rule['src']); + $auth_list[] = strtolower($rule['src']); } //规则列表结果保存到Cache - Cache::tag('adminRules')->set('RulesSrc' . $uid, $authList, 36000); + Cache::tag('adminRules')->set('RulesSrc0', $auth_list_all, 36000); + Cache::tag('adminRules')->set('RulesSrc' . $uid, $auth_list, 36000); } else { - $authList = Cache::get('RulesSrc' . $uid); + $auth_list_all = Cache::get('RulesSrc0'); + $auth_list = Cache::get('RulesSrc' . $uid); } - if (!in_array((string) $controller . '/' . $pathInfo, $authList)) { - return false; + if (!in_array((string) $controller . '/' . $pathInfo, $auth_list_all)) { + return true; + } + else{ + if (!in_array((string) $controller . '/' . $pathInfo, $auth_list)) { + return false; + } } - return true; } } } diff --git a/app/admin/middleware/Install.php b/app/admin/middleware/Install.php index 238ac23..9d3999a 100644 --- a/app/admin/middleware/Install.php +++ b/app/admin/middleware/Install.php @@ -7,11 +7,9 @@ class Install { public function handle($request, \Closure $next) { - if(!file_exists(root_path() . './config/install.lock')) - { + if (!is_installed()) { return $request->isAjax()?vae_assign(202,'请先完成系统安装引导'):redirect((string)url('/install/index')); } - return $next($request); } } diff --git a/app/admin/view/common/layui.html b/app/admin/view/common/layui.html index 50fd3b8..3998a8c 100644 --- a/app/admin/view/common/layui.html +++ b/app/admin/view/common/layui.html @@ -1,4 +1,4 @@ - + + diff --git a/app/home/view/login/reg.html b/app/home/view/login/reg.html index 9e502aa..fb6e173 100644 --- a/app/home/view/login/reg.html +++ b/app/home/view/login/reg.html @@ -217,8 +217,8 @@
- {:get_config('webconfig.copyright')} {:get_config('webconfig.icp')},技术支持:629工作室 + {:get_system_config('web','copyright')} {:get_system_config('web','icp')},Powered by GouguCMS
diff --git a/app/home/view/user/index.html b/app/home/view/user/index.html index 87315da..655619c 100644 --- a/app/home/view/user/index.html +++ b/app/home/view/user/index.html @@ -1,6 +1,6 @@ {extend name="common/base"/} {block name="style"} - + {/block} {block name="body"} diff --git a/app/home/view/user/info_edit.html b/app/home/view/user/info_edit.html index 53b7928..03b9ac5 100644 --- a/app/home/view/user/info_edit.html +++ b/app/home/view/user/info_edit.html @@ -1,6 +1,6 @@ {extend name="common/base"/} {block name="style"} - + {/block} {block name="body"} diff --git a/app/install/controller/Index.php b/app/install/controller/Index.php index 250cd43..099db5c 100644 --- a/app/install/controller/Index.php +++ b/app/install/controller/Index.php @@ -9,13 +9,11 @@ use think\facade\View; class Index { - public function _initialize() - { - parent::_initialize(); - + function __construct(){ // 检测是否安装过 if (is_installed()) { - return $this->error('你已经安装过勾股cms系统!'); + echo '你已经安装过勾股cms系统!'; + die(); } } diff --git a/config/install.lock b/config/install.lock deleted file mode 100644 index 4406ff1..0000000 --- a/config/install.lock +++ /dev/null @@ -1 +0,0 @@ -勾股CMS安装鉴定文件,勿删!!!!!此次安装时间:2021-01-29 17:53:06 \ No newline at end of file diff --git a/public/index.php b/public/index.php index 67cf294..5be8c93 100644 --- a/public/index.php +++ b/public/index.php @@ -1,14 +1,4 @@ -// +---------------------------------------------------------------------- - // [ 应用入口文件 ] namespace think;