From 10a3660d33d38d1f8a9701268e00fbfecd0c47a3 Mon Sep 17 00:00:00 2001 From: taoser Date: Sat, 7 Aug 2021 15:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B4=A6=E6=88=B7=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=EF=BC=8C=E4=BC=98=E5=8C=96=E5=88=86=E7=B1=BB=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- app/admin/controller/Login.php | 6 +-- app/admin/controller/Set.php | 2 +- app/admin/controller/Upgrade.php | 26 ++++++------ app/admin/view/set/system/website.html | 34 +++++++-------- app/common/controller/BaseController.php | 2 +- app/common/model/User.php | 2 +- app/index/controller/Active.php | 51 +++++++++++++++++++++++ app/index/controller/Article.php | 3 +- app/index/controller/User.php | 37 ++++++++++++---- app/install/data/taoler.sql | 6 +-- config/taoler.php | 2 +- public/static/res/mods/index.js | 2 +- view/taoler/index/active/index.html | 36 ++++++++++++++++ view/taoler/index/article/ask/cate.html | 13 +++--- view/taoler/index/article/cate.html | 12 +++--- view/taoler/index/article/posts/cate.html | 12 +++--- view/taoler/index/user/activate.html | 22 +++++++--- 18 files changed, 195 insertions(+), 77 deletions(-) create mode 100644 app/index/controller/Active.php create mode 100644 view/taoler/index/active/index.html diff --git a/README.md b/README.md index 2ed05c5..59bd79d 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ * 后台:http://adm.aieok.com:888 * 账号:test * 密码:test123 - * 版本:TaoLer 1.8.1 - * 日期:2021.8.4 + * 版本:TaoLer 1.8.2 + * 日期:2021.8.5 #### 项目地址 diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index f657c3e..e4ca85e 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -26,13 +26,13 @@ class Login extends AdminController } $user = new \app\admin\model\Admin(); - $res = $user->login($data); + $result = $user->login($data); - if ($res == 1) { + if ($result == 1) { $res = ['code'=>0,'msg'=>'登陆成功', 'url'=>(string) url('index/index')]; //$res['data']['access_token'] = $data['__token__']; } else { - $res = ['code'=>-1,'msg'=>$res,'url'=>'admin/login']; + $res = ['code'=>-1,'msg'=>$result,'url'=>(string) url('admin/login')]; } return json($res); } diff --git a/app/admin/controller/Set.php b/app/admin/controller/Set.php index 334508b..dcaae09 100644 --- a/app/admin/controller/Set.php +++ b/app/admin/controller/Set.php @@ -141,7 +141,7 @@ class Set extends AdminController $upRes = $uploads->put('file','logo',2000,'image','uniqid'); $logoJson = $upRes->getData(); if($logoJson['status'] == 0){ - $result = Db::name('system')->where('id', 1)->update(['logo'=>$logoJson['url']]); + $result = Db::name('system')->where('id', 1)->cache('system')->update(['logo'=>$logoJson['url']]); if($result){ $res = ['code'=>0,'msg'=>'上传logo成功']; } else { diff --git a/app/admin/controller/Upgrade.php b/app/admin/controller/Upgrade.php index 6b8cd4b..1dd6e4e 100644 --- a/app/admin/controller/Upgrade.php +++ b/app/admin/controller/Upgrade.php @@ -226,19 +226,6 @@ class Upgrade extends AdminController //$package_name = str_replace('.zip','',$package_file); Log::channel('update')->info('update:{type} {progress} {msg}',['type'=>'success','progress'=>'50%','msg'=>'升级文件解压成功!']); - - //升级sql操作 - $upSql = $zipPath.'runtime/mysql_update.sql'; - if(file_exists($upSql)) - { - $sqlRes = $this->db_update($upSql); - $upDate = $sqlRes->getData(); - if($upDate['code'] == -1){ - return json(['code'=>-1,'msg'=>$upDate['msg']]); - } - //删除sql语句 - unlink($upSql); - } //升级PHP if(is_dir($zipPath)) @@ -284,6 +271,19 @@ class Upgrade extends AdminController Files::delDirAndFile($this->upload_dir); Files::delDirAndFile($this->backup_dir); } + + //升级sql操作 + $upSql = $zipPath.'runtime/mysql_update.sql'; + if(file_exists($upSql)) + { + $sqlRes = $this->db_update($upSql); + $upDate = $sqlRes->getData(); + if($upDate['code'] == -1){ + return json(['code'=>-1,'msg'=>$upDate['msg']]); + } + //删除sql语句 + unlink($upSql); + } Log::channel('update')->info('update:{type} {progress} {msg}',['type'=>'success','progress'=>'100%','msg'=>'升级成功!']); //更新系统的版本号了 diff --git a/app/admin/view/set/system/website.html b/app/admin/view/set/system/website.html index a1736e9..61758e9 100644 --- a/app/admin/view/set/system/website.html +++ b/app/admin/view/set/system/website.html @@ -7,11 +7,11 @@
-
+
  • 网站设置
  • 邮箱服务
  • -
  • 服务配置
  • +
  • 服务配置
@@ -265,6 +265,7 @@ var $ = layui.$ ,form = layui.form ,upload = layui.upload; + var element =layui.element ; //LOGO选完文件后不自动上传 upload.render({ @@ -278,19 +279,12 @@ ,bindAction: '#logo-upload-button' ,done: function(res){ if(res.code == 0){ - layer.msg(res.msg,{ - icon:6, - tiye:2000 + layer.msg(res.msg,{icon:6,tiye:2000 },function(){ location.reload(); }); } else { - layer.open({ - title:"上传失败", - content:res.msg, - icon:5, - anim:6 - }); + layer.open({title:"上传失败",content:res.msg,icon:5,anim:6}); } } }); @@ -300,8 +294,6 @@ $.post("{:url('admin/set/config')}",field,function(res){ if(res.code == 0){ layer.msg(res.msg,{icon:6,tiye:2000 - },function(){ - location.reload(); }); } else { layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); @@ -315,8 +307,6 @@ $.post("{:url('admin/set/sendMailCode')}",field,function(res){ if(res.code == 0){ layer.msg(res.msg,{icon:6,tiye:2000 - },function(){ - location.reload(); }); } else { layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); @@ -331,8 +321,6 @@ $.post("{:url('admin/set/activeMailServer')}",field,function(res){ if(res.code == 0){ layer.msg(res.msg,{icon:6,tiye:2000 - },function(){ - location.reload(); }); } else { layer.open({title:"设置失败",content:res.msg,icon:5,anim:6}); @@ -340,6 +328,18 @@ }); return false; }); + + //显示当前tab + if(location.hash){ + element.tabChange('website-tabs-brief', location.hash.replace(/^#/, '')); + } + + element.on('tab(website-tabs-brief)', function(){ + var othis = $(this), layid = othis.attr('lay-id'); + if(layid){ + location.hash = layid; + } + }); }); diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php index 8adb164..37ecc58 100644 --- a/app/common/controller/BaseController.php +++ b/app/common/controller/BaseController.php @@ -69,7 +69,7 @@ class BaseController extends BaseCtrl $user = Cache::get('user'.$id); if(!$user){ //1.查询用户 - $user = Db::name('user')->field('id,name,nickname,user_img,sex,area_id,auth,city,email,sign,point,vip,create_time')->find($id); + $user = Db::name('user')->field('id,name,nickname,user_img,sex,area_id,auth,city,email,active,sign,point,vip,create_time')->find($id); Cache::tag('user')->set('user'.$id,$user,600); } diff --git a/app/common/model/User.php b/app/common/model/User.php index be5eed6..737a03d 100644 --- a/app/common/model/User.php +++ b/app/common/model/User.php @@ -140,7 +140,7 @@ class User extends Model { $userId = $data['user_id']; $user = User::where('id',$userId)->find(); - $result = $user->allowField(['email','nickname','sex','city','area_id','sign'])->save($data); + $result = $user->allowField(['email','active','nickname','sex','city','area_id','sign'])->save($data); if($result){ return 1; }else{ diff --git a/app/index/controller/Active.php b/app/index/controller/Active.php new file mode 100644 index 0000000..7e40285 --- /dev/null +++ b/app/index/controller/Active.php @@ -0,0 +1,51 @@ +'']); + return View::fetch('index'); + } + + //api首页 + public function email() + { + if(Request::isPost()){ + $url = Request::param('url'); + $atime = substr($url,0,10); + $mde = substr($url,10,32); + $uid = substr($url,42); + $t = time() - $atime; + $mins = floor(($t%3600)/60); + if($mins > 10){ + return json(['code'=>-1,'msg'=>'已超时']); + } + $user = Db::name('user')->find($uid); + $umail = md5($user['email']); + if($umail == $mde){ + $result = Db::name('user')->update(['id'=>$uid,'active'=>1]); + if($result){ + Cache::delete('user'.$this->uid); + return json(['code'=>0,'msg'=>'激活成功','url'=>(string) url('login/index')]); + }else{ + return json(['code'=>-1,'msg'=>'激活失败!']); + } + } else { + return json(['code'=>-1,'msg'=>'请求错误!']); + } + } + + } + +} \ No newline at end of file diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 37e1f17..805e9db 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -62,6 +62,7 @@ class Article extends BaseController //分类列表 $article = new ArticleModel(); $artList = $article->getCateList($ename,$type,$page,$url,$suffix); + $count = $artList->total(); // 热议文章 $artHot = $article->getArtHot(10); @@ -73,7 +74,7 @@ class Article extends BaseController //分类钻展赞助 $ad_comm = $ad->getSliderList(6); - View::assign(['type'=>$type,'artList'=>$artList,'artHot'=>$artHot,'ad_cateImg'=>$ad_cateImg,'ad_comm'=>$ad_comm,'jspage'=>'jie']); + View::assign(['type'=>$type,'artList'=>$artList,'artHot'=>$artHot,'ad_cateImg'=>$ad_cateImg,'ad_comm'=>$ad_comm,'jspage'=>'jie','count'=>$count,'page'=>$page,'url'=>$url]); return View::fetch('article/'.$tpl.'/cate'); } diff --git a/app/index/controller/User.php b/app/index/controller/User.php index 6c9f735..aaa130e 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -117,6 +117,10 @@ class User extends BaseController if(!$result){ $this->error($validate->getError()); } else { + $mail = Db::name('user')->where('id',$this->uid)->value('email'); + if($data['email'] !== $mail){ + $data['active'] = 0; + } $user = new userModel; $result = $user->setNew($data); if($result == 1){ @@ -151,7 +155,7 @@ class User extends BaseController if($dirPath !== './static/res/images/avatar'){ //防止删除默认头像 unlink('.'.$imgPath); } - } + } $result = Db::name('user') ->where('id',$this->uid) ->update(['user_img'=>$name_path]); @@ -202,18 +206,34 @@ class User extends BaseController return View::fetch(); } - //邮箱激活 public function activate() { - $this->isLogin(); - $user = UserModel::find($this->uid); - $this->assign('user',$user); - return view(); + //管理员邮箱 + $adminEmail = Db::name('user')->where('id',1)->cache(true)->value('email'); + View::assign('adminEmail',$adminEmail); + return View::fetch(); + } + + //邮箱激活 + public function active() + { + + if(Request::isPost()){ + $email = Request::param('email'); + $url = Request::domain().Request::root().'/active/index?url='.time().md5($email).$this->uid; + $content = "Hi亲爱的{$this->showUser($this->uid)['name']}:
您正在进行邮箱激活,请在10分钟内完成激活。 请点击进行激活
若无法跳转请复制链接激活:{$url}"; + $res = mailto($email,'邮箱激活',$content); + if($res){ + return json(['status'=>0]); + }else{ + return json(['status'=>-1,'发送邮件出错!']); + } + } } //修改密码 - public function setpass() + public function setPass() { if(Request::isAjax()){ $data = Request::param(); @@ -226,7 +246,8 @@ class User extends BaseController $result = $user->setpass($data); if($result == 1) { Session::clear(); - return $this->success('密码修改成功 请登录', '/login'); + Cookie::delete('auth'); + return $this->success('密码修改成功 请登录', (string) url('login/index')); } else { return $this->error($result); } diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql index 7d5d882..73ec302 100644 --- a/app/install/data/taoler.sql +++ b/app/install/data/taoler.sql @@ -379,7 +379,6 @@ CREATE TABLE `tao_mail_server` ( `port` tinyint(2) NOT NULL COMMENT '邮箱端口', `nickname` varchar(20) NOT NULL DEFAULT '' COMMENT '昵称', `password` varchar(16) NOT NULL COMMENT '邮箱密码', - `active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '邮箱服务1激活0未激活', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; @@ -387,7 +386,7 @@ CREATE TABLE `tao_mail_server` ( -- ---------------------------- -- Records of tao_mail_server -- ---------------------------- -INSERT INTO `tao_mail_server` VALUES ('1', 'xxxx@aliyun.com', 'smtp.aliyun.com', '25', 'user', '123456', '0', '0'); +INSERT INTO `tao_mail_server` VALUES ('1', 'xxxx@aliyun.com', 'smtp.aliyun.com', '25', 'user', '123456', '0'); -- ---------------------------- -- Table structure for tao_message @@ -507,6 +506,7 @@ CREATE TABLE `tao_user` ( `password` varchar(32) NOT NULL COMMENT '密码', `phone` varchar(11) NOT NULL DEFAULT '' COMMENT '手机', `email` varchar(50) NOT NULL DEFAULT '' COMMENT '邮箱', + `active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1激活账户0未激活', `nickname` varchar(16) NOT NULL DEFAULT '' COMMENT '昵称', `city` varchar(50) NOT NULL DEFAULT '' COMMENT '归属地', `sex` enum('0','1') NOT NULL DEFAULT '0' COMMENT '性别0男1女', @@ -533,7 +533,7 @@ CREATE TABLE `tao_user` ( -- ---------------------------- -- Records of tao_user -- ---------------------------- -INSERT INTO `tao_user` VALUES ('1', 'admin', '95d6f8d0d0c3b45e5dbe4057da1b149e', '2147483647', 'admin@qq.com', '管理员', '北京市', '1', '这是一个社区系统', '/static/res/images/avatar/00.jpg', '1', '0', '1', '1', '0', '127.0.0.1', '0', '0', '0', '0', '1579053025', '1578469091', '0'); +INSERT INTO `tao_user` VALUES ('1', 'admin', '95d6f8d0d0c3b45e5dbe4057da1b149e', '2147483647', 'admin@qq.com', '0', '管理员', '北京市', '1', '这是一个社区系统', '/static/res/images/avatar/00.jpg', '1', '0', '1', '1', '0', '127.0.0.1', '0', '0', '0', '0', '1579053025', '1578469091', '0'); -- ---------------------------- -- Table structure for tao_user_area diff --git a/config/taoler.php b/config/taoler.php index b64d39c..05602d7 100644 --- a/config/taoler.php +++ b/config/taoler.php @@ -7,7 +7,7 @@ return [ //应用名,此项不可更改 'appname' => 'TaoLer', //版本配置 - 'version' => '1.8.1', + 'version' => '1.8.2', //加盐 'salt' => 'taoler', //数据库备份目录 diff --git a/public/static/res/mods/index.js b/public/static/res/mods/index.js index 8e82b0e..eaf4c99 100644 --- a/public/static/res/mods/index.js +++ b/public/static/res/mods/index.js @@ -949,7 +949,7 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'imgcom'], //发送激活邮件 fly.activate = function(email){ - fly.json('/api/activate/', {}, function(res){ + fly.json(actvateEmaiUrl, {"email":email}, function(res){ if(res.status === 0){ layer.alert('已成功将激活链接发送到了您的邮箱,接受可能会稍有延迟,请注意查收。', { icon: 1 diff --git a/view/taoler/index/active/index.html b/view/taoler/index/active/index.html new file mode 100644 index 0000000..8cceaf0 --- /dev/null +++ b/view/taoler/index/active/index.html @@ -0,0 +1,36 @@ +{extend name="public:base" /} + +{block name="title"}{$sysInfo.webname}-{$sysInfo.webtitle}{/block} +{block name="column"}{include file="public/column" /}{/block} + +{block name="content"} +
+
+
账户激活成功
+
+
+{include file="public/menu" /} +{/block} + +{block name="script"} + +{/block} \ No newline at end of file diff --git a/view/taoler/index/article/ask/cate.html b/view/taoler/index/article/ask/cate.html index 9f8dba4..2a9af79 100644 --- a/view/taoler/index/article/ask/cate.html +++ b/view/taoler/index/article/ask/cate.html @@ -50,12 +50,8 @@ {/volist} - -
{$artList|raw}
- - +
-
@@ -98,9 +94,11 @@ //执行一个laypage实例 laypage.render({ elem: 'pages' //注意,这里的 test1 是 ID,不用加 # 号 - ,count: 50 //数据总数,从服务端得到 + ,count: {$count} //数据总数,从服务端得到 ,limit: 15 - ,curr :{$Request.param.page ?: 1} //获取起始页 + ,curr : {$page} + + //获取起始页 ,jump: function(obj, first){ //obj包含了当前分页的所有参数,比如: //console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。 @@ -110,6 +108,7 @@ if(!first){ //do something //window.location.href= url+obj.curr+'&limit='+obj.limit+'#collection'; //跳转 + window.location.href = '{$url}'+obj.curr+'.html'; //跳转 } } }); diff --git a/view/taoler/index/article/cate.html b/view/taoler/index/article/cate.html index 96b5955..eef6386 100644 --- a/view/taoler/index/article/cate.html +++ b/view/taoler/index/article/cate.html @@ -51,11 +51,8 @@ {/volist} -
{$artList|raw}
- - +
-
@@ -98,18 +95,19 @@ //执行一个laypage实例 laypage.render({ elem: 'pages' //注意,这里的 test1 是 ID,不用加 # 号 - ,count: 50 //数据总数,从服务端得到 + ,count: {$count} //数据总数,从服务端得到 ,limit: 15 - ,curr :{$Request.param.page ?: 1} //获取起始页 + ,curr :{$page} + //获取起始页 ,jump: function(obj, first){ //obj包含了当前分页的所有参数,比如: //console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。 //console.log(obj.limit); //得到每页显示的条数 - //首次不执行 if(!first){ //do something //window.location.href= url+obj.curr+'&limit='+obj.limit+'#collection'; //跳转 + window.location.href = '{$url}'+obj.curr+'.html'; //跳转 } } }); diff --git a/view/taoler/index/article/posts/cate.html b/view/taoler/index/article/posts/cate.html index 0c3b32d..80a9dc4 100644 --- a/view/taoler/index/article/posts/cate.html +++ b/view/taoler/index/article/posts/cate.html @@ -42,11 +42,8 @@ {/volist} -
{$artList|raw}
- - +
-
@@ -89,9 +86,11 @@ //执行一个laypage实例 laypage.render({ elem: 'pages' //注意,这里的 test1 是 ID,不用加 # 号 - ,count: 50 //数据总数,从服务端得到 + ,count: {$count} //数据总数,从服务端得到 ,limit: 15 - ,curr :{$Request.param.page ?: 1} //获取起始页 + ,curr : {$page} + + //获取起始页 ,jump: function(obj, first){ //obj包含了当前分页的所有参数,比如: //console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。 @@ -101,6 +100,7 @@ if(!first){ //do something //window.location.href= url+obj.curr+'&limit='+obj.limit+'#collection'; //跳转 + window.location.href = '{$url}'+obj.curr+'.html'; //跳转 } } }); diff --git a/view/taoler/index/user/activate.html b/view/taoler/index/user/activate.html index d621a5f..d079d73 100644 --- a/view/taoler/index/user/activate.html +++ b/view/taoler/index/user/activate.html @@ -1,5 +1,6 @@ -{layout name="public:layout" /} - +{extend name="public/user" /} + +{block name="content"}
  • @@ -11,10 +12,14 @@
  • {$user.email} - + {if ($user.active == 1)} + (已成功激活) + {else /} (尚未激活) + {/if}
  • + {if($user.active == 0)}
  • 1. 如果您未收到邮件,或激活链接失效,您可以 @@ -22,12 +27,19 @@ 更换邮箱
    - 2. 如果您始终没有收到 Fly 发送的邮件,请注意查看您邮箱中的垃圾邮件; + 2. 如果您始终没有收到发送的邮件,请注意查看您邮箱中的垃圾邮件;
    - 3. 如果你实在无法激活邮件,您还可以联系:admin@xx.com + 3. 如果你实在无法激活邮件,您还可以联系管理员:{$adminEmail}
  • + {/if}
+{/block} +{block name="script"} + +{/block}