From c440d9561ac9326824e1df484fc43aee55e123d0 Mon Sep 17 00:00:00 2001 From: liyukun <1099438829@qq.com> Date: Sun, 27 Jun 2021 23:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Category.php | 24 ++++++--- app/common.php | 4 +- app/common/model/PvLog.php | 6 +-- app/common/model/UrlLog.php | 1 - app/common/taglib/Zz.php | 1 - app/index/common.php | 54 +++++++++------------ app/index/controller/Base.php | 17 ++++--- config/app.php | 2 - public/template/default/pc/index/index.html | 4 +- 9 files changed, 55 insertions(+), 58 deletions(-) diff --git a/app/admin/controller/Category.php b/app/admin/controller/Category.php index d3e1360..5227b4f 100644 --- a/app/admin/controller/Category.php +++ b/app/admin/controller/Category.php @@ -110,10 +110,14 @@ class Category extends AuthController */ public function add($pid ='') { - $systemConfig = cache('systemConfig'); - $themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$systemConfig['web_template']).'info.json'; - $themeInfo = json_decode(file_get_contents($themeInfoFile),true); - $themeList = $themeInfo['category_list']; + $templatePath = system_config('web_template'); + $themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$templatePath).'info.json'; + if (file_exists($themeInfoFile)){ + $themeInfo = json_decode(file_get_contents($themeInfoFile),true); + $themeList = $themeInfo['category_list']; + }else{ + $themeList = []; + } $where = Util::postMore([ 'name' => '', 'status' => '', @@ -135,10 +139,14 @@ class Category extends AuthController */ public function edit(Request $request) { - $systemConfig = cache('systemConfig'); - $themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$systemConfig['web_template']).'info.json'; - $themeInfo = json_decode(file_get_contents($themeInfoFile),true); - $themeList = $themeInfo['category_list']; + $templatePath = system_config('web_template'); + $themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$templatePath).'info.json'; + if (file_exists($themeInfoFile)){ + $themeInfo = json_decode(file_get_contents($themeInfoFile),true); + $themeList = $themeInfo['category_list']; + }else{ + $themeList = []; + } $where = Util::postMore([ 'name' => '', 'status' => '', diff --git a/app/common.php b/app/common.php index 7d07346..31efc1c 100644 --- a/app/common.php +++ b/app/common.php @@ -15,7 +15,7 @@ if (!function_exists('system_config_more')) { $systemConfig = cache('systemConfig'); if (empty($systemConfig)){ - $systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues(); + $systemConfig = \app\common\model\SystemConfig::getSystemConfigValues(); cache('systemConfig',$systemConfig); } $data = []; @@ -75,7 +75,7 @@ if (!function_exists('system_config')) { $systemConfig = cache('systemConfig'); if (empty($systemConfig)){ - $systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues(); + $systemConfig = \app\common\model\SystemConfig::getSystemConfigValues(); cache('systemConfig',$systemConfig); } return $systemConfig[$formName]??''; diff --git a/app/common/model/PvLog.php b/app/common/model/PvLog.php index 2d0cfe8..7b98bf7 100644 --- a/app/common/model/PvLog.php +++ b/app/common/model/PvLog.php @@ -43,8 +43,7 @@ class PvLog extends BaseModel { $pvData['view'] = 1; $pvData['date'] = $date_data; $pvData['time'] = $hour; - $pvData['create_time'] = time(); - $this->insertGetId($pvData); + $this->save($pvData); } //uv表 $uvLogModel=new UvLogModel(); @@ -61,8 +60,7 @@ class PvLog extends BaseModel { $uvData['ip'] = $ipData; $uvData['time'] = $hour; $uvData['date'] = $date_data; - $uvData['create_time'] = time(); - $uvLogModel->insertGetId($uvData); + $uvLogModel->save($uvData); } } diff --git a/app/common/model/UrlLog.php b/app/common/model/UrlLog.php index 3ccfa55..8ffed87 100644 --- a/app/common/model/UrlLog.php +++ b/app/common/model/UrlLog.php @@ -25,7 +25,6 @@ class UrlLog extends BaseModel { $dataUrl['pv'] = 1; $dataUrl['title'] = $title; $dataUrl['date'] = $date_data; - $dataUrl['create_time'] = time(); $this->insertGetId($dataUrl); } } diff --git a/app/common/taglib/Zz.php b/app/common/taglib/Zz.php index 26d1da8..d245c92 100644 --- a/app/common/taglib/Zz.php +++ b/app/common/taglib/Zz.php @@ -136,7 +136,6 @@ class Zz extends TagLib{ $where=isset($tag['where'])?$tag['where']:''; $display=isset($tag['display'])?$tag['display']:1; $display=$display==1?1:0; - $parse = 'render();'; diff --git a/app/index/common.php b/app/index/common.php index 96cc5d2..c8af40b 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -286,7 +286,7 @@ function tpl_get_prenext($get,$cid=false,$none){ */ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=false,$display=1){ - $docmentListModel=Db::name('document') + $documentListModel= (new \app\common\model\Document()) ->alias('a') ->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT') ->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT') @@ -294,12 +294,9 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals ->where('a.status',1) ->where('b.status',1) ->field('a.*,b.title as category_title,c.*'); - if($display){ - $docmentListModel=$docmentListModel->where('a.display',1); + $documentListModel=$documentListModel->where('a.display',1); } - - //判断当前是否搜索页面 if(request()->action()=='search'){ $type='search'; @@ -310,58 +307,55 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals $dc=get_document_category($cid); $child=$dc['child']; if($child){ - $docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child"); + $documentListModel=$documentListModel->where('a.category_id','in',"$cid,$child"); } else{ - $docmentListModel=$docmentListModel->where('a.category_id',$cid); + $documentListModel=$documentListModel->where('a.category_id',$cid); } break; case 'son': //获取栏目下文章 - $docmentListModel=$docmentListModel->where('a.category_id',$cid); + $documentListModel=$documentListModel->where('a.category_id',$cid); break; case 'search': //获取关键字搜索的文章 $kw=input('kw'); //搜索关键词 $tid=input('cid');//文章分类Id if($kw){ - $docmentListModel=$docmentListModel->where('a.title','like',"%$kw%"); + $documentListModel=$documentListModel->where('a.title','like',"%$kw%"); } if($tid){ - $docmentListModel=$docmentListModel->where('a.category_id',$tid); + $documentListModel=$documentListModel->where('a.category_id',$tid); } break; case 'where': //根据自定义条件获取文章(where语句) - $docmentListModel=$docmentListModel->where($where); + $documentListModel=$documentListModel->where($where); break; case 'tag': //读取指定tag的文章 - $docmentListModel=$docmentListModel->where('a.keywords','like',"%$where%"); + $documentListModel=$documentListModel->where('a.keywords','like',"%$where%"); break; } - - $docmentListModel=$docmentListModel->order($orderby); + $documentListModel=$documentListModel->order($orderby); //获取当前请求的请求参数,以确定分页是否要带上这些请求参数 $query=request()->query(); if($query){ - $docmentListModel=$docmentListModel->paginate($pagesize,false,['query' => getRouteQuery()]); + $documentListModel=$documentListModel->paginate($pagesize,false,['query' => getRouteQuery()]); } else{ - $docmentListModel=$docmentListModel->paginate($pagesize); + $documentListModel=$documentListModel->paginate($pagesize); } $lists=[]; - foreach ($docmentListModel as $key=>$item){ + foreach ($documentListModel as $key=>$item){ //生成文章url $item['url']=aurl($item); $lists[$key]=$item; } - $re=[ - 'model'=>$docmentListModel, + 'model'=>$documentListModel, 'lists'=>$lists ]; - return $re; } @@ -439,7 +433,7 @@ function tpl_get_article($id,$table){ */ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$where=false,$display=1,$ids=''){ - $docmentListModel=Db::name('document') + $documentListModel=Db::name('document') ->alias('a') ->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT') ->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT') @@ -448,7 +442,7 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w ->field('a.*,b.title as category_title,c.*'); if($display){ - $docmentListModel=$docmentListModel->where('a.display',1); + $documentListModel=$documentListModel->where('a.display',1); } switch ($type){ @@ -457,33 +451,33 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w $dc=get_document_category($cid); $child=$dc['child']; if($child){ - $docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child"); + $documentListModel=$documentListModel->where('a.category_id','in',"$cid,$child"); } else{ - $docmentListModel=$docmentListModel->where('a.category_id',$cid); + $documentListModel=$documentListModel->where('a.category_id',$cid); } break; case 'son': //获取栏目下文章 - $docmentListModel=$docmentListModel->where('a.category_id',$cid); + $documentListModel=$documentListModel->where('a.category_id',$cid); break; case 'where': //根据自定义条件获取文章(where语句) - $docmentListModel=$docmentListModel->where($where); + $documentListModel=$documentListModel->where($where); break; case 'ids': //读取指定id的文章 - $docmentListModel=$docmentListModel->where('a.id','in',$ids); + $documentListModel=$documentListModel->where('a.id','in',$ids); break; case 'tag': //读取指定tag的文章 - $docmentListModel=$docmentListModel->where('a.keywords','like',"%$where%"); + $documentListModel=$documentListModel->where('a.keywords','like',"%$where%"); break; } - $docmentListModel=$docmentListModel->order($orderby)->select(); + $documentListModel=$documentListModel->order($orderby)->select(); $lists=[]; - foreach ($docmentListModel as $key=>$item){ + foreach ($documentListModel as $key=>$item){ //生成文章url $item['url']=aurl($item); $lists[$key]=$item; diff --git a/app/index/controller/Base.php b/app/index/controller/Base.php index 0ffebd3..4e7c73e 100644 --- a/app/index/controller/Base.php +++ b/app/index/controller/Base.php @@ -5,7 +5,6 @@ namespace app\index\controller; use app\BaseController; use app\common\model\PvLog; use app\common\model\UrlLog; -use app\common\model\UvLog; use app\common\model\SystemConfig; /** @@ -32,15 +31,14 @@ class Base extends BaseController } //判断后台统计配置是否开启 1 开启 if ($systemConfig["web_statistics"] == 1) { - //增加pv信息 - (new PvLog())->addLog(); - //增加uv信息 - (new UvLog())->addLog(); + //pv表 zz_pv_log 栏目存在 点击进入页面后 + $pvLogModel=new PvLog(); + $pvLogModel->set_view(); } //判断是否开启了伪静态 - if ($systemConfig['web_rewrite']) { + if ($systemConfig['web_rewrite']=='0') { $this->request->setRoot('/?s='); - } elseif(web_config('WEB_REWRITE')=='1') { + } elseif($systemConfig['web_rewrite']=='1') { $this->request->setRoot('/'); } else { $this->request->setRoot('/index.php'); @@ -55,6 +53,9 @@ class Base extends BaseController */ protected function urlrecord($title) { - (new UrlLog())->addLog($title); + $urlLogModel=new UrlLog(); + //获取url + $urlInfo = $this->request->url(true); + $urlLogModel->set_url($title,$urlInfo); } } \ No newline at end of file diff --git a/config/app.php b/config/app.php index 3ba1bc0..313fc2a 100644 --- a/config/app.php +++ b/config/app.php @@ -22,8 +22,6 @@ return [ 'app_express' => true, // 默认时区 'default_timezone' => 'Asia/Shanghai', - // 快捷访问 - 'app_express' => true, // 自动多应用模式 'auto_multi_app' => true, // 应用映射(自动多应用模式有效) diff --git a/public/template/default/pc/index/index.html b/public/template/default/pc/index/index.html index 4458d59..696abfa 100644 --- a/public/template/default/pc/index/index.html +++ b/public/template/default/pc/index/index.html @@ -57,7 +57,7 @@
- {zz:list orderby="create_time desc"} + {zz:list orderby="create_time desc" type="where"}
@@ -81,7 +81,7 @@
    - {zz:list orderby="create_time desc"} + {zz:list orderby="create_time desc" type="where"}