From 1d15617cb0d521efab516035acb33e61b63754ba Mon Sep 17 00:00:00 2001 From: hdm Date: Wed, 16 Feb 2022 15:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8B=BE=E8=82=A1CMS2.0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E6=9E=84=E4=BA=86=E7=B3=BB=E7=BB=9F=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97=E3=80=81=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BB=A5=E5=8F=8A=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97=E7=9A=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Admin.php | 132 +++++++++++++++--------------- app/admin/controller/Article.php | 2 +- app/admin/controller/Conf.php | 2 +- app/admin/controller/Goods.php | 2 +- app/admin/controller/Keywords.php | 2 +- app/admin/controller/Log.php | 2 +- app/admin/controller/Nav.php | 2 +- app/admin/controller/Role.php | 2 +- app/admin/controller/Search.php | 2 +- app/admin/controller/Sitemap.php | 4 +- app/admin/controller/Slide.php | 6 +- app/admin/controller/User.php | 6 +- public/index.php | 4 +- 13 files changed, 82 insertions(+), 86 deletions(-) diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index 3c35f7d..5861d67 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -28,7 +28,7 @@ class Admin extends BaseController $where[] = ['id|username|nickname|desc|mobile', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['status','>=',0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $admin = AdminList::where($where) ->order('create_time asc') ->paginate($rows, false, ['query' => $param]) @@ -46,72 +46,9 @@ class Admin extends BaseController //添加 public function add() - { - $id = empty(get_params('id')) ? 0 : get_params('id'); - if ($id > 0) { - $admin = get_admin(get_params('id')); - View::assign('admin', $admin); - } - View::assign('id', $id); - return view(); - } - - public function to_avatars($char) - { - $defaultData = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾', - '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'); - if (isset($char)) { - $Char = $char; - } else { - $Char = $defaultData[mt_rand(0, count($defaultData) - 1)]; - } - $OutputSize = min(512, empty($_GET['size']) ? 36 : intval($_GET['size'])); - - $Avatar = new MDAvatars($Char, 256, 1); - $avatar_name = '/avatars/avatar_256_' . set_salt(10) . time() . '.png'; - $path = get_config('filesystem.disks.public.url') . $avatar_name; - $res = $Avatar->Save('.' . $path, 256); - $Avatar->Free(); - /* - if ($res) { - //写入到附件表 - $data = []; - $data['filepath'] = $path; - $data['name'] = $Char; - $data['mimetype'] = 'image/png'; - $data['fileext'] = 'png'; - $data['filesize'] = 0; - $data['filename'] = $avatar_name; - $data['sha1'] = ''; - $data['md5'] = ''; - $data['module'] = \think\facade\App::initialize()->http->getName(); - $data['action'] = app('request')->action(); - $data['uploadip'] = app('request')->ip(); - $data['create_time'] = time(); - $data['user_id'] = get_login_admin('id') ? get_login_admin('id') : 0; - if ($data['module'] = 'admin') { - //通过后台上传的文件直接审核通过 - $data['status'] = 1; - $data['admin_id'] = $data['user_id']; - $data['audit_time'] = time(); - } - $data['use'] = 'avatar'; //附件用处 - $fid = Db::name('file')->insertGetId($data); - return $fid; - } - */ - return $path; - } - - //提交添加 - public function post_submit() - { - if (request()->isAjax()) { - $param = get_params(); - + { + if (request()->isAjax()) { + $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { try { validate(AdminCheck::class)->scene('edit')->check($param); @@ -200,7 +137,66 @@ class Admin extends BaseController } } return to_assign(); + } + else{ + $id = empty(get_params('id')) ? 0 : get_params('id'); + if ($id > 0) { + $admin = get_admin(get_params('id')); + View::assign('admin', $admin); + } + View::assign('id', $id); + return view(); + } + } + + public function to_avatars($char) + { + $defaultData = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾', + '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'); + if (isset($char)) { + $Char = $char; + } else { + $Char = $defaultData[mt_rand(0, count($defaultData) - 1)]; } + $OutputSize = min(512, empty($_GET['size']) ? 36 : intval($_GET['size'])); + + $Avatar = new MDAvatars($Char, 256, 1); + $avatar_name = '/avatars/avatar_256_' . set_salt(10) . time() . '.png'; + $path = get_config('filesystem.disks.public.url') . $avatar_name; + $res = $Avatar->Save('.' . $path, 256); + $Avatar->Free(); + /* + if ($res) { + //写入到附件表 + $data = []; + $data['filepath'] = $path; + $data['name'] = $Char; + $data['mimetype'] = 'image/png'; + $data['fileext'] = 'png'; + $data['filesize'] = 0; + $data['filename'] = $avatar_name; + $data['sha1'] = ''; + $data['md5'] = ''; + $data['module'] = \think\facade\App::initialize()->http->getName(); + $data['action'] = app('request')->action(); + $data['uploadip'] = app('request')->ip(); + $data['create_time'] = time(); + $data['user_id'] = get_login_admin('id') ? get_login_admin('id') : 0; + if ($data['module'] = 'admin') { + //通过后台上传的文件直接审核通过 + $data['status'] = 1; + $data['admin_id'] = $data['user_id']; + $data['audit_time'] = time(); + } + $data['use'] = 'avatar'; //附件用处 + $fid = Db::name('file')->insertGetId($data); + return $fid; + } + */ + return $path; } //查看 @@ -263,7 +259,7 @@ class Admin extends BaseController if (!empty($param['rule_menu'])) { $where['rule_menu'] = $param['rule_menu']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = DB::name('AdminLog') ->field("id,uid,nickname,title,content,rule_menu,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time") ->order('create_time desc') diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index 4aa412a..6f60004 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -129,7 +129,7 @@ class Article extends BaseController $where[] = ['a.article_cate_id', '=', $param['article_cate_id']]; } $where[] = ['a.status', '>=', 0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = ArticleList::where($where) ->field('a.*,w.id as cate_id,a.id as id,w.title as cate_title,a.title as title') ->alias('a') diff --git a/app/admin/controller/Conf.php b/app/admin/controller/Conf.php index c23e764..3227f4b 100644 --- a/app/admin/controller/Conf.php +++ b/app/admin/controller/Conf.php @@ -23,7 +23,7 @@ class Conf extends BaseController $param = get_params(); $where = array(); $where[] = ['status', '>=', 0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = Db::name('Config') ->where($where) ->paginate($rows, false, ['query' => $param]); diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index 0d97286..2ebc253 100644 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -129,7 +129,7 @@ class Goods extends BaseController $where[] = ['a.cate_id', '=', $param['cate_id']]; } $where[] = ['a.status', '>=', 0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = GoodsList::where($where) ->field('a.*,a.id as id,w.title as cate_title,a.title as title') ->alias('a') diff --git a/app/admin/controller/Keywords.php b/app/admin/controller/Keywords.php index 5b5a5fa..2d937c3 100644 --- a/app/admin/controller/Keywords.php +++ b/app/admin/controller/Keywords.php @@ -26,7 +26,7 @@ class Keywords extends BaseController $where[] = ['title', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['status', '>=', 0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = Db::name('Keywords') ->order('create_time desc') ->where($where) diff --git a/app/admin/controller/Log.php b/app/admin/controller/Log.php index a533f40..893fa20 100644 --- a/app/admin/controller/Log.php +++ b/app/admin/controller/Log.php @@ -27,7 +27,7 @@ class Log extends BaseController if (!empty($param['action'])) { $where['action'] = $param['action']; } - $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; + $rows = empty($param['limit']) ? get_config(''app . page_size'') : $param['limit']; $content = DB::name('AdminLog') ->field("id,uid,nickname,action,title,content,rule_menu,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time") ->order('create_time desc') diff --git a/app/admin/controller/Nav.php b/app/admin/controller/Nav.php index 6948708..67570a0 100644 --- a/app/admin/controller/Nav.php +++ b/app/admin/controller/Nav.php @@ -27,7 +27,7 @@ class Nav extends BaseController if (!empty($param['keywords'])) { $where[] = ['id|name|title|desc', 'like', '%' . $param['keywords'] . '%']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $nav = NavList::where($where) ->order('create_time asc') ->paginate($rows, false, ['query' => $param]); diff --git a/app/admin/controller/Role.php b/app/admin/controller/Role.php index 3e13eb9..1fe7e7b 100644 --- a/app/admin/controller/Role.php +++ b/app/admin/controller/Role.php @@ -26,7 +26,7 @@ class Role extends BaseController if (!empty($param['keywords'])) { $where[] = ['id|title|desc', 'like', '%' . $param['keywords'] . '%']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $group = AdminGroup::where($where) ->order('create_time asc') ->paginate($rows, false, ['query' => $param]); diff --git a/app/admin/controller/Search.php b/app/admin/controller/Search.php index 2dccd6a..a58acf6 100644 --- a/app/admin/controller/Search.php +++ b/app/admin/controller/Search.php @@ -23,7 +23,7 @@ class Search extends BaseController if (!empty($param['keywords'])) { $where[] = ['title', 'like', '%' . $param['keywords'] . '%']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = Db::name('SearchKeywords') ->order('id desc') ->where($where) diff --git a/app/admin/controller/Sitemap.php b/app/admin/controller/Sitemap.php index f86ca5e..d0a6b79 100644 --- a/app/admin/controller/Sitemap.php +++ b/app/admin/controller/Sitemap.php @@ -29,7 +29,7 @@ class Sitemap extends BaseController $where[] = ['id|name', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['status', '=', 1]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $SitemapCate = SitemapCate::where($where) ->order('sort desc, id desc') ->paginate($rows, false, ['query' => $param]); @@ -118,7 +118,7 @@ class Sitemap extends BaseController $where = array(); $where[] = ['sitemap_cate_id', '=', $param['id']]; $where[] = ['status', '>=', 0]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $sitemap = SitemapInfo::where($where) ->order('sort desc, id desc') ->paginate($rows, false, ['query' => $param]); diff --git a/app/admin/controller/Slide.php b/app/admin/controller/Slide.php index 56142db..1e911f2 100644 --- a/app/admin/controller/Slide.php +++ b/app/admin/controller/Slide.php @@ -27,7 +27,7 @@ class Slide extends BaseController if (!empty($param['keywords'])) { $where[] = ['id|name|title|desc', 'like', '%' . $param['keywords'] . '%']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $slide = SlideList::where($where) ->order('create_time asc') ->paginate($rows, false, ['query' => $param]); @@ -112,7 +112,7 @@ class Slide extends BaseController if (request()->isAjax()) { $where = array(); $where[] = ['s.slide_id', '=', $param['id']]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $slideInfoList = SlideInfo::where($where) ->alias('s') ->join('File f', 's.img=f.id', 'LEFT') @@ -133,7 +133,7 @@ class Slide extends BaseController $param = get_params(); $where = array(); $where[] = ['s.slide_id', '=', $param['id']]; - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $slideInfoList = SlideInfo::where($where) ->alias('s') ->join('File f', 's.img=f.id', 'LEFT') diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index 8e372e2..24f0374 100644 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -41,7 +41,7 @@ class User extends BaseController $where['register_time'] = array('elt', $end_time); } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = UserList::where($where) ->order('id desc') ->paginate($rows, false, ['query' => $param]) @@ -116,7 +116,7 @@ class User extends BaseController if (!empty($param['action'])) { $where['title'] = $param['action']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = DB::name('UserLog') ->field("id,uid,nickname,title,content,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time") ->order('create_time desc') @@ -154,7 +154,7 @@ class User extends BaseController if (!empty($param['keywords'])) { $where[] = ['nickname|title', 'like', '%' . $param['keywords'] . '%']; } - $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; + $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $content = DB::name('UserLog') ->field("id,uid,nickname,title,content,ip,param,create_time") ->order('create_time desc') diff --git a/public/index.php b/public/index.php index 7efb802..8ffda34 100644 --- a/public/index.php +++ b/public/index.php @@ -9,7 +9,7 @@ namespace think; if (empty(file_exists(__DIR__ . '/../vendor/autoload.php'))) { - echo '您还未安装PHP依赖包,请输入命令安装:composer install,安装教程点击这里。'; + echo '您还未安装PHP依赖包,请输入命令安装:composer install,安装教程点击这里。'; exit; } require __DIR__ . '/../vendor/autoload.php'; @@ -18,7 +18,7 @@ require __DIR__ . '/../vendor/autoload.php'; define('CMS_VERSION','2.0.11'); // 定义ThinkPHP版本号 -define('TP_VERSION','6.0.9'); +define('TP_VERSION','6.0.12'); // 定义Layui版本号 define('LAYUI_VERSION','2.6.8');