diff --git a/app/BaseController.php b/app/BaseController.php index 6f17a2c..cfa751b 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -6,6 +6,12 @@ namespace app; use think\App; use think\exception\ValidateException; use think\Validate; +use think\Response; +use think\exception\HttpResponseException; +use think\facade\Db; +use think\facade\Request; +use think\facade\Lang; +use think\facade\View; /** * 控制器基础类 @@ -187,4 +193,94 @@ abstract class BaseController } + //显示网站设置 + protected function getSystem() + { + //1.系统配置信息 + return Db::name('system')->cache('system',3600)->find(1); + + } + + //域名协议转换 把数据库中的带HTTP或不带协议的域名转换为当前协议的域名前缀 + protected function getHttpUrl($url) + { + //域名转换为无http协议 + $www = stripos($url,'://') ? substr(stristr($url,'://'),3) : $url; + $htpw = Request::scheme().'://'. $www; + return $htpw; + } + + //得到当前系统安装前台域名 + protected function getIndexUrl() + { + $sys = $this->getSystem(); + $domain = $this->getHttpUrl($sys['domain']); + $syscy = $sys['clevel'] ? Lang::get('Authorized') : Lang::get('Free version'); + $runTime = $this->getRunTime(); + View::assign(['domain'=>$domain,'insurl'=>$sys['domain'],'syscy'=>$syscy,'clevel'=>$sys['clevel'],'runTime'=>$runTime]); + return $domain; + } + + protected function getRunTime() + { + //运行时间 + $now = time(); + $sys = $this->getSystem(); + $count = $now-$sys['create_time']; + $days = floor($count/86400); + $hos = floor(($count%86400)/3600); + $mins = floor(($count%3600)/60); + $years = floor($days/365); + if($years >= 1){ + $days = floor($days%365); + } + $runTime = $years ? "{$years}年{$days}天{$hos}时{$mins}分" : "{$days}天{$hos}时{$mins}分"; + return $runTime; + } + + /** + * 获取文章链接地址 + * + * @param integer $aid + * @return string + */ + protected function getRouteUrl(int $aid) : string + { + $indexUrl = $this->getIndexUrl(); + $artUrl = (string) url('detail_id', ['id' => $aid]); + + // 判断是否开启绑定 + //$domain_bind = array_key_exists('domain_bind',config('app')); + + // 判断index应用是否绑定域名 + $bind_index = array_search('index',config('app.domain_bind')); + // 判断admin应用是否绑定域名 + $bind_admin = array_search('admin',config('app.domain_bind')); + + // 判断index应用是否域名映射 + $map_index = array_search('index',config('app.app_map')); + // 判断admin应用是否域名映射 + $map_admin = array_search('admin',config('app.app_map')); + + $index = $map_index ? $map_index : 'index'; // index应用名 + $admin = $map_admin ? $map_admin : 'admin'; // admin应用名 + + if($bind_index) { + // index绑定域名 + $url = $indexUrl . str_replace($admin.'/','',$artUrl); + } else { // index未绑定域名 + // admin绑定域名 + if($bind_admin) { + $url = $indexUrl .'/' . $index . $artUrl; + } else { + $url = $indexUrl . str_replace($admin,$index,$artUrl); + } + + } + + return $url; + } + + + } diff --git a/app/admin/controller/Forum.php b/app/admin/controller/Forum.php index da9a9d7..e925637 100644 --- a/app/admin/controller/Forum.php +++ b/app/admin/controller/Forum.php @@ -3,17 +3,13 @@ namespace app\admin\controller; use app\common\controller\AdminController; -use app\admin\validate\Admin; -use app\admin\model\Admin as adminModel; use app\common\model\Cate; use app\common\model\Comment; use app\common\model\Article; use think\facade\View; use think\facade\Request; use think\facade\Db; -use think\facade\Session; use think\facade\Cache; -use think\exception\ValidateException; use taoler\com\Files; class Forum extends AdminController @@ -117,32 +113,22 @@ class Forum extends AdminController } } - //置顶帖子 - public function top() - { - // - } - //加精帖子 - public function hot() - { - // - } - //审核帖子 + /** + * 置顶、加精、评论开关,审核等状态管理 + * + * @return void + */ public function check() { - $data = Request::only(['id','status']); - + $param = Request::only(['id','name','value']); + $data = ['id'=>$param['id'],$param['name']=>$param['value']]; //获取状态 - $res = Db::name('article')->where('id',$data['id'])->save(['status' => $data['status']]); + $res = Db::name('article')->save($data); + Cache::delete('article_'.$data['id']); if($res){ - if($data['status'] == 1){ - return json(['code'=>0,'msg'=>'帖子审核通过','icon'=>6]); - } else { - return json(['code'=>0,'msg'=>'帖子被禁止','icon'=>5]); - } - + return json(['code'=>0,'msg'=>'设置成功','icon'=>6]); }else { - return json(['code'=>-1,'msg'=>'审核出错']); + return json(['code'=>-1,'msg'=>'失败啦','icon'=>6]); } } diff --git a/app/admin/controller/Seo.php b/app/admin/controller/Seo.php index 0a835bf..1b3da57 100644 --- a/app/admin/controller/Seo.php +++ b/app/admin/controller/Seo.php @@ -2,7 +2,7 @@ /* * @Author: TaoLer * @Date: 2022-04-13 09:54:31 - * @LastEditTime: 2022-05-07 12:00:01 + * @LastEditTime: 2022-05-12 16:21:33 * @LastEditors: TaoLer * @Description: 搜索引擎SEO优化设置 * @FilePath: \TaoLer\app\admin\controller\Seo.php @@ -60,8 +60,7 @@ class Seo extends AdminController $urls[] = $this->getRouteUrl($aid); } // 百度接口单次最大提交200,进行分组 - $urls = array_chunk($urls,2000); - + $urls = array_chunk($urls,2000); $api = config('taoler.baidu.push_api'); $ch = curl_init(); foreach($urls as $url) { diff --git a/app/admin/view/forum/list.html b/app/admin/view/forum/list.html index 1d485fc..c8c4c39 100644 --- a/app/admin/view/forum/list.html +++ b/app/admin/view/forum/list.html @@ -49,38 +49,21 @@
-
- - - - - + {/block} diff --git a/app/admin/view/set/system/website.html b/app/admin/view/set/system/website.html index 32c02af..e6f547e 100644 --- a/app/admin/view/set/system/website.html +++ b/app/admin/view/set/system/website.html @@ -123,7 +123,7 @@
-
提示:
+
提示
未授权版本,不限制功能,但严禁私自改写此处版权脚本,一旦发现,永久关闭升级服务!!
diff --git a/app/common/controller/AdminController.php b/app/common/controller/AdminController.php index c2cb866..d3ed52a 100644 --- a/app/common/controller/AdminController.php +++ b/app/common/controller/AdminController.php @@ -1,4 +1,13 @@ + * @Date: 2021-12-06 16:04:50 + * @LastEditTime: 2022-05-12 16:02:40 + * @LastEditors: TaoLer + * @Description: 搜索引擎SEO优化设置 + * @FilePath: \TaoLer\app\common\controller\AdminController.php + * Copyright (c) 2020~2022 https://www.aieok.com All rights reserved. + */ declare (strict_types = 1); namespace app\common\controller; @@ -92,93 +101,6 @@ class AdminController extends \app\BaseController return true; } - //显示网站设置 - protected function getSystem() - { - //1.系统配置信息 - return Db::name('system')->cache('system',3600)->find(1); - - } - //域名协议转换 把数据库中的带HTTP或不带协议的域名转换为当前协议的域名前缀 - protected function getHttpUrl($url) - { - //域名转换为无http协议 - $www = stripos($url,'://') ? substr(stristr($url,'://'),3) : $url; - $htpw = Request::scheme().'://'. $www; - return $htpw; - } - - //得到当前系统安装前台域名 - protected function getIndexUrl() - { - $sys = $this->getSystem(); - $domain = $this->getHttpUrl($sys['domain']); - $syscy = $sys['clevel'] ? Lang::get('Authorized') : Lang::get('Free version'); - $runTime = $this->getRunTime(); - View::assign(['domain'=>$domain,'insurl'=>$sys['domain'],'syscy'=>$syscy,'clevel'=>$sys['clevel'],'runTime'=>$runTime]); - return $domain; - } - - protected function getRunTime() - { - //运行时间 - $now = time(); - $sys = $this->getSystem(); - $count = $now-$sys['create_time']; - $days = floor($count/86400); - $hos = floor(($count%86400)/3600); - $mins = floor(($count%3600)/60); - $years = floor($days/365); - if($years >= 1){ - $days = floor($days%365); - } - $runTime = $years ? "{$years}年{$days}天{$hos}时{$mins}分" : "{$days}天{$hos}时{$mins}分"; - return $runTime; - } - - /** - * 获取文章链接地址 - * - * @param integer $aid - * @return string - */ - protected function getRouteUrl(int $aid) : string - { - $indexUrl = $this->getIndexUrl(); - $artUrl = (string) url('detail_id', ['id' => $aid]); - - // 判断是否开启绑定 - //$domain_bind = array_key_exists('domain_bind',config('app')); - - // 判断index应用是否绑定域名 - $bind_index = array_search('index',config('app.domain_bind')); - // 判断admin应用是否绑定域名 - $bind_admin = array_search('admin',config('app.domain_bind')); - - // 判断index应用是否域名映射 - $map_index = array_search('index',config('app.app_map')); - // 判断admin应用是否域名映射 - $map_admin = array_search('admin',config('app.app_map')); - - $index = $map_index ? $map_index : 'index'; // index应用名 - $admin = $map_admin ? $map_admin : 'admin'; // admin应用名 - - if($bind_index) { - // index绑定域名 - $url = $indexUrl . str_replace($admin.'/','',$artUrl); - } else { // index未绑定域名 - // admin绑定域名 - if($bind_admin) { - $url = $indexUrl .'/' . $index . $artUrl; - } else { - $url = $indexUrl . str_replace($admin,$index,$artUrl); - } - - } - - return $url; - } - } \ No newline at end of file diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index a208b1c..ad628f5 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -205,16 +205,24 @@ class Article extends BaseController $article = new ArticleModel(); $result = $article->add($data); if ($result['code'] == 1) { + // 获取到的最新ID + $aid = Db::name('article')->max('id'); + // 清除文章tag缓存 + Cache::tag('tagArtDetail')->clear(); + // 发提醒邮件 + if(Config::get('taoler.config.email_notice')) mailto($this->showUser(1)['email'],'发帖审核通知','Hi亲爱的管理员:
用户'.$this->showUser($this->uid)['name'].'刚刚发表了 '.$data['title'].' 新的帖子,请尽快处理。'); + if(Config::get('taoler.config.posts_check')){ - $aid = Db::name('article')->max('id'); $link = (string)url('article/detail', ['id' => $aid]); }else{ $link = (string)url('index/'); } - // 清除文章tag缓存 - Cache::tag('tagArtDetail')->clear(); - if(Config::get('taoler.config.email_notice')) mailto($this->showUser(1)['email'],'发帖审核通知','Hi亲爱的管理员:
用户'.$this->showUser($this->uid)['name'].'刚刚发表了 '.$data['title'].' 新的帖子,请尽快处理。'); - $res = Msgres::success($result['msg'], $link); + // 推送给百度收录接口 + if(empty(config('taoler.baidu.push_api'))) { + $this->baiduPush($aid); + } + + $res = Msgres::success($result['msg'], $link); } else { $res = Msgres::error('add_error'); } @@ -261,6 +269,10 @@ class Article extends BaseController //删除原有缓存显示编辑后内容 Cache::delete('article_'.$id); $link = (string) url('article/detail',['id'=> $id]); + // 推送给百度收录接口 + if(empty(config('taoler.baidu.push_api'))) { + $this->baiduPush($data['id']); + } $editRes = Msgres::success('edit_success',$link); } else { $editRes = Msgres::error($result); @@ -541,11 +553,35 @@ class Article extends BaseController $tag = Config::get('taglink'); if(count($tag)) { foreach($tag as $key=>$value) { - $content = str_replace("$key", 'a('.$value.')['.$key.']',$content); + // 匹配所有 + //$content = str_replace("$key", 'a('.$value.')['.$key.']',$content); + // 限定匹配数量 + $content = preg_replace('/'.$key.'/','a('.$value.')['.$key.']',$content,2); } } return $content; } + + // baidu push api + protected function baiduPush($id) + { + // baidu 接口 + $api = config('taoler.baidu.push_api'); + $artUrl = $this->getRouteUrl((int)$id); + $url = [$artUrl]; + $ch = curl_init(); + $options = array( + CURLOPT_URL => $api, + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POSTFIELDS => implode("\n", $url), + CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), + ); + curl_setopt_array($ch, $options); + curl_exec($ch); + curl_close($ch); + + } } \ No newline at end of file diff --git a/public/static/admin/modules/forum.js b/public/static/admin/modules/forum.js index 33deef6..185f04a 100644 --- a/public/static/admin/modules/forum.js +++ b/public/static/admin/modules/forum.js @@ -1,25 +1,25 @@ - + layui.define(['table', 'form'], function(exports){ var $ = layui.$ ,table = layui.table ,form = layui.form; //帖子管理 - table.render({ +var forms = table.render({ elem: '#LAY-app-forum-list' ,url: forumList //帖子数据接口 ,cols: [[ {type: 'checkbox'} ,{field: 'id', width: 60, title: 'ID', sort: true} - ,{field: 'poster', title: '贴主',width: 100} - ,{field: 'avatar', title: '头像', width: 80, templet: '#imgTpl'} - ,{field: 'title', title: '标题', mWidth: 200,templet: '#title'} - ,{field: 'content', title: '内容', mWidth: 200} + ,{field: 'poster', title: '账号',width: 80} + ,{field: 'avatar', title: '头像', width: 60, templet: '#avatarTpl'} + ,{field: 'title', title: '标题', minWidth: 180,templet: '
{{d.title}}
'} + ,{field: 'content', title: '内容', minWidth: 200} ,{field: 'posttime', title: '时间',width: 120, sort: true} ,{field: 'top', title: '置顶', templet: '#buttonTpl', width: 80, align: 'center'} ,{field: 'hot', title: '加精', templet: '#buttonHot', width: 80, align: 'center'} ,{field: 'reply', title: '禁评', templet: '#buttonReply', width: 80, align: 'center'} - ,{field: 'check', title: '审帖', templet: '#buttonCheck', width: 100, align: 'center'} + ,{field: 'check', title: '审帖', templet: '#buttonCheck', width: 95, align: 'center'} ,{title: '操作', width: 60, align: 'center', toolbar: '#table-forum-list'} ]] ,page: true @@ -34,29 +34,29 @@ layui.define(['table', 'form'], function(exports){ if(obj.event === 'del'){ layer.confirm('确定删除此条帖子?', function(index){ //obj.del(); - $.ajax({ - type:'post', - url:forumListdel, - data:{id:data.id}, - dataType:'json', - success:function(data){ - if(data.code == 0){ - layer.msg(data.msg,{ - icon:6, - time:2000 - },function(){ - location.reload(); - }); - } else { - layer.open({ - title:'删除失败', - content:data.msg, - icon:5, - adim:6 - }) - } - } - }); + $.ajax({ + type:'post', + url:forumListdel, + data:{id:data.id}, + dataType:'json', + success:function(data){ + if(data.code == 0){ + layer.msg(data.msg,{ + icon:6, + time:2000 + },function(){ + forms.reload(); + }); + } else { + layer.open({ + title:'删除失败', + content:data.msg, + icon:5, + adim:6 + }) + } + } + }); layer.close(index); }); } else if(obj.event === 'edit'){ @@ -74,8 +74,8 @@ layui.define(['table', 'form'], function(exports){ ,submitID = 'LAY-app-forum-submit' ,submit = layero.find('iframe').contents().find("#layuiadmin-form-list") ,poster = submit.find('input[name="poster"]').val() - ,content = submit.find('input[name="content"]').val() - ,avatar = submit.find('input[name="avatar"]').val(); + ,content = submit.find('input[name="content"]').val() + ,avatar = submit.find('input[name="avatar"]').val(); //监听提交 iframeWindow.layui.form.on('submit('+ submitID +')', function(data){ @@ -132,7 +132,7 @@ layui.define(['table', 'form'], function(exports){ ,{field: 'avatar', title: '头像', width: 80, templet: '#imgTpl'} ,{field: 'content', title: '评论', minWidth: 200} ,{field: 'replytime', title: '回复时间', width: 120, sort: true} - ,{field: 'check', title: '审核', templet: '#buttonCheck', width: 100} + ,{field: 'check', title: '审核', templet: '#buttonCheck', width: 100} ,{title: '操作', width: 60, align: 'center', toolbar: '#table-forum-replys'} ]] ,page: true diff --git a/public/static/res/mods/imgcom.js b/public/static/res/mods/imgcom.js index 0dd9b2b..5b9822d 100644 --- a/public/static/res/mods/imgcom.js +++ b/public/static/res/mods/imgcom.js @@ -1,4 +1,4 @@ -/** +/** images压缩扩展模块 changlin_zhao@qq.com 2021.5.25 diff --git a/view/taoler/index/article/add.html b/view/taoler/index/article/add.html index 9b785e6..a9515b5 100644 --- a/view/taoler/index/article/add.html +++ b/view/taoler/index/article/add.html @@ -216,8 +216,42 @@ }); // 获取描述的内容 - $("#L_content").bind('input propertychange', function(){ - var content = $(this).val() + // $("#L_content111").bind('input propertychange', function(){ + // var content = $(this).val(); + // setTimeout(function(){ + // $.ajax({ + // type:"post", + // url:"{:url('article/getDescription')}", + // data:{"content":content}, + // daType:"json", + // success:function (data){ + // if (data.code == 0) { + // $('[name="description"]').val(data.data); + // } + // } + // }) + // }, 5000) + // return false; + // }) + + // 获取描述的内容 非实时获取,停止输入后获取 + var flag = false; + var othis = $('#L_content'); + othis.on('compositionstart',function(){ + flag = true; + }) + othis.on('compositionend',function(){ + flag = false; + desc(othis.val()); + + }) + + // othis.on('input', function (event) { + // // 忽略一切非直接输入,不做逻辑处理 + // if (!flag) todo(event.target.value); + // }); + + function desc(content){ $.ajax({ type:"post", url:"{:url('article/getDescription')}", @@ -228,9 +262,8 @@ $('[name="description"]').val(data.data); } } - }); - return false; - }) + }) + } // 手动添加tags $('#article-tags-button').on('click',function(){ diff --git a/view/taoler/index/error/404.html b/view/taoler/index/error/404.html index 458c228..0803feb 100644 --- a/view/taoler/index/error/404.html +++ b/view/taoler/index/error/404.html @@ -1,3 +1,12 @@ + {extend name="public/base" /} {block name="title"}404 - {$sysInfo.webname}{/block} @@ -9,7 +18,7 @@

-

页面或者数据被 纸飞机 运到火星了,啥都看不到了…

+

页面或者数据被 纸飞机 运到火星了,啥都看不到了…

@@ -19,11 +28,11 @@ {block name="script"}{/block} diff --git a/view/taoler/index/public/column.html b/view/taoler/index/public/column.html index e228466..f315696 100644 --- a/view/taoler/index/public/column.html +++ b/view/taoler/index/public/column.html @@ -1,12 +1,3 @@ -
    diff --git a/view/taoler/index/public/filter.html b/view/taoler/index/public/filter.html index 9b38e65..b9f769e 100644 --- a/view/taoler/index/public/filter.html +++ b/view/taoler/index/public/filter.html @@ -1,12 +1,3 @@ -
    {:lang('all')} diff --git a/view/taoler/index/public/footer.html b/view/taoler/index/public/footer.html index ab49c5b..4a38a8e 100644 --- a/view/taoler/index/public/footer.html +++ b/view/taoler/index/public/footer.html @@ -1,12 +1,3 @@ -