- {$art.title} + {article:title /}
{:getArtContent($art.content)}
+{:getArtContent($article.content)}
diff --git a/app/BaseController.php b/app/BaseController.php index f24c8b6..081e41b 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -470,4 +470,17 @@ abstract class BaseController return $array; } + /** + * 过滤字符串中表情 + * @param $str string 字符串内容 + * @return string + */ + public function filterEmoji(string $str): string + { + $str = preg_replace_callback('/./u', function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, $str); + return $str; + } + } diff --git a/app/admin/controller/content/Forum.php b/app/admin/controller/content/Forum.php index 5f34437..7f12dd9 100644 --- a/app/admin/controller/content/Forum.php +++ b/app/admin/controller/content/Forum.php @@ -131,9 +131,9 @@ class Forum extends AdminController $data['content'] = $this->downUrlPicsReaplace($data['content']); // 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); - + $data['description'] = strip_tags($this->filterEmoji($data['description'])); // 获取分类ename,appname - $cateName = $this->model->field('ename,appname')->find($data['cate_id']); + $cateEname = Db::name('cate')->where('id',$data['cate_id'])->value('ename'); $result = $this->model->add($data); if ($result['code'] == 1) { @@ -152,7 +152,7 @@ class Forum extends AdminController // 清除文章tag缓存 Cache::tag('tagArtDetail')->clear(); - $link = $this->getArticleUrl((int)$aid, 'index', $cateName['ename']); + $link = $this->getArticleUrl((int)$aid, 'index', $cateEname); hook('SeoBaiduPush', ['link'=>$link]); // 推送给百度收录接口 @@ -201,7 +201,7 @@ class Forum extends AdminController $data['content'] = $this->downUrlPicsReaplace($data['content']); // 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); - + $data['description'] = strip_tags($this->filterEmoji($data['description'])); $result = $article->edit($data); if($result == 1) { //处理标签 @@ -228,7 +228,7 @@ class Forum extends AdminController } //删除原有缓存显示编辑后内容 Cache::delete('article_'.$id); - $link = $this->getRouteUrl((int) $id, $article->cate->ename, $article->cate->appname); + $link = $this->getArticleUrl((int) $id, 'index', $article->cate->ename); hook('SeoBaiduPush', ['link'=>$link]); // 推送给百度收录接口 return Msgres::success('edit_success',$link); } diff --git a/app/admin/view/user/user/add.html b/app/admin/view/user/user/add.html index 20930f0..d33d51c 100644 --- a/app/admin/view/user/user/add.html +++ b/app/admin/view/user/user/add.html @@ -90,8 +90,8 @@ icon: 1, time: 1000 }, function() { - parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页 parent.layui.table.reload("user-table"); + parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页 }); } else { layer.msg(result.msg, { diff --git a/app/common.php b/app/common.php index b33329d..f82e1cc 100644 --- a/app/common.php +++ b/app/common.php @@ -251,18 +251,6 @@ function getSpaceNmu($level) return str_repeat('---',$level); } -//链接投放开关,有设置则打开 -function showSlider($type) -{ - $sliders = new \app\common\model\Slider(); - $sliderArr = $sliders->getSliderList($type); - if(!empty($sliderArr)) { - return true; - } else { - return false; - } -} - //提取内容第一张图片 function getOnepic($str) { diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php index fdf4c6f..4975ba2 100644 --- a/app/common/controller/BaseController.php +++ b/app/common/controller/BaseController.php @@ -17,7 +17,6 @@ use think\facade\View; use think\facade\Db; use think\facade\Session; use think\facade\Cache; -use app\facade\Article; use app\BaseController as BaseCtrl; use app\common\model\Cate; @@ -146,21 +145,11 @@ class BaseController extends BaseCtrl { //1.查询分类表获取所有分类 $sysInfo = $this->getSystem(); - $slider = new \app\common\model\Slider(); - //头部链接 - $head_links = $slider->getSliderList(10); - //页脚链接 - $foot_links = $slider->getSliderList(11); - //友情链接 - $friend_links = $slider->getSliderList(9); //获取热门标签 $hotTag = $this->getHotTag(); $assign = [ 'sysInfo' => $sysInfo, - 'headlinks' => $head_links, - 'footlinks' => $foot_links, - 'flinks' => $friend_links, 'hotTag' => $hotTag, 'host' => Request::domain() . '/' ]; diff --git a/app/common/taglib/Article.php b/app/common/taglib/Article.php index ef5fc8f..acdad2c 100644 --- a/app/common/taglib/Article.php +++ b/app/common/taglib/Article.php @@ -13,7 +13,6 @@ namespace app\common\taglib; use think\template\TagLib; -use app\common\model\Article as ArticleModel; class Article extends TagLib { @@ -29,10 +28,14 @@ class Article extends TagLib 'comment_num' => ['attr' => '', 'close' => 0], 'keywords' => ['attr' => '', 'close' => 0], 'description' => ['attr' => '', 'close' => 0], + 'link' => ['attr' => '', 'close' => 0], + 'time' => ['attr' => '', 'close' => 0], 'cate' => ['attr' => 'name', 'close' => 0], 'user' => ['attr' => 'name', 'close' => 0], + 'list' => ['attr' => '', 'close' => 1], + 'comment' => ['attr' => '', 'close' => 1], @@ -88,6 +91,16 @@ class Article extends TagLib return '{$article.description}'; } + public function tagLink(): string + { + return '{$article.url}'; + } + + public function tagTime(): string + { + return '{$article.create_time}'; + } + // 详情分类 public function tagCate($tag): string { @@ -106,12 +119,17 @@ class Article extends TagLib return '{$article.cate_id}'; } + if($tag['name'] == 'link') + { + return '{:url(\'cate\',[\'ename\'=>$article.cate.ename])}'; + } + return ''; } public function tagUser($tag) { - if($tag['name'] == 'user_link') { + if($tag['name'] == 'link') { return '{:url("user/home",["id"=>'.'$'.'article.user.id'.'])->domain(true)}'; } return '{$article.user.' . $tag['name'] . '}'; @@ -155,4 +173,13 @@ class Article extends TagLib return $parse; } + // 分类列表 + public function tagList($tag, $content): string + { + $parse = '{volist name="artList['.'\'data\''.']" id="article" empty= "还没有内容"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + } \ No newline at end of file diff --git a/app/common/taglib/Cate.php b/app/common/taglib/Cate.php new file mode 100644 index 0000000..a5a50d6 --- /dev/null +++ b/app/common/taglib/Cate.php @@ -0,0 +1,21 @@ + + * @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved. + */ + +namespace app\common\taglib; + +use think\template\TagLib; + +class Cate extends TagLib +{ + protected $tag = [ + + ]; + +} \ No newline at end of file diff --git a/app/common/taglib/Gnav.php b/app/common/taglib/Gnav.php new file mode 100644 index 0000000..70b83b0 --- /dev/null +++ b/app/common/taglib/Gnav.php @@ -0,0 +1,95 @@ + + * @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved. + */ + +namespace app\common\taglib; + +use think\template\TagLib; + +class Gnav extends TagLib +{ + protected $tags = [ + // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 + //'nav' => ['attr' => '', 'close' => 1], + 'id' => ['attr' => '', 'close' => 0], + 'pid' => ['attr' => '', 'close' => 0], + 'icon' => ['attr' => '', 'close' => 0], + 'name' => ['attr' => '', 'close' => 0], + 'ename' => ['attr' => '', 'close' => 0], + 'title' => ['attr' => '', 'close' => 0], + 'detpl' => ['attr' => '', 'close' => 0], + 'sort' => ['attr' => '', 'close' => 0], + 'desc' => ['attr' => '', 'close' => 0], + 'is_hot' => ['attr' => '', 'close' => 0], + 'link' => ['attr' => '', 'close' => 0], + 'children' => ['attr' => '', 'close' => 0], + + ]; + + + public function tagId(): string + { + return '{$gnav.id}'; + } + + public function tagPid(): string + { + return '{$gnav.pid}'; + } + + public function tagIcon(): string + { + return '{$gnav.icon}'; + } + + public function tagName($tag): string + { + return '{$gnav.catename}'; + } + + public function tagEname(): string + { + return '{$gnav.ename}'; + } + + public function tagTitle(): string + { + return '{:cookie(\'think_lang\') == \'en-us\' ? $gnav.ename : $gnav.catename}'; + } + + public function tagDetpl(): string + { + return '{$gnav.detpl}'; + } + + public function tagSort(): string + { + return '{$gnav.sort}'; + } + + public function tagDesc(): string + { + return '{$gnav.desc}'; + } + + public function tagIs_hot(): string + { + return '{$gnav.is_hot}'; + } + + public function tagLink(): string + { + return '{$gnav.url}'; + } + + public function tagChildren(): string + { + return '{$gnav.children}'; + } +} \ No newline at end of file diff --git a/app/common/taglib/Nav.php b/app/common/taglib/Nav.php new file mode 100644 index 0000000..31d75f7 --- /dev/null +++ b/app/common/taglib/Nav.php @@ -0,0 +1,96 @@ + + * @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved. + */ + +namespace app\common\taglib; + +use think\template\TagLib; + +class Nav extends TagLib +{ + protected $tags = [ + // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 + //'nav' => ['attr' => '', 'close' => 1], + 'id' => ['attr' => '', 'close' => 0], + 'pid' => ['attr' => '', 'close' => 0], + 'icon' => ['attr' => '', 'close' => 0], + 'name' => ['attr' => '', 'close' => 0], + 'ename' => ['attr' => '', 'close' => 0], + 'title' => ['attr' => '', 'close' => 0], + 'detpl' => ['attr' => '', 'close' => 0], + 'sort' => ['attr' => '', 'close' => 0], + 'desc' => ['attr' => '', 'close' => 0], + 'is_hot' => ['attr' => '', 'close' => 0], + 'link' => ['attr' => '', 'close' => 0], + 'children' => ['attr' => '', 'close' => 0], + + ]; + + + public function tagId(): string + { + return '{$nav.id}'; + } + + public function tagPid(): string + { + return '{$nav.pid}'; + } + + public function tagIcon(): string + { + return '{$nav.icon}'; + } + + public function tagName($tag): string + { + return '{$nav.catename}'; + } + + public function tagEname(): string + { + return '{$nav.ename}'; + } + + public function tagTitle(): string + { + return '{:cookie(\'think_lang\') == \'en-us\' ? $nav.ename : $nav.catename}'; + } + + public function tagDetpl(): string + { + return '{$nav.detpl}'; + } + + public function tagSort(): string + { + return '{$nav.sort}'; + } + + public function tagDesc(): string + { + return '{$nav.desc}'; + } + + public function tagIs_hot(): string + { + return '{$nav.is_hot}'; + } + + public function tagLink(): string + { + return '{$nav.url}'; + } + + public function tagChildren(): string + { + return '{$nav.children}'; + } + +} \ No newline at end of file diff --git a/app/common/taglib/Snav.php b/app/common/taglib/Snav.php new file mode 100644 index 0000000..29550b8 --- /dev/null +++ b/app/common/taglib/Snav.php @@ -0,0 +1,95 @@ + + * @Copyright (c) 2020~2023 https://www.aieok.com All rights reserved. + */ + +namespace app\common\taglib; + +use think\template\TagLib; + +class Snav extends TagLib +{ + protected $tags = [ + // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 + //'nav' => ['attr' => '', 'close' => 1], + 'id' => ['attr' => '', 'close' => 0], + 'pid' => ['attr' => '', 'close' => 0], + 'icon' => ['attr' => '', 'close' => 0], + 'name' => ['attr' => '', 'close' => 0], + 'ename' => ['attr' => '', 'close' => 0], + 'title' => ['attr' => '', 'close' => 0], + 'detpl' => ['attr' => '', 'close' => 0], + 'sort' => ['attr' => '', 'close' => 0], + 'desc' => ['attr' => '', 'close' => 0], + 'is_hot' => ['attr' => '', 'close' => 0], + 'link' => ['attr' => '', 'close' => 0], + 'children' => ['attr' => '', 'close' => 0], + + ]; + + + public function tagId(): string + { + return '{$snav.id}'; + } + + public function tagPid(): string + { + return '{$snav.pid}'; + } + + public function tagIcon(): string + { + return '{$snav.icon}'; + } + + public function tagName($tag): string + { + return '{$snav.catename}'; + } + + public function tagEname(): string + { + return '{$snav.ename}'; + } + + public function tagTitle(): string + { + return '{:cookie(\'think_lang\') == \'en-us\' ? $snav.ename : $snav.catename}'; + } + + public function tagDetpl(): string + { + return '{$snav.detpl}'; + } + + public function tagSort(): string + { + return '{$snav.sort}'; + } + + public function tagDesc(): string + { + return '{$snav.desc}'; + } + + public function tagIs_hot(): string + { + return '{$snav.is_hot}'; + } + + public function tagLink(): string + { + return '{$snav.url}'; + } + + public function tagChildren(): string + { + return '{$snav.children}'; + } +} \ No newline at end of file diff --git a/app/common/taglib/Taoler.php b/app/common/taglib/Taoler.php index f43aa6d..75eb6fa 100644 --- a/app/common/taglib/Taoler.php +++ b/app/common/taglib/Taoler.php @@ -16,12 +16,52 @@ class Taoler extends TagLib { protected $tags = [ // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 - 'content' => ['attr' => 'name', 'close' => 0], + 'nav' => ['attr' => '', 'close' => 1], + 'snav' => ['attr' => '', 'close' => 1], + 'gnav' => ['attr' => '', 'close' => 1], + 'if' => ['condition', 'expression' => true, 'close' => 1], ]; - public function tagContent($tag) + public function tagNav($tag, $content): string { - return '{$article.' . $tag['name'] . '}'; + $id = $tag['id'] ?? 'nav'; + $parse = '{volist name="cateList" id="'.$id.'"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; } + + public function tagSnav($tag, $content): string + { + $id = $tag['id'] ?? 'snav'; + $parse = '{volist name="nav.children" id="'.$id.'"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + + public function tagGnav($tag, $content): string + { + $id = $tag['id'] ?? 'gnav'; + $parse = '{volist name="snav.children" id="'.$id.'"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + + public function tagIf($tag, $content): string + { + + $condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition']; + $condition = $this->parseCondition($condition); + $parseStr = '' . $content . ''; + + return $parseStr; + +// return '{if'.$tag.'}} '.$content.' {/if}'; + + } + + } \ No newline at end of file diff --git a/app/index/config/view.php b/app/index/config/view.php index af45d61..b135fc9 100644 --- a/app/index/config/view.php +++ b/app/index/config/view.php @@ -3,13 +3,38 @@ // | 模板设置 // +---------------------------------------------------------------------- use think\facade\Db; +use taoler\com\Files; +use think\facade\Cache; + //如果网站安装从数据库查询选择的模板 if(file_exists('./install.lock')){ - $template = Db::name('system')->where('id',1)->value('template'); + $template = Db::name('system')->where('id',1)->cache(true)->value('template'); } else { $template = ''; } + $taglib_pre_load = Cache::remember('taglib', function(){ + $tagsArr = []; + //获取app/common/taglib + $common_taglib = Files::getAllFile(root_path().'app/common/taglib'); + foreach ($common_taglib as $t) { + $tagsArr[] = str_replace('/','\\',strstr(strstr($t, 'app/'), '.php', true)); + } + + //获取addons/taglib文件 + $localAddons = Files::getDirName('../addons/'); + foreach($localAddons as $v) { + $dir = root_path(). 'addons'. DIRECTORY_SEPARATOR . $v . DIRECTORY_SEPARATOR .'taglib'; + if(!file_exists($dir)) continue; + $addons_taglib = Files::getAllFile($dir); + foreach ($addons_taglib as $a) { + $tagsArr[] = str_replace('/','\\',strstr(strstr($a, 'addons/'), '.php', true)); + } + } + return implode(',', $tagsArr); + }); + + return [ // 模板引擎类型使用Think 'type' => 'Think', @@ -20,7 +45,7 @@ return [ // 模板后缀 'view_suffix' => 'html', // 预先加载的标签库 - 'taglib_pre_load' => 'app\common\taglib\Article,app\common\taglib\Taoler,app\common\taglib\Comment', + 'taglib_pre_load' => $taglib_pre_load, // 模板文件名分隔符 'view_depr' => DIRECTORY_SEPARATOR, // 模板引擎普通标签开始标记 diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index d7de9ec..dde6cf3 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -12,8 +12,6 @@ use think\facade\Session; use think\facade\Config; use app\common\model\Cate; use app\common\model\Comment; -use app\common\model\Article as ArticleModel; -use app\common\model\Slider; use app\common\model\UserZan; use app\common\model\PushJscode; use taoler\com\Message; @@ -30,15 +28,13 @@ class Article extends BaseController public function __construct(App $app) { parent::__construct($app); - $this->model = new ArticleModel(); + $this->model = new \app\common\model\Article(); } //文章分类 public function cate() { $cate = new Cate(); - $ad = new Slider(); - $article = new ArticleModel(); //动态参数 $ename = Request::param('ename'); $type = Request::param('type','all'); @@ -53,13 +49,10 @@ class Article extends BaseController $path = substr($url,0,strrpos($url,"/")); //分类列表 - $artList = $article->getCateList($ename,$type,$page); + $artList = $this->model->getCateList($ename,$type,$page); // 热议文章 - $artHot = $article->getArtHot(10); - //分类图片 - $ad_cateImg = $ad->getSliderList(3); - //分类钻展赞助 - $ad_comm = $ad->getSliderList(6); + $artHot = $this->model->getArtHot(10); + $assignArr = [ 'ename'=>$ename, @@ -67,8 +60,6 @@ class Article extends BaseController 'type'=>$type, 'artList'=>$artList, 'artHot'=>$artHot, - 'ad_cateImg'=>$ad_cateImg, - 'ad_comm'=>$ad_comm, 'path'=>$path, 'jspage'=>'jie' ]; @@ -155,12 +146,6 @@ class Article extends BaseController $lrDate_time = Db::name('comment')->where('article_id', $id)->max('update_time',false) ?? time(); // 热议文章 $artHot = $this->model->getArtHot(10); - //广告 - $ad = new Slider(); - //分类图片 - $ad_artImg = $ad->getSliderList(4); - //分类钻展赞助 - $ad_comm = $ad->getSliderList(7); //push $push_js = Db::name('push_jscode')->where(['delete_time'=>0,'type'=>1])->cache(true)->select(); @@ -168,8 +153,6 @@ class Article extends BaseController 'article' => $artDetail, 'pv' => $pv, 'artHot' => $artHot, - 'ad_art' => $ad_artImg, - 'ad_comm' => $ad_comm, 'tags' => $tags, 'relationArticle' => $relationArticle, 'previous' => $previous, @@ -282,13 +265,11 @@ class Article extends BaseController $data['content'] = $this->downUrlPicsReaplace($data['content']); // 把中文,转换为英文,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); - + $data['description'] = strip_tags($this->filterEmoji($data['description'])); // 获取分类ename,appname $cateName = Db::name('cate')->field('ename,appname')->find($data['cate_id']); - $article = new ArticleModel(); - - $result = $article->add($data); + $result = $this->model->add($data); if ($result['code'] == 1) { // 获取到的最新ID $aid = $result['data']['id']; @@ -350,7 +331,7 @@ class Article extends BaseController */ public function edit($id) { - $article = ArticleModel::find($id); + $article = $this->model->find($id); if(Request::isAjax()){ $data = Request::only(['id','cate_id','title','title_color','read_type','art_pass','content','upzip','keywords','description','captcha']); @@ -377,8 +358,8 @@ class Article extends BaseController $data['content'] = $this->downUrlPicsReaplace($data['content']); // 把,转换为,并去空格->转为数组->去掉空数组->再转化为带,号的字符串 $data['keywords'] = implode(',',array_filter(explode(',',trim(str_replace(',',',',$data['keywords']))))); + $data['description'] = strip_tags($this->filterEmoji($data['description'])); - $result = $article->edit($data); if($result == 1) { //处理标签 @@ -436,7 +417,7 @@ class Article extends BaseController */ public function delete() { - $article = ArticleModel::find(input('id')); + $article = $this->model->find(input('id')); $result = $article->together(['comments'])->delete(); if($result) { return Msgres::success('delete_success'); @@ -509,7 +490,7 @@ class Article extends BaseController public function jieset() { $data = Request::param(); - $article = ArticleModel::field('id,is_top,is_hot,is_reply')->find($data['id']); + $article = $this->model->field('id,is_top,is_hot,is_reply')->find($data['id']); switch ($data['field']){ case 'top': if($data['rank']==1){ @@ -549,7 +530,7 @@ class Article extends BaseController public function titleColor() { $data = Request::param(); - $result = ArticleModel::update($data); + $result = $this->model->update($data); if($result){ //清除文章缓存 Cache::tag(['tagArt','tagArtDetail'])->clear(); diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 26ad43d..c16d8b2 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -15,7 +15,6 @@ use think\facade\View; use think\facade\Request; use think\facade\Db; use app\facade\Article; -use app\common\model\Slider; use app\common\lib\Msgres; class Index extends BaseController @@ -30,39 +29,19 @@ class Index extends BaseController public function index() { $types = input('type'); - - $slider = new Slider(); - //幻灯 - $sliders = Request::isMobile() ? $slider->getSliderList(12) : $slider->getSliderList(1); //置顶文章 $artTop = Article::getArtTop(5); //首页文章列表,显示20个 $artList = Article::getArtList(22); //热议文章 $artHot = Article::getArtHot(10); - //首页广告 - $indexAd = $slider->getSliderList(13); - //温馨通道 - $fast_links = $slider->getSliderList(8); - //首页赞助 - $ad_index = $slider->getSliderList(5); - //首页右栏图片 - $ad_comm = $slider->getSliderList(2); - //友情链接申请 - $adminEmail = Db::name('user')->where('id',1)->cache(true)->value('email'); $vs = [ - 'slider' => $sliders, 'artTop' => $artTop, 'artList' => $artList, 'artHot' => $artHot, - 'ad_index_r'=> $indexAd, 'type' => $types, - 'ad_index' => $ad_index, - 'ad_comm' => $ad_comm, - 'fastlinks' => $fast_links, - 'adminEmail' => $adminEmail, 'jspage' => '', ]; View::assign($vs); diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql index cc15936..2a53344 100644 --- a/app/install/data/taoler.sql +++ b/app/install/data/taoler.sql @@ -48,7 +48,7 @@ DROP TABLE IF EXISTS `tao_article`; CREATE TABLE `tao_article` ( `id` int NOT NULL AUTO_INCREMENT COMMENT '用户ID', `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标题', - `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容', + `content` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '内容', `status` enum('0','-1','1') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '1' COMMENT '状态1显示0待审-1禁止', `cate_id` int NOT NULL COMMENT '分类id', `user_id` int NOT NULL COMMENT '用户id', diff --git a/composer.lock b/composer.lock index 9d348f0..1e622c6 100644 --- a/composer.lock +++ b/composer.lock @@ -596,16 +596,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.9.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318" + "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", - "reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b", + "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b", "shasum": "", "mirrors": [ { @@ -630,11 +630,6 @@ "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, "autoload": { "files": [ "src/functions_include.php" @@ -692,7 +687,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.9.0" + "source": "https://github.com/guzzle/psr7/tree/1.9.1" }, "funding": [ { @@ -708,7 +703,7 @@ "type": "tidelift" } ], - "time": "2022-06-20T21:43:03+00:00" + "time": "2023-04-17T16:00:37+00:00" }, { "name": "jaeger/g-http", diff --git a/config/taoler.php b/config/taoler.php index 862cc02..5dbade8 100644 --- a/config/taoler.php +++ b/config/taoler.php @@ -16,7 +16,7 @@ return [ // 应用名,此项不可更改 'appname' => 'TaoLer', // 版本配置 - 'version' => '2.3.1', + 'version' => '2.3.2', // 加盐 'salt' => 'taoler', // 数据库备份目录 diff --git a/extend/taoler/com/Files.php b/extend/taoler/com/Files.php index 542b470..0242a2f 100644 --- a/extend/taoler/com/Files.php +++ b/extend/taoler/com/Files.php @@ -28,9 +28,10 @@ class Files $arr = array(); $data = scandir($path); foreach ($data as $value){ - if($value !='.' && $value != '..' && !stripos($value,".") && $value != '.gitignore'){ - $arr[] = strtolower($value); - } + if (in_array($value, ['.', '..','.gitignore'])) continue; + if(!stripos($value,".")) { + $arr[] = strtolower($value); + } } //return array_merge(array_diff($arr, array('install'))); return $arr; diff --git a/public/static/component/pear/module/imgcom.js b/public/static/component/pear/module/imgcom.js new file mode 100644 index 0000000..5b9822d --- /dev/null +++ b/public/static/component/pear/module/imgcom.js @@ -0,0 +1,111 @@ +/** + images压缩扩展模块 + changlin_zhao@qq.com + 2021.5.25 +**/ + +layui.define(['upload','layer'],function(exports){ +var upload = layui.upload; +var layer = layui.layer; +var compressImage = { + uploads: function(obj){ + //obj.preview(function(index, file, result){ + + //执行实例 + var files = obj.pushFile(); + var filesArry = []; + for (var key in files) { //将上传的文件转为数组形式 + filesArry.push(files[key]) + } + var index = filesArry.length - 1; + var file = filesArry[index]; //获取最后选择的图片,即处理多选情况 + + if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1] + .replace(/[ ]/g, "").replace("MSIE", "")) < 9) { + return obj.upload(index, file) + } + canvasDataURL(file, function (blob) { + var aafile = new File([blob], file.name, { + type: file.type + }) + var isLt1M; + if (file.size < aafile.size) { + isLt1M = file.size + } else { + isLt1M = aafile.size + } + + if (isLt1M / 1024 / 1024 > 2) { + return layer.alert('上传图片过大!') + } else { + if (file.size < aafile.size) { + return obj.upload(index, file) + } + obj.upload(index, aafile) + } + }) + + + + + function canvasDataURL(file, callback) { //压缩转化为base64 + var reader = new FileReader() + reader.readAsDataURL(file) + reader.onload = function (e) { + const img = new Image() + const quality = 0.8 // 图像质量 + const canvas = document.createElement('canvas') + const drawer = canvas.getContext('2d') + img.src = this.result + img.onload = function () { + + var originWidth = img.width,/* 图片的宽度 */ + originHeight = img.height; /* 图片的高度 */ + + // 设置最大尺寸限制,将所有图片都压缩到小于1m + const maxWidth = 2560, maxHeight = 1600; + // 需要压缩的目标尺寸 + let targetWidth = originWidth, targetHeight = originHeight; + // 等比例计算超过最大限制时缩放后的图片尺寸 + if (originWidth > maxWidth || originHeight > maxHeight) { + if (originWidth / originHeight > 1) { + // 宽图片 + targetWidth = maxWidth; + targetHeight = Math.round(maxWidth * (originHeight / originWidth)); + } else { + // 高图片 + targetHeight = maxHeight; + targetWidth = Math.round(maxHeight * (originWidth / originHeight)); + } + } + + canvas.width = targetWidth; + canvas.height = targetHeight; + drawer.drawImage(img, 0, 0, canvas.width, canvas.height) + convertBase64UrlToBlob(canvas.toDataURL(file.type, quality), callback); + } + } + } + + function convertBase64UrlToBlob(urlData, callback) { //将base64转化为文件格式 + const arr = urlData.split(',') + const mime = arr[0].match(/:(.*?);/)[1] + const bstr = atob(arr[1]) + let n = bstr.length + const u8arr = new Uint8Array(n) + while (n--) { + u8arr[n] = bstr.charCodeAt(n) + } + callback(new Blob([u8arr], { + type: mime + })); + } + + + //}) + } + } + //输出 imgcom 接口 + exports('imgcom', compressImage); +}); + diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 477fffd..94b6426 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -578,18 +578,24 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.9.0", - "version_normalized": "1.9.0.0", + "version": "1.9.1", + "version_normalized": "1.9.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318" + "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", - "reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", - "shasum": "" + "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b", + "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { "php": ">=5.4.0", @@ -606,13 +612,8 @@ "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, - "time": "2022-06-20T21:43:03+00:00", + "time": "2023-04-17T16:00:37+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, "installation-source": "dist", "autoload": { "files": [ @@ -671,7 +672,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.9.0" + "source": "https://github.com/guzzle/psr7/tree/1.9.1" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index da2ca92..f663b46 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'taoser/taoler', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'eddc6843101a94454f9333fb993cff1741007b42', + 'reference' => '2aa133f33d26cc3d1dba9eb687b1744690f4026c', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -83,9 +83,9 @@ 'dev_requirement' => false, ), 'guzzlehttp/psr7' => array( - 'pretty_version' => '1.9.0', - 'version' => '1.9.0.0', - 'reference' => 'e98e3e6d4f86621a9b75f623996e6bbdeb4b9318', + 'pretty_version' => '1.9.1', + 'version' => '1.9.1.0', + 'reference' => 'e4490cabc77465aaee90b20cfc9a770f8c04be6b', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), @@ -349,7 +349,7 @@ 'taoser/taoler' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'eddc6843101a94454f9333fb993cff1741007b42', + 'reference' => '2aa133f33d26cc3d1dba9eb687b1744690f4026c', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml b/vendor/guzzlehttp/psr7/.github/workflows/ci.yml index eda7dce..0850470 100644 --- a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml +++ b/vendor/guzzlehttp/psr7/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: jobs: build: name: Build - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: max-parallel: 10 matrix: @@ -21,11 +21,7 @@ jobs: extensions: mbstring - name: Checkout code - uses: actions/checkout@v2 - - - name: Mimic PHP 8.0 - run: composer config platform.php 8.0.999 - if: matrix.php > 8 + uses: actions/checkout@v3 - name: Install dependencies run: composer update --no-interaction --no-progress diff --git a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml b/vendor/guzzlehttp/psr7/.github/workflows/integration.yml index 3c31f9e..a55a256 100644 --- a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml +++ b/vendor/guzzlehttp/psr7/.github/workflows/integration.yml @@ -4,14 +4,13 @@ on: pull_request: jobs: - build: name: Test - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: max-parallel: 10 matrix: - php: ['7.2', '7.3', '7.4', '8.0'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Set up PHP @@ -21,7 +20,7 @@ jobs: coverage: none - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download dependencies uses: ramsey/composer-install@v1 diff --git a/vendor/guzzlehttp/psr7/.github/workflows/static.yml b/vendor/guzzlehttp/psr7/.github/workflows/static.yml index ab4d68b..f00351b 100644 --- a/vendor/guzzlehttp/psr7/.github/workflows/static.yml +++ b/vendor/guzzlehttp/psr7/.github/workflows/static.yml @@ -6,11 +6,11 @@ on: jobs: php-cs-fixer: name: PHP-CS-Fixer - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md index b4fdf3c..9b2b65c 100644 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 1.9.1 - 2023-04-17 + +### Fixed + +- Fixed header validation issue + ## 1.9.0 - 2022-06-20 ### Added diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json index 0e36920..2607f22 100644 --- a/vendor/guzzlehttp/psr7/composer.json +++ b/vendor/guzzlehttp/psr7/composer.json @@ -61,11 +61,6 @@ "GuzzleHttp\\Tests\\Psr7\\": "tests/" } }, - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, "config": { "preferred-install": "dist", "sort-packages": true, diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php index 0ac8663..0bbd63e 100644 --- a/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -226,12 +226,9 @@ trait MessageTrait throw new \InvalidArgumentException('Header name can not be empty.'); } - if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) { + if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { throw new \InvalidArgumentException( - sprintf( - '"%s" is not valid header name', - $header - ) + sprintf('"%s" is not valid header name.', $header) ); } } @@ -263,8 +260,10 @@ trait MessageTrait // Clients must not send a request with line folding and a server sending folded headers is // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting // folding is not likely to break any legitimate use case. - if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) { - throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value)); + if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header value.', $value) + ); } } } diff --git a/vendor/services.php b/vendor/services.php index c2b7e4e..98eb61c 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'taoser\\addons\\Service', diff --git a/view/taoler/index/article/ask/cate.html b/view/taoler/index/article/ask/cate.html index aa48744..fa4db84 100644 --- a/view/taoler/index/article/ask/cate.html +++ b/view/taoler/index/article/ask/cate.html @@ -25,55 +25,50 @@
{:getArtContent($art.content)}
+{:getArtContent($article.content)}