From 82985869c84bb8a643abdeecd7f69bd9d0e795fc Mon Sep 17 00:00:00 2001 From: taoser Date: Tue, 12 Oct 2021 16:50:02 +0800 Subject: [PATCH] 1.8.5 --- app/Request.php | 8 +++++--- app/admin/controller/Sign.php | 24 +++++++++++++----------- app/index/controller/User.php | 6 ++++++ config/view.php | 2 ++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/Request.php b/app/Request.php index 27afbfc..fe5eac5 100644 --- a/app/Request.php +++ b/app/Request.php @@ -5,7 +5,9 @@ namespace app; class Request extends \think\Request { //过滤空格 - protected $filter = ['trim','htmlspecialchars','strip_tags']; - //protected $filter = ['trim']; - + //protected $filter = ['trim','htmlspecialchars','strip_tags']; + //protected $filter = ['trim','htmlspecialchars']; + //protected $filter = ['trim','strip_tags']; + protected $filter = ['trim']; + } diff --git a/app/admin/controller/Sign.php b/app/admin/controller/Sign.php index d2d6906..cbae710 100644 --- a/app/admin/controller/Sign.php +++ b/app/admin/controller/Sign.php @@ -12,20 +12,22 @@ class Sign extends AdminController //添加签到积分规则 public function add() { - $data = Request::only(['days','score']); - $day = UserSignrule::where('days',$data['days'])->find(); - //$day = Db::name('user_signrule')->where('days',$data['days'])->find(); - if($day){ - $res = ['code'=>-1,'msg'=>'不能重复设置']; - } else { - $result = UserSignrule::create($data); - if($result){ - $res = ['code'=>0,'msg'=>'设置积分成功']; + if(Request::isPost()){ + $data = Request::only(['days','score']); + $day = UserSignrule::where('days',(int)$data['days'])->find(); + //$day = Db::name('user_signrule')->where('days',$data['days'])->find(); + if(!is_null($day)){ + $res = ['code'=>-1,'msg'=>'不能重复设置']; } else { - $res = ['code'=>-1,'msg'=>'保存失败']; + $result = UserSignrule::create($data); + if($result){ + $res = ['code'=>0,'msg'=>'设置积分成功']; + } else { + $res = ['code'=>-1,'msg'=>'保存失败']; + } } + return json($res); } - return json($res); } //删除签到积分规则 diff --git a/app/index/controller/User.php b/app/index/controller/User.php index aaa130e..6c17d6d 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -117,6 +117,12 @@ class User extends BaseController if(!$result){ $this->error($validate->getError()); } else { + //防止重复的email + $resEmail = Db::name('user')->where('email',$data['email'])->where('id','<>',$this->uid)->find(); + if(!is_null($resEmail)){ + return ['code'=>-1,'msg'=>'email已存在,请更换!']; + } + //若更换email,需重新激活 $mail = Db::name('user')->where('id',$this->uid)->value('email'); if($data['email'] !== $mail){ $data['active'] = 0; diff --git a/config/view.php b/config/view.php index 2caf977..9b50d80 100644 --- a/config/view.php +++ b/config/view.php @@ -29,6 +29,8 @@ return [ 'taglib_begin' => '{', // 标签库标签结束标记 'taglib_end' => '}', + + 'default_filter' => 'htmlspecialchars', //模板输出替换 'tpl_replace_string' => [ '__STATIC__'=>'/static/layui',