From 2b4328baef2d5e509d73385e92949b6eab3ad4a5 Mon Sep 17 00:00:00 2001 From: liyukun <1099438829@qq.com> Date: Sat, 26 Jun 2021 15:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/config/session.php | 1 - app/admin/controller/Admin.php | 4 +- app/admin/controller/AdminAuth.php | 2 +- app/admin/controller/AdminIcon.php | 16 ---- app/admin/controller/AdminLog.php | 2 +- app/admin/controller/AdminNotify.php | 2 +- app/admin/controller/AdminRole.php | 4 +- app/admin/controller/Article.php | 6 +- app/admin/controller/AuthController.php | 4 +- app/admin/controller/Category.php | 4 +- app/admin/controller/Files.php | 2 +- app/admin/controller/FriendLink.php | 2 +- app/admin/controller/Images.php | 4 +- app/admin/controller/Index.php | 4 +- app/admin/controller/Invitation.php | 2 +- app/admin/controller/Login.php | 4 +- app/admin/controller/Slides.php | 2 +- app/admin/controller/SystemConfig.php | 4 +- app/admin/controller/SystemConfigTab.php | 4 +- app/admin/controller/Theme.php | 2 +- app/admin/controller/User.php | 2 +- app/admin/subscribes/AdminSubscribe.php | 2 +- app/common/exceptions/AuthException.php | 15 --- app/common/interfaces/MiddlewareInterface.php | 16 ---- .../middleware/AllowOriginMiddleware.php | 35 ------- app/common/middleware/AuthTokenMiddleware.php | 49 ---------- app/{admin => common}/model/Admin.php | 2 +- app/{admin => common}/model/AdminAuth.php | 2 +- app/{admin => common}/model/AdminLog.php | 2 +- app/{admin => common}/model/AdminNotify.php | 2 +- app/{admin => common}/model/AdminRole.php | 2 +- app/{admin => common}/model/Attachment.php | 2 +- .../model/AttachmentCategory.php | 2 +- app/{admin => common}/model/BaseModel.php | 2 +- app/{admin => common}/model/Document.php | 2 +- .../model/DocumentArticle.php | 2 +- .../model/DocumentCategory.php | 2 +- .../model/DocumentCategoryContent.php | 2 +- .../model/DocumentProduct.php | 2 +- app/{admin => common}/model/FriendLink.php | 2 +- .../model/InvitationCode.php | 2 +- app/{admin => common}/model/MessageForm.php | 2 +- app/{admin => common}/model/ModelTrait.php | 2 +- app/{admin => common}/model/Slides.php | 2 +- app/{admin => common}/model/SystemConfig.php | 2 +- .../model/SystemConfigTab.php | 2 +- app/{admin => common}/model/User.php | 2 +- app/common/taglib/Zz.php | 7 +- app/common/validate/AdminMemberEdit.php | 30 ++++++ app/common/validate/AdminMenu.php | 6 +- app/common/validate/Adminaction.php | 6 +- app/common/validate/Adminauthgroup.php | 12 +-- app/common/validate/Adminmember.php | 12 +-- app/common/validate/Config.php | 6 +- app/common/validate/Document.php | 93 ++++++++++-------- app/common/validate/Documentcategory.php | 71 ++++++-------- app/common/validate/Friendlink.php | 9 +- app/common/validate/Messageform.php | 6 +- app/index/common.php | 95 ++++++++----------- app/index/controller/Article.php | 6 +- app/index/controller/Base.php | 7 +- app/index/model/Document.php | 17 ---- app/index/model/DocumentArticle.php | 36 ------- app/index/model/DocumentCategory.php | 17 ---- app/index/model/DocumentCategoryContent.php | 17 ---- app/index/model/DocumentProduct.php | 17 ---- app/index/model/FriendLink.php | 17 ---- app/index/model/MessageForm.php | 17 ---- app/index/model/PvLog.php | 50 ---------- app/index/model/Slides.php | 17 ---- app/index/model/UrlLog.php | 50 ---------- app/index/model/UvLog.php | 51 ---------- config/app.php | 12 ++- public/template/default/pc/index/index.html | 4 +- 74 files changed, 247 insertions(+), 677 deletions(-) delete mode 100644 app/admin/controller/AdminIcon.php delete mode 100644 app/common/exceptions/AuthException.php delete mode 100644 app/common/interfaces/MiddlewareInterface.php delete mode 100644 app/common/middleware/AllowOriginMiddleware.php delete mode 100644 app/common/middleware/AuthTokenMiddleware.php rename app/{admin => common}/model/Admin.php (99%) rename app/{admin => common}/model/AdminAuth.php (99%) rename app/{admin => common}/model/AdminLog.php (98%) rename app/{admin => common}/model/AdminNotify.php (98%) rename app/{admin => common}/model/AdminRole.php (99%) rename app/{admin => common}/model/Attachment.php (97%) rename app/{admin => common}/model/AttachmentCategory.php (99%) rename app/{admin => common}/model/BaseModel.php (98%) rename app/{admin => common}/model/Document.php (97%) rename app/{admin => common}/model/DocumentArticle.php (96%) rename app/{admin => common}/model/DocumentCategory.php (98%) rename app/{admin => common}/model/DocumentCategoryContent.php (96%) rename app/{admin => common}/model/DocumentProduct.php (96%) rename app/{admin => common}/model/FriendLink.php (97%) rename app/{admin => common}/model/InvitationCode.php (97%) rename app/{admin => common}/model/MessageForm.php (98%) rename app/{admin => common}/model/ModelTrait.php (99%) rename app/{admin => common}/model/Slides.php (97%) rename app/{admin => common}/model/SystemConfig.php (99%) rename app/{admin => common}/model/SystemConfigTab.php (95%) rename app/{admin => common}/model/User.php (99%) create mode 100644 app/common/validate/AdminMemberEdit.php delete mode 100644 app/index/model/Document.php delete mode 100644 app/index/model/DocumentArticle.php delete mode 100644 app/index/model/DocumentCategory.php delete mode 100644 app/index/model/DocumentCategoryContent.php delete mode 100644 app/index/model/DocumentProduct.php delete mode 100644 app/index/model/FriendLink.php delete mode 100644 app/index/model/MessageForm.php delete mode 100644 app/index/model/PvLog.php delete mode 100644 app/index/model/Slides.php delete mode 100644 app/index/model/UrlLog.php delete mode 100644 app/index/model/UvLog.php diff --git a/app/admin/config/session.php b/app/admin/config/session.php index bbb966d..c4fdf6f 100644 --- a/app/admin/config/session.php +++ b/app/admin/config/session.php @@ -7,5 +7,4 @@ return [ // 过期时间 'expire' => 1440, // 前缀 - 'prefix' => 'zz_admin', ]; diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index 44019bb..4c7741e 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\Admin as aModel; -use app\admin\model\AdminRole as rModel; +use app\common\model\Admin as aModel; +use app\common\model\AdminRole as rModel; use app\Request; use app\admin\services\UtilService as Util; use FormBuilder\Factory\Elm; diff --git a/app/admin/controller/AdminAuth.php b/app/admin/controller/AdminAuth.php index 538cfb1..acf0f3b 100644 --- a/app/admin/controller/AdminAuth.php +++ b/app/admin/controller/AdminAuth.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\AdminAuth as aModel; +use app\common\model\AdminAuth as aModel; use app\Request; use FormBuilder\Exception\FormBuilderException; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/AdminIcon.php b/app/admin/controller/AdminIcon.php deleted file mode 100644 index c5697de..0000000 --- a/app/admin/controller/AdminIcon.php +++ /dev/null @@ -1,16 +0,0 @@ -fetch(); - } -} \ No newline at end of file diff --git a/app/admin/controller/AdminLog.php b/app/admin/controller/AdminLog.php index e038d6c..6fd27e4 100644 --- a/app/admin/controller/AdminLog.php +++ b/app/admin/controller/AdminLog.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\AdminLog as lModel; +use app\common\model\AdminLog as lModel; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/AdminNotify.php b/app/admin/controller/AdminNotify.php index d7b2fef..0afd7bd 100644 --- a/app/admin/controller/AdminNotify.php +++ b/app/admin/controller/AdminNotify.php @@ -3,7 +3,7 @@ namespace app\admin\controller; use app\admin\services\UtilService as Util; -use app\admin\model\AdminNotify as nModel; +use app\common\model\AdminNotify as nModel; /** * 消息提醒 * Class AdminNotify diff --git a/app/admin/controller/AdminRole.php b/app/admin/controller/AdminRole.php index b624abd..0907097 100644 --- a/app/admin/controller/AdminRole.php +++ b/app/admin/controller/AdminRole.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\AdminRole as rModel; -use app\admin\model\AdminAuth as aModel; +use app\common\model\AdminRole as rModel; +use app\common\model\AdminAuth as aModel; use app\Request; use FormBuilder\Exception\FormBuilderException; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index e87d10b..8cfffc5 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -2,9 +2,9 @@ namespace app\admin\controller; -use app\admin\model\Document as aModel; -use app\admin\model\DocumentCategory as cModel; -use app\admin\model\DocumentArticle; +use app\common\model\Document as aModel; +use app\common\model\DocumentCategory as cModel; +use app\common\model\DocumentArticle; use app\Request; use app\admin\services\UtilService as Util; use think\Exception; diff --git a/app/admin/controller/AuthController.php b/app/admin/controller/AuthController.php index 6bf63d0..27e1bcd 100644 --- a/app/admin/controller/AuthController.php +++ b/app/admin/controller/AuthController.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\AdminAuth; -use app\admin\model\AdminRole; +use app\common\model\AdminAuth; +use app\common\model\AdminRole; use think\facade\App; use think\facade\Lang; use think\facade\Session; diff --git a/app/admin/controller/Category.php b/app/admin/controller/Category.php index cd04a64..d3e1360 100644 --- a/app/admin/controller/Category.php +++ b/app/admin/controller/Category.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\DocumentCategory as aModel; -use app\admin\model\DocumentCategoryContent; +use app\common\model\DocumentCategory as aModel; +use app\common\model\DocumentCategoryContent; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/Files.php b/app/admin/controller/Files.php index 77edded..c9eb696 100644 --- a/app/admin/controller/Files.php +++ b/app/admin/controller/Files.php @@ -3,7 +3,7 @@ namespace app\admin\controller; -use app\admin\model\Attachment; +use app\common\model\Attachment; use app\admin\services\storage\QcloudCoService; use app\admin\services\UtilService as Util; use think\exception\ValidateException; diff --git a/app/admin/controller/FriendLink.php b/app/admin/controller/FriendLink.php index 9cb0448..992aab1 100644 --- a/app/admin/controller/FriendLink.php +++ b/app/admin/controller/FriendLink.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\FriendLink as aModel; +use app\common\model\FriendLink as aModel; use app\admin\services\FormBuilderService as Form; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/Images.php b/app/admin/controller/Images.php index 8fffefc..2ccf583 100644 --- a/app/admin/controller/Images.php +++ b/app/admin/controller/Images.php @@ -3,8 +3,8 @@ namespace app\admin\controller; -use app\admin\model\Attachment; -use app\admin\model\AttachmentCategory; +use app\common\model\Attachment; +use app\common\model\AttachmentCategory; use FormBuilder\Factory\Elm; use app\admin\services\FormBuilderService as Form; use app\admin\services\storage\QcloudCoService; diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index f65e15a..914cdb5 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\AdminAuth; -use app\admin\model\AdminNotify; +use app\common\model\AdminAuth; +use app\common\model\AdminNotify; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/Invitation.php b/app/admin/controller/Invitation.php index 616c65a..e5168d5 100644 --- a/app/admin/controller/Invitation.php +++ b/app/admin/controller/Invitation.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\InvitationCode as aModel; +use app\common\model\InvitationCode as aModel; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index a6cf0f1..d132fe5 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -3,8 +3,8 @@ namespace app\admin\controller; -use app\admin\model\Admin; -use app\admin\model\Admin as adminModel; +use app\common\model\Admin; +use app\common\model\Admin as adminModel; use app\admin\services\UtilService as Util; class Login extends AuthController diff --git a/app/admin/controller/Slides.php b/app/admin/controller/Slides.php index 81e36de..1411080 100644 --- a/app/admin/controller/Slides.php +++ b/app/admin/controller/Slides.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\Slides as aModel; +use app\common\model\Slides as aModel; use app\admin\services\FormBuilderService as Form; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/SystemConfig.php b/app/admin/controller/SystemConfig.php index ede4156..a32b615 100644 --- a/app/admin/controller/SystemConfig.php +++ b/app/admin/controller/SystemConfig.php @@ -2,8 +2,8 @@ namespace app\admin\controller; -use app\admin\model\SystemConfig as cModel; -use app\admin\model\SystemConfigTab as tModel; +use app\common\model\SystemConfig as cModel; +use app\common\model\SystemConfigTab as tModel; use app\Request; use FormBuilder\Factory\Elm; use app\admin\services\FormBuilderService as Form; diff --git a/app/admin/controller/SystemConfigTab.php b/app/admin/controller/SystemConfigTab.php index e91f117..65122ff 100644 --- a/app/admin/controller/SystemConfigTab.php +++ b/app/admin/controller/SystemConfigTab.php @@ -7,8 +7,8 @@ use app\Request; use FormBuilder\Factory\Elm; use app\admin\services\FormBuilderService as Form; use app\admin\services\UtilService as Util; -use app\admin\model\SystemConfigTab as tModel; -use app\admin\model\SystemConfig as cModel; +use app\common\model\SystemConfigTab as tModel; +use app\common\model\SystemConfig as cModel; /** * 管理员配置 diff --git a/app/admin/controller/Theme.php b/app/admin/controller/Theme.php index 08ba7fc..cfd793b 100644 --- a/app/admin/controller/Theme.php +++ b/app/admin/controller/Theme.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\SystemConfig as cModel; +use app\common\model\SystemConfig as cModel; use app\Request; use app\admin\services\UtilService as Util; diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index d19348d..02d9f36 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -2,7 +2,7 @@ namespace app\admin\controller; -use app\admin\model\User as aModel; +use app\common\model\User as aModel; use app\Request; use app\admin\services\UtilService as Util; use FormBuilder\Factory\Elm; diff --git a/app/admin/subscribes/AdminSubscribe.php b/app/admin/subscribes/AdminSubscribe.php index 83c215b..213151c 100644 --- a/app/admin/subscribes/AdminSubscribe.php +++ b/app/admin/subscribes/AdminSubscribe.php @@ -3,7 +3,7 @@ namespace app\admin\subscribes; -use app\admin\model\AdminLog; +use app\common\model\AdminLog; /** * 操作员日志记录 diff --git a/app/common/exceptions/AuthException.php b/app/common/exceptions/AuthException.php deleted file mode 100644 index b22a5e3..0000000 --- a/app/common/exceptions/AuthException.php +++ /dev/null @@ -1,15 +0,0 @@ -isOptions()) { - $response = Response::create("ok"); - } else { - $response = $next($request); - } - return $response; - } -} \ No newline at end of file diff --git a/app/common/middleware/AuthTokenMiddleware.php b/app/common/middleware/AuthTokenMiddleware.php deleted file mode 100644 index 64e1bf3..0000000 --- a/app/common/middleware/AuthTokenMiddleware.php +++ /dev/null @@ -1,49 +0,0 @@ -header('Authori-zation'); - if(!$token) $token = $request->header('Authorization'); - try { - $authInfo = User::parseToken($token); - } catch (AuthException $e) { - if ($force) - return app('json')->make($e->getCode(), $e->getMessage()); - } - if (!is_null($authInfo)) { - Request::macro('user', function () use (&$authInfo) { - return $authInfo; - }); - } - Request::macro('isLogin', function () use (&$authInfo) { - return !is_null($authInfo); - }); - Request::macro('uid', function () use (&$authInfo) { - return is_null($authInfo) ? 0 : $authInfo['uid']; - }); - return $next($request); - } -} \ No newline at end of file diff --git a/app/admin/model/Admin.php b/app/common/model/Admin.php similarity index 99% rename from app/admin/model/Admin.php rename to app/common/model/Admin.php index 2ce3fdd..865cce9 100644 --- a/app/admin/model/Admin.php +++ b/app/common/model/Admin.php @@ -1,7 +1,7 @@ ['attr' => 'typeid,orderby,row,void,model,type,where,display,ids,limit', 'close' => 1], 'type'=> ['attr' => 'typeid', 'close' => 1], 'list'=> ['attr' => 'orderby,pagesize,type,typeid,void,model,where,display', 'close' => 1], - 'prenext'=> ['attr' => 'get,cid,void', 'close' => 1], + 'prenext'=> ['attr' => 'get,cid,void,none', 'close' => 1], 'flink'=> ['attr' => 'type,row,void', 'close' => 1], 'banner'=> ['attr' => 'type,row,void', 'close' => 1], 'sql'=> ['attr' => 'sql', 'close' => 1], @@ -40,7 +40,7 @@ class Zz extends TagLib{ $row=isset($tag['row'])?$tag['row']:100; $void=isset($tag['void'])?$tag['void']:'field'; $where=isset($tag['where'])?$tag['where']:''; - $orderby=isset($tag['orderby'])?$tag['orderby']:'sort desc'; + $orderby=isset($tag['orderby'])?$tag['orderby']:'sort asc'; $display=isset($tag['display'])?$tag['display']:1; $display=$display==1?1:0; @@ -157,9 +157,10 @@ class Zz extends TagLib{ $get=isset($tag['get'])?$tag['get']:'pre'; $cid=isset($tag['cid'])?$tag['cid']:'$cid'; $void=isset($tag['void'])?$tag['void']:'field'; + $none=isset($tag['none'])?$tag['none']:'没有了'; $parse = ''; $parse .= '{volist name="__LIST__" id="'.$void.'"}'; $parse .= $content; diff --git a/app/common/validate/AdminMemberEdit.php b/app/common/validate/AdminMemberEdit.php new file mode 100644 index 0000000..ba3823b --- /dev/null +++ b/app/common/validate/AdminMemberEdit.php @@ -0,0 +1,30 @@ + 'require|max:16', + 'nickname' => 'max:10', + ]; + + protected $message = [ + 'username.require' => '请输入用户名', + 'username.max' => '用户名最多不能超过16个字符', + 'nickname.max' => '用户名最多不能超过10个字符', + ]; + +} diff --git a/app/common/validate/AdminMenu.php b/app/common/validate/AdminMenu.php index 34f38a1..cdcd4c5 100644 --- a/app/common/validate/AdminMenu.php +++ b/app/common/validate/AdminMenu.php @@ -1,10 +1,10 @@ 'require|max:30', 'title' => 'require|max:80', 'remark' => 'max:140', - 'type' => 'number', - 'status' => 'number', + ]; protected $message = [ @@ -30,8 +29,7 @@ class Adminaction extends Validate { 'title.max' => '行为名称最多输入80个字符', 'name.max' => '行为标识最多输入30个字符', 'remark.max' => '行为描述最多输入140个字符', - 'type.number' => '行为类型只能为数字', - 'status.number' => '行为状态只能为数字', + ]; } diff --git a/app/common/validate/Adminauthgroup.php b/app/common/validate/Adminauthgroup.php index 6a596d0..77582a4 100644 --- a/app/common/validate/Adminauthgroup.php +++ b/app/common/validate/Adminauthgroup.php @@ -1,10 +1,10 @@ 'require|max:20', - 'type' => 'number', 'description' => 'max:80', ]; protected $message = [ 'title.require' => '请输入用户组名称!', 'title.max' => '用户组名称最多输入20个字符', - 'type.number' => '组类型只能为数字', - 'description.max' => '描述信息最多输入80个字符', + 'remark.max' => '描述信息最多输入80个字符', ]; } diff --git a/app/common/validate/Adminmember.php b/app/common/validate/Adminmember.php index 2cf9dc3..1d010f0 100644 --- a/app/common/validate/Adminmember.php +++ b/app/common/validate/Adminmember.php @@ -1,20 +1,20 @@ 'require|max:16', @@ -30,8 +30,6 @@ class Adminmember extends Validate { 'password.min' => '密码最少不能低于4个字符', 'password.max' => '密码最多不能超过30个字符', ]; - - protected $scene = [ 'editpwd' => ['password']//修改密码 ]; diff --git a/app/common/validate/Config.php b/app/common/validate/Config.php index 4e3cb05..32530d6 100644 --- a/app/common/validate/Config.php +++ b/app/common/validate/Config.php @@ -1,10 +1,10 @@ 'require|max:80', - 'uid' => 'number|max:10', - 'name' => 'max:40', - 'category_id' => 'require|number', - 'keywords' => 'max:255', - 'description' => 'max:255', - 'type' => 'number', - 'sort' => 'require|number', - 'link_str' => 'max:255', - 'cover_path' => 'max:255', - ]; - - protected $message = [ - 'title.require' => '请输入文章标题!', - 'title.max' => '文章标题最多输入80个字符', - 'uid.number' => '用户id只能是数字', - 'uid.max' => '用户id最多输入10个字符', - 'name.max' => '标识最多输入40个字符', - 'category_id' => '请选择文章分类', - 'category_id.number' => '文章分类只能是数字', - 'keywords.max' => '关键字最多输入255个字符', - 'description.max' => '描述最多输入255个字符', - 'link_str.max' => '外链最多输入255个字符', - 'cover_path.max' => '封面最多输入255个字符', - 'type.number' => '内容类型只能是数字', - 'sort.require' => '请输入排序序号', - 'sort.number' => '排序序号只能是数字', - + protected $rule = [ + 'writer|作者' => [ + 'require', + 'max' => 50, + ], + 'title|标题' => [ + 'require', + 'max' => 500, + ], + 'category_id|所属分类' => [ + 'require', + 'number', + ], + 'keywords|网站关键词' => [ + 'max' => 500, + ], + 'description|网站描述' => [ + 'max' => 65535, + ], + 'isrecommend|是否推荐' => [ + 'require', + 'number' + ], + 'istop|是否置顶' => [ + 'require', + 'number', + ], + 'link_str|外链' => [ + 'max' => 500, + ], + 'cover_path|封面' => [ + 'max' => 500, + ], + 'display|是否显示' => [ + 'require', + 'number', + ], + 'view|浏览量' => [ + 'number', + ], + 'sort|排序' => [ + 'require', + 'number', + ], + 'content|文章内容' => [ + 'max' => 65535, + ], ]; //更新排序 protected $scene = [ - 'sort' => ['sort'] + 'sort' => ['sort'] ]; - } diff --git a/app/common/validate/Documentcategory.php b/app/common/validate/Documentcategory.php index 8145ad3..6466825 100644 --- a/app/common/validate/Documentcategory.php +++ b/app/common/validate/Documentcategory.php @@ -1,53 +1,42 @@ 'require|max:50', - 'name' => 'max:30', - 'pid'=>'require|number', - 'display'=>'require|number', - 'type' => 'require|number', - 'sort' => 'require|number', - 'link_str' => 'max:255', - 'keywords' => 'max:255', - 'description' => 'max:255', - 'meta_title' => 'max:50', - 'template_index'=>['regex' => '/^[a-zA-Z0-9]/'], - 'template_lists'=>['regex' => '/^[a-zA-Z0-9]/'], - 'template_detail'=>['regex' => '/^[a-zA-Z0-9]/'], - ]; - - protected $message = [ - 'title.require' => '请输入文章标题!', - 'title.max' => '文章标题最多输入50个字符', - 'name.max' => '标识最多输入30个字符', - 'type.number' => '分类类别只能是数字', - 'sort.number' => '排序只能是数字!', - 'link_str.max' => '外链最多输入255个字符', - 'keywords.max' => '关键字最多输入255个字符', - 'description.max' => '描述最多输入255个字符', - 'meta_title.max' => 'SEO的网页标题最多输入50个字符', - 'template_index'=>'模板文件名必须以字母或数字开头!', - 'template_lists'=>'模板文件名必须以字母或数字开头!', - 'template_detail'=>'模板文件名必须以字母或数字开头!' +class DocumentCategory extends Validate +{ + protected $rule = [ + 'title|标题' => [ + 'require', + 'max' => 50, + ], + 'pid|上级分类ID' => [ + 'require', + 'number', + ], + 'sort|排序' => [ + 'require', + 'number', + ], + 'meta_title|标题' => [ + 'max' => 500, + ], + 'keywords|网页关键字' => [ + 'max' => 500, + ], + 'link_str|外链' => [ + 'max' => 500, + ], + 'icon|分类图标' => [ + 'max' => 500, + ], ]; //更新排序 protected $scene = [ - 'sort' => ['sort'] + 'sort' => ['sort'] ]; } diff --git a/app/common/validate/Friendlink.php b/app/common/validate/Friendlink.php index c9813df..631c17e 100644 --- a/app/common/validate/Friendlink.php +++ b/app/common/validate/Friendlink.php @@ -2,9 +2,9 @@ // +---------------------------------------------------------------------- // | HulaCWMS 呼啦企业网站管理系统 // +---------------------------------------------------------------------- -// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved. +// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved. // +---------------------------------------------------------------------- -// | Author: 灼灼文化 +// | Author: 开发树 // +---------------------------------------------------------------------- namespace app\common\validate; @@ -20,15 +20,12 @@ class Friendlink extends Validate { 'title' => 'require|max:255', 'url' => 'require|max:255', 'sort' => 'require|number', - 'uid' => 'max:10|number', ]; protected $message = [ 'title.require' => '请输入链接名称!', - 'url.require' => '请选择链接地址!', + 'url.require' => '请输入链接地址!', 'sort' => '请输入排序序号', 'sort.number' => '排序序号只能是数字', - 'uid.number' => '添加者ID只能是数字', - 'uid.max' => '添加者ID最多不超过10个字符', 'title.max' => '链接名称最多输入255个字符', 'url.max' => '链接地址最多输入255个字符', ]; diff --git a/app/common/validate/Messageform.php b/app/common/validate/Messageform.php index a659dbb..8bd5d2e 100644 --- a/app/common/validate/Messageform.php +++ b/app/common/validate/Messageform.php @@ -2,9 +2,9 @@ // +---------------------------------------------------------------------- // | HulaCWMS 呼啦企业网站管理系统 // +---------------------------------------------------------------------- -// | Copyright (c) 2019 http://www.zhuopro.com All rights reserved. +// | Copyright (c) 2021 https://www.kaifashu.com All rights reserved. // +---------------------------------------------------------------------- -// | Author: 灼灼文化 +// | Author: 开发树 // +---------------------------------------------------------------------- namespace app\common\validate; @@ -14,7 +14,7 @@ use think\Validate; * 后台菜单验证器 */ -class Messageform extends Validate { +class MessageForm extends Validate { protected $rule = [ 'content' => 'require', diff --git a/app/index/common.php b/app/index/common.php index efb229a..96cc5d2 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -30,7 +30,7 @@ function html2text($str){ function get_type_content($id,$strip=false){ $dc=Db::name('document_category_content')->find($id); if(!$dc){ - throw new Exception('分类不存在或已删除!'); + return ''; } if($strip){ return html2text($dc['content']); @@ -44,7 +44,7 @@ function get_document_category_list(){ //缓存文章菜单 $docuemtCategory=cache('DATA_DOCUMENT_CATEGORY_LIST'); if($docuemtCategory===null){ - $docuemtCategoryList=Db::name('document_category')->order('sort desc')->select(); + $docuemtCategoryList=Db::name('document_category')->where('status',1)->order('sort asc')->select(); //转换,让id作为数组的键 $docuemtCategory=[]; foreach ($docuemtCategoryList as $key=>$item){ @@ -67,41 +67,17 @@ function get_document_category($x,$field=false){ } //获取缓存的文章菜单 $docuemtCategoryList=get_document_category_list(); - $docuemtCategory=$docuemtCategoryList[$x]??''; - if(!$docuemtCategory){ - throw new Exception('分类不存在或已删除!'); + if(!isset($docuemtCategoryList[$x])){ + return false; } if($field){ - return $docuemtCategory[$field]; + return $docuemtCategoryList[$x][$field]; } else{ - return $docuemtCategory; + return $docuemtCategoryList[$x]; } } -/** - * 获取栏目子元素 - * @param $cid int|array 栏目分类 - * @param bool $field - * @return mixed|string - * @throws Exception - * @author 李玉坤 - * @date 2021-04-06 9:43 - */ -function get_document_category_children($cid){ - if(!$cid){ - throw new Exception('请指定要获取的栏目分类id!'); - } - if (!is_array($cid)){ - $cid = explode(',',$cid); - } - $children = Db::name('document_category')->where('pid','in',$cid)->column('id'); - if(!empty($children)){ - $children = array_merge($children,get_document_category_children($children)); - } - return $children; -} - /** * 获取一个文章分类-通个分类标识 */ @@ -119,7 +95,7 @@ function get_document_category_by_name($name,$field=false){ } } if(!$docuemtCategory){ - throw new Exception('分类不存在或已删除!'); + return false; } if($field){ return $docuemtCategory[$field]; @@ -132,7 +108,7 @@ function get_document_category_by_name($name,$field=false){ /** * 模板-获取文章分类 */ -function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ +function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1){ switch($type){ case 'top': @@ -153,7 +129,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ } $dc=get_document_category($typeid); if(!$dc){ - throw new Exception('分类不存在或已删除!'); + return false; } return get_document_category_by_parent($dc['pid'],$row,$display);; break; @@ -166,7 +142,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ if(!$dc){ throw new Exception('分类不存在或已删除!'); } - $tempArr=Db::name('document_category')->where('id','in',$dc['child'])->select(); + $tempArr=Db::name('document_category')->where('id','in',$dc['child'])->where('status',1)->limit($row); if($display){ $tempArr=$tempArr->where('display',1); } @@ -197,8 +173,8 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ $dc=get_document_category($typeid); if($dc['pid']!=0){ //获取根分类,此操作读取数据库,非缓存! - $dc=Db::name('document_category')->where('pid',0) - ->where("CONCAT(',',child,',') like '%,$typeid,%'"); + $dc=Db::name('document_category')-where('pid',0)->where('status',1) + -> where("CONCAT(',',child,',') like '%,$typeid,%'")->limit($row); if($display){ $dc=$dc->where('display',1); } @@ -214,7 +190,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ break; case 'where': //根据自定义条件获取分类(where语句),此操作读取数据库,非缓存! - $tempArr=Db::name('document_category')-> where($where)->order($orderby); + $tempArr=Db::name('document_category')->where('status',1)-> where($where)->order($orderby)->limit($row); if($display){ $tempArr=$tempArr->where('display',1); } @@ -228,7 +204,7 @@ function tpl_get_channel($type,$typeid,$row,$where='',$orderby='',$display=1){ break; case 'ids': //根据多个栏目id,逗号隔开的那种,获得栏目列表 - $tempArr=Db::name('document_category')-> where('id','in',$typeid)->order($orderby); + $tempArr=Db::name('document_category')->where('status',1)-> where('id','in',$typeid)->order($orderby)->limit($row); if($display){ $tempArr=$tempArr->where('display',1); } @@ -261,11 +237,7 @@ function get_document_category_by_parent($pid,$row,$display=1){ } if($item['pid']==$pid&&($display?$item['display']==1:true)){ $x=$x+1; - $tempArr[$item['id']] = $item; - } - //判断是否有子元素,子元素则为其父元素的child字段设置为1 - if ($item['pid'] > 0 && !empty($tempArr[$item['pid']])){ - $tempArr[$item['pid']]['child'] = 1; + array_push($tempArr,$item); } } return $tempArr; @@ -275,7 +247,7 @@ function get_document_category_by_parent($pid,$row,$display=1){ * $get=上一篇|下一篇 * $cid=栏目分类id */ -function tpl_get_prenext($get,$cid=false){ +function tpl_get_prenext($get,$cid=false,$none){ //文档id $id=input('id'); if(!$get){ @@ -297,7 +269,7 @@ function tpl_get_prenext($get,$cid=false){ else{ $document['id']=false; $document['url']='javascript:void(0)'; - $document['title']='没有了'; + $document['title']=$none; } return $document; @@ -317,9 +289,10 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals $docmentListModel=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') + ->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT') ->where("a.type='$table'") ->where('a.status',1) + ->where('b.status',1) ->field('a.*,b.title as category_title,c.*'); if($display){ @@ -335,11 +308,9 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals case 'find': //获取栏目下文章以及所有子孙分类文章 $dc=get_document_category($cid); - $children = get_document_category_children($cid); - if(!empty($children)){ - array_push($children,$cid); - $children = implode('.',$children); - $docmentListModel=$docmentListModel->where('a.category_id','in',$children); + $child=$dc['child']; + if($child){ + $docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child"); } else{ $docmentListModel=$docmentListModel->where('a.category_id',$cid); @@ -374,7 +345,7 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals //获取当前请求的请求参数,以确定分页是否要带上这些请求参数 $query=request()->query(); if($query){ - $docmentListModel=$docmentListModel->paginate( ['list_rows'=>$pagesize,'query' => request()->param()]); + $docmentListModel=$docmentListModel->paginate($pagesize,false,['query' => getRouteQuery()]); } else{ $docmentListModel=$docmentListModel->paginate($pagesize); @@ -394,6 +365,17 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals return $re; } +/** + * 获得当前路由及参数列表 + * @return mixed + */ +function getRouteQuery(){ + $request=request(); + $queryArr=$request->param(); + $queryArr['s']=$request->pathinfo(); + return $queryArr; +} + /** * 根据栏目类型,生成栏目url */ @@ -431,8 +413,8 @@ function tpl_get_article($id,$table){ ->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') - ->where('a.status',1)->where('a.display',1)->where('a.id',$id)->where("a.type='article'") - ->field('a.*,b.title as category_title,c.content'); + ->where('a.status',1)->where('a.id',$id)->where("a.type='$table'") + ->field('a.*,b.title as category_title,c.*'); $doc=$docmentModel->find(); @@ -461,8 +443,7 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w ->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') - ->where("a.type='$table'") - ->where('a.status',1) + ->where("a.type='$table'")->where('a.status',1)->where('b.status',1) ->limit($row) ->field('a.*,b.title as category_title,c.*'); @@ -615,7 +596,7 @@ function tpl_get_position($dc,$positionList=array()){ $htmlstr='首页'; $positionListCount=count($positionList); for ($x=$positionListCount-1;$x>=0;$x--){ - $htmlstr=$htmlstr.'>'.$positionList[$x]['title'].''; + $htmlstr=$htmlstr.'>'.$positionList[$x]['title'].''; } return $htmlstr; } diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index cf05dde..551193f 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -50,13 +50,13 @@ class Article extends Base //读取列表页模板 $listTmp=''; if($dc['type']==0){ - $listTmp=$dc['template']; + $listTmp=$dc['template_lists']; if(!$listTmp){ $this->error('请在栏目分类中,指定当前栏目的列表模板!'); } } elseif($dc['type']==1){ - $listTmp=$dc['template']; + $listTmp=$dc['template_index']; if(!$listTmp){ $this->error('请在栏目分类中,指定当前栏目的单篇模板!'); } @@ -114,7 +114,7 @@ class Article extends Base //添加当前页面的位置信息 $article['position']=tpl_get_position($dc); //更新浏览次数 - Db::name('document')->where('id', $article['id'])->inc('view', 1); + Db::name('document')->where('id', $article['id'])->inc('view')->update(); //读取详情页模板 $detailTmp=$dc['template_detail']; if(!$detailTmp){ diff --git a/app/index/controller/Base.php b/app/index/controller/Base.php index 083f24a..60ba403 100644 --- a/app/index/controller/Base.php +++ b/app/index/controller/Base.php @@ -16,11 +16,6 @@ use app\admin\model\SystemConfig; */ class Base extends BaseController { - /** - * 控制器中间件 - * @var array - */ - protected $middleware = []; //系统配置 protected $systemConfig = []; @@ -47,6 +42,8 @@ class Base extends BaseController } //判断是否开启了伪静态 if ($systemConfig['web_rewrite']) { + $this->request->setRoot('/?s='); + } elseif(web_config('WEB_REWRITE')=='1') { $this->request->setRoot('/'); } else { $this->request->setRoot('/index.php'); diff --git a/app/index/model/Document.php b/app/index/model/Document.php deleted file mode 100644 index db5ee99..0000000 --- a/app/index/model/Document.php +++ /dev/null @@ -1,17 +0,0 @@ -page((int)$where['page'],(int)$where['limit']); - $data = $model->select(); - if ($data) $data = $data->toArray(); - return compact('data','count'); - } -} \ No newline at end of file diff --git a/app/index/model/DocumentCategory.php b/app/index/model/DocumentCategory.php deleted file mode 100644 index 572af5c..0000000 --- a/app/index/model/DocumentCategory.php +++ /dev/null @@ -1,17 +0,0 @@ -where('date',$date_data) - ->where('time','=',$hour) - ->value('id'); - if ($pvInfo) { - $model->where('id', $pvInfo) - ->inc('view') - ->update(); - } else { - $pvData = [ - 'view' => 1, - 'time' => $hour, - 'date' => $date_data - ]; - $model->save($pvData); - } - } -} \ No newline at end of file diff --git a/app/index/model/Slides.php b/app/index/model/Slides.php deleted file mode 100644 index 810e8f3..0000000 --- a/app/index/model/Slides.php +++ /dev/null @@ -1,17 +0,0 @@ -url(true); - //根据url和date字段判断数据库中是否存在该页面的记录 - $url_data = $model->where('date',$date_data) - ->where('url',$urlInfo) - ->field('id') - ->find(); - if ($url_data) { - $model->where('id',$url_data['id'])->inc('pv')->update(); - } else { - $dataUrl = [ - 'url' => $urlInfo, - 'pv' => 1, - 'title' => $title, - 'date' => $date_data - ]; - $model->save($dataUrl); - } - } -} \ No newline at end of file diff --git a/app/index/model/UvLog.php b/app/index/model/UvLog.php deleted file mode 100644 index 52a62c7..0000000 --- a/app/index/model/UvLog.php +++ /dev/null @@ -1,51 +0,0 @@ -ip(); - //查询该ip今天是否存在过 - $uvInfo = $model->where('date',$date_data) - ->where('ip',$ipData) - ->field('id') - ->find(); - //不存在 添加数据 - if (!$uvInfo) { - $uvData = [ - 'ip' => $ipData, - 'time' => $hour, - 'date' => $date_data - ]; - $model->save($uvData); - } - } -} \ No newline at end of file diff --git a/config/app.php b/config/app.php index 1a97220..3ba1bc0 100644 --- a/config/app.php +++ b/config/app.php @@ -4,7 +4,10 @@ // +---------------------------------------------------------------------- return [ + //应用调试模式 'app_debug' => env('app_debug', false), + // 应用Trace调试 + 'app_trace' => env('app_debug', false), // 应用地址 'app_host' => env('app.host', ''), // 应用的命名空间 @@ -15,6 +18,8 @@ return [ 'with_event' => true, // 默认应用 'default_app' => 'index', + // 开启应用快速访问 + 'app_express' => true, // 默认时区 'default_timezone' => 'Asia/Shanghai', // 快捷访问 @@ -22,14 +27,17 @@ return [ // 自动多应用模式 'auto_multi_app' => true, // 应用映射(自动多应用模式有效) - 'app_map' => ['*'=>'', 'api'=>'api', 'admin'=>'admin', 'index'=>'index'], + 'app_map' => ['*'=>'', 'admin'=>'admin', 'index'=>'index'], // 域名绑定(自动多应用模式有效) 'domain_bind' => [], // 禁止URL访问的应用列表(自动多应用模式有效) - 'deny_app_list' => [], + 'deny_app_list' => ['common','addons'], // 异常页面的模板文件 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl', + // 默认跳转页面对应的模板文件 + 'dispatch_success_tmpl' => root_path(). 'extend/tpl/dispatch_jump.tpl', + 'dispatch_error_tmpl' => root_path(). 'extend/tpl/dispatch_jump.tpl', // 错误显示信息,非调试模式有效 'error_message' => '页面错误!请稍后再试~', diff --git a/public/template/default/pc/index/index.html b/public/template/default/pc/index/index.html index 825fd8d..4458d59 100644 --- a/public/template/default/pc/index/index.html +++ b/public/template/default/pc/index/index.html @@ -57,7 +57,7 @@