修改测试后已知的bug

This commit is contained in:
hdm 2021-02-23 13:52:07 +08:00
parent 4c1449a23f
commit 1cd51dce07
19 changed files with 167 additions and 56 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
/runtime
/public/.user.ini
/public/backup
/config/install.lock

View File

@ -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()
{

View File

@ -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;
}
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,4 @@
<script src="{__LAYUI__}/layui.js?v={:get_config('webconfig.version')}"></script>
<script src="{__LAYUI__}/layui.js?v={:get_system_config('web','version')}"></script>
<script>
var base='{__ADMIN_JS__}/module/';
{if condition=" '[base]'!=='base' "}
@ -17,7 +17,7 @@
}
layui.config({
base: base,
version:'{:get_config('webconfig.version')}'
version:'{:get_system_config('web','version')}'
}).extend(extend).use(moduleArray, function(){
callback(layui);
});

View File

@ -1,7 +1,7 @@
{extend name="common/base"/}
{block name="style"}
<link rel="stylesheet" href="{__LAYUI__}/font/extend/iconfont.css?v={:get_config('webconfig.version')}">
<link rel="stylesheet" href="{__ADMIN_CSS__}/gougucms.css?v={:get_config('webconfig.version')}">
<link rel="stylesheet" href="{__LAYUI__}/font/extend/iconfont.css?v={:get_system_config('web','version')}">
<link rel="stylesheet" href="{__ADMIN_CSS__}/gougucms.css?v={:get_system_config('web','version')}">
{/block}
<!-- 主体 -->
{block name="body"}
@ -10,7 +10,7 @@
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo" ittab-home><img src="{__ADMIN_IMG__}/syslogo.png" width="186"
alt="{:get_config('webconfig.admin_title')}" /></div>
alt="{:get_system_config('web','admin_title')}" /></div>
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item" lay-unselect>
<a href="javascript:;" ittab-refresh class="refreshThis" id="ittab-refresh" title="刷新当前页"

View File

@ -133,16 +133,16 @@
</tr>
<tr>
<td><b>系统版本</b></td>
<td>{:get_config('webconfig.version')}</td>
<td>{:CMS_VERSION}</td>
</tr>
<tr>
<td><b>ThinkPHP版本</b></td>
<td>6.05<a class="layui-badge layui-bg-blue" style="margin-left:20px"
<td>{:TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
href="https://www.kancloud.cn/manual/thinkphp6_0" target="_blank">TP6文档</a></td>
</tr>
<tr>
<td><b>Layui版本</b></td>
<td>2.73<a class="layui-badge layui-bg-blue" style="margin-left:20px" href="https://www.layui.com/doc/"
<td>{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px" href="https://www.layui.com/doc/"
target="_blank">Layui文档</a></td>
</tr>
<tr>

View File

@ -5,8 +5,8 @@
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{:get_config('webconfig.admin_title')}</title>
<link rel="stylesheet" href="{__LAYUI__}/css/layui.css?v={:get_config('webconfig.version')}" media="all">
<title>{:get_system_config('web','admin_title')}</title>
<link rel="stylesheet" href="{__LAYUI__}/css/layui.css?v={:get_system_config('web','version')}" media="all">
<style type="text/css">
html,body {width: 100%;height: 100%;background: #34a853;}
input:-webkit-autofill {
@ -71,11 +71,11 @@
</div>
</div>
<div class="foot">
{:get_config('webconfig.copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank" rel="nofollow"
style="margin-left: 15px;color:#d3e8fa;">{:get_config('webconfig.icp')}</a>
{:get_system_config('web','copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
rel="nofollow" style="margin-left: 15px;color:#d3e8fa;">{:get_system_config('web','icp')}</a>Powered by GouguCMS
</div>
</div>
<script src="{__LAYUI__}/layui.js?v={:get_config('webconfig.version')}"></script>
<script src="{__LAYUI__}/layui.js?v={:get_system_config('web','version')}"></script>
<script type="text/javascript">
layui.use(['form'], function() {
var form = layui.form,

View File

@ -247,6 +247,7 @@ function get_file($id)
/**
* 判断是否是手机浏览器
* @return bool
*/
function isMobile()
{
@ -262,3 +263,93 @@ function isMobile()
return false;
}
}
/**
* 邮件发送
* @param $to 接收人
* @param string $subject 邮件标题
* @param string $content 邮件内容(html模板渲染后的内容)
* @throws Exception
* @throws phpmailerException
*/
function send_email($to, $subject = '', $content = '')
{
$mail = new PHPMailer\PHPMailer\PHPMailer();
$arr = \think\facade\Db::name('config')
->where('inc_type', 'smtp')
->select();
$config = convert_arr_kv($arr, 'name', 'value');
$mail->CharSet = 'UTF-8'; //设定邮件编码默认ISO-8859-1如果发中文此项必须设置否则乱码
$mail->isSMTP();
$mail->SMTPDebug = 0;
//调试输出格式
//$mail->Debugoutput = 'html';
//smtp服务器
$mail->Host = $config['smtp_server'];
//端口 - likely to be 25, 465 or 587
$mail->Port = $config['smtp_port'];
if ($mail->Port == '465') {
$mail->SMTPSecure = 'ssl';
}// 使用安全协议
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//发送邮箱
$mail->Username = $config['smtp_user'];
//密码
$mail->Password = $config['smtp_pwd'];
//Set who the message is to be sent from
$mail->setFrom($config['smtp_user'], $config['email_id']);
//回复地址
//$mail->addReplyTo('replyto@example.com', 'First Last');
//接收邮件方
if (is_array($to)) {
foreach ($to as $v) {
$mail->addAddress($v);
}
} else {
$mail->addAddress($to);
}
$mail->isHTML(true);// send as HTML
//标题
$mail->Subject = $subject;
//HTML内容转换
$mail->msgHTML($content);
return $mail->send();
}
/**
* 验证输入的邮件地址是否合法
* @param $user_email 邮箱
* @return bool
*/
function is_email($user_email)
{
$chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {
if (preg_match($chars, $user_email)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* 验证输入的手机号码是否合法
* @param $mobile_phone 手机号
* @return bool
*/
function is_mobile_phone($mobile_phone)
{
$chars = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$/";
if (preg_match($chars, $mobile_phone)) {
return true;
}
return false;
}

View File

@ -7,9 +7,8 @@ class Install
{
public function handle($request, \Closure $next)
{
if(!file_exists(root_path() . './config/install.lock'))
{
return $request->isAjax()?to_assign(202,'请先完成系统安装引导'):redirect((string)url('/install/index'));
if (!is_installed()) {
return $request->isAjax()?vae_assign(202,'请先完成系统安装引导'):redirect((string)url('/install/index'));
}
return $next($request);

View File

@ -45,7 +45,7 @@
<div class="footer-bottom">
<div class="footer-bottom-box clearfix">
<div class="l">
{:get_config('webconfig.copyright')}<a href="http://www.beian.miit.gov.cn" target="_blank" rel="nofollow" style="margin-left: 15px;color:#dad8d5">粤ICP备1xxxxxx11号-1</a>
{:get_system_config('web','copyright')} <a href="http://www.beian.miit.gov.cn" target="_blank" rel="nofollow" style="margin-left: 15px;color:#dad8d5">{:get_system_config('web','icp')}</a>
</div>
<div class="r">Powered by GouguCMS</div>
</div>

View File

@ -1,6 +1,6 @@
{extend name="common/base"/}
{block name="style"}
<link rel="stylesheet" href="{__CSS__}/index.css?v={:get_config('webconfig.version')}" media="all">
<link rel="stylesheet" href="{__CSS__}/index.css?v={:get_system_config('web','version')}" media="all">
{/block}
<!-- 主体 -->
{block name="body"}

View File

@ -216,8 +216,8 @@
</div>
</div>
<div class="foot">
{:get_config('webconfig.copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
rel="nofollow" style="margin-left: 15px;color:#d3e8fa;">{:get_config('webconfig.icp')}</a>技术支持629工作室
{:get_system_config('web','copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
rel="nofollow" style="margin-left: 15px;color:#d3e8fa;">{:get_system_config('web','icp')}</a>Powered by GouguCMS
</div>
</div>
<script language="javascript" src="{__STATIC__}/jquery.min.js"></script>

View File

@ -217,8 +217,8 @@
</div>
</div>
<div class="foot">
{:get_config('webconfig.copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
rel="nofollow" style="margin-left: 15px;color:#d3e8fa;">{:get_config('webconfig.icp')}</a>技术支持629工作室
{:get_system_config('web','copyright')} <a id="beian" href="//www.beian.miit.gov.cn" target="_blank"
rel="nofollow" style="margin-left: 15px;color:#d3e8fa;">{:get_system_config('web','icp')}</a>Powered by GouguCMS
</div>
</div>
<script language="javascript" src="{__STATIC__}/jquery.min.js"></script>

View File

@ -1,6 +1,6 @@
{extend name="common/base"/}
{block name="style"}
<link rel="stylesheet" href="{__CSS__}/user.css?v={:get_config('webconfig.version')}" media="all">
<link rel="stylesheet" href="{__CSS__}/user.css?v={:get_system_config('web','version')}" media="all">
{/block}
<!-- 主体 -->
{block name="body"}

View File

@ -1,6 +1,6 @@
{extend name="common/base"/}
{block name="style"}
<link rel="stylesheet" href="{__CSS__}/user.css?v={:get_config('webconfig.version')}" media="all">
<link rel="stylesheet" href="{__CSS__}/user.css?v={:get_system_config('web','version')}" media="all">
{/block}
<!-- 主体 -->
{block name="body"}

View File

@ -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();
}
}

View File

@ -1 +0,0 @@
勾股CMS安装鉴定文件勿删此次安装时间2021-01-29 17:53:06

View File

@ -1,14 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
namespace think;