diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index d5c197a5..965b9fdf 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -1,6 +1,6 @@ /* FastAdmin Install SQL - Date: 2020年04月23日 + Date: 2020-06-11 22:11:09 */ SET FOREIGN_KEY_CHECKS = 0; @@ -53,6 +53,27 @@ CREATE TABLE `fa_admin_log` ( KEY `name` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='管理员日志表'; +-- ---------------------------- +-- Table structure for fa_area +-- ---------------------------- +DROP TABLE IF EXISTS `fa_area`; +CREATE TABLE `fa_area` ( + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `pid` int(10) DEFAULT NULL COMMENT '父id', + `shortname` varchar(100) DEFAULT NULL COMMENT '简称', + `name` varchar(100) DEFAULT NULL COMMENT '名称', + `mergename` varchar(255) DEFAULT NULL COMMENT '全称', + `level` tinyint(4) DEFAULT NULL COMMENT '层级 0 1 2 省市区县', + `pinyin` varchar(100) DEFAULT NULL COMMENT '拼音', + `code` varchar(100) DEFAULT NULL COMMENT '长途区号', + `zip` varchar(100) DEFAULT NULL COMMENT '邮编', + `first` varchar(50) DEFAULT NULL COMMENT '首字母', + `lng` varchar(100) DEFAULT NULL COMMENT '经度', + `lat` varchar(100) DEFAULT NULL COMMENT '纬度', + PRIMARY KEY (`id`), + KEY `pid` (`pid`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='地区表'; + -- ---------------------------- -- Table structure for fa_attachment -- ---------------------------- @@ -337,7 +358,7 @@ CREATE TABLE `fa_ems` ( `code` varchar(10) NOT NULL DEFAULT '' COMMENT '验证码', `times` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '验证次数', `ip` varchar(30) NOT NULL DEFAULT '' COMMENT 'IP', - `createtime` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '创建时间', + `createtime` int(10) DEFAULT NULL COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='邮箱验证码表'; @@ -418,7 +439,7 @@ CREATE TABLE `fa_user` ( `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像', `level` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '等级', `gender` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '性别', - `birthday` date COMMENT '生日', + `birthday` date DEFAULT NULL COMMENT '生日', `bio` varchar(100) NOT NULL DEFAULT '' COMMENT '格言', `money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '余额', `score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '积分', @@ -546,4 +567,24 @@ CREATE TABLE `fa_user_token` ( `expiretime` int(10) DEFAULT NULL COMMENT '过期时间', PRIMARY KEY (`token`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='会员Token表'; + +-- ---------------------------- +-- Table structure for fa_version +-- ---------------------------- +DROP TABLE IF EXISTS `fa_version`; +CREATE TABLE `fa_version` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `oldversion` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '旧版本号', + `newversion` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '新版本号', + `packagesize` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '包大小', + `content` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '升级内容', + `downloadurl` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '下载地址', + `enforce` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '强制更新', + `createtime` int(10) DEFAULT NULL COMMENT '创建时间', + `updatetime` int(10) DEFAULT NULL COMMENT '更新时间', + `weigh` int(10) NOT NULL DEFAULT 0 COMMENT '权重', + `status` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='版本表'; + SET FOREIGN_KEY_CHECKS = 1; diff --git a/application/admin/controller/Addon.php b/application/admin/controller/Addon.php index c3c1939c..5e1caca1 100644 --- a/application/admin/controller/Addon.php +++ b/application/admin/controller/Addon.php @@ -316,7 +316,10 @@ class Addon extends Backend $onlineaddons = Cache::get("onlineaddons"); if (!is_array($onlineaddons)) { $onlineaddons = []; - $result = Http::sendRequest(config('fastadmin.api_url') . '/addon/index'); + $result = Http::sendRequest(config('fastadmin.api_url') . '/addon/index', [], 'GET', [ + CURLOPT_HTTPHEADER => ['Accept-Encoding:gzip'], + CURLOPT_ENCODING => "gzip" + ]); if ($result['ret']) { $json = (array)json_decode($result['msg'], true); $rows = isset($json['rows']) ? $json['rows'] : []; diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php index 3491754a..5172a10a 100644 --- a/application/admin/controller/Category.php +++ b/application/admin/controller/Category.php @@ -81,6 +81,17 @@ class Category extends Backend return $this->view->fetch(); } + /** + * 添加 + */ + public function add() + { + if ($this->request->isPost()) { + $this->token(); + } + return parent::add(); + } + /** * 编辑 */ @@ -97,6 +108,7 @@ class Category extends Backend } } if ($this->request->isPost()) { + $this->token(); $params = $this->request->post("row/a"); if ($params) { $params = $this->preExcludeFields($params); diff --git a/application/admin/controller/user/Group.php b/application/admin/controller/user/Group.php index 52463eec..b4c38c1b 100644 --- a/application/admin/controller/user/Group.php +++ b/application/admin/controller/user/Group.php @@ -26,16 +26,23 @@ class Group extends Backend public function add() { + if ($this->request->isPost()) { + $this->token(); + } $nodeList = \app\admin\model\UserRule::getTreeList(); $this->assign("nodeList", $nodeList); return parent::add(); } - public function edit($ids = NULL) + public function edit($ids = null) { + if ($this->request->isPost()) { + $this->token(); + } $row = $this->model->get($ids); - if (!$row) + if (!$row) { $this->error(__('No Results were found')); + } $rules = explode(',', $row['rules']); $nodeList = \app\admin\model\UserRule::getTreeList($rules); $this->assign("nodeList", $nodeList); diff --git a/application/admin/controller/user/Rule.php b/application/admin/controller/user/Rule.php index 4f818d7a..3dfa64e7 100644 --- a/application/admin/controller/user/Rule.php +++ b/application/admin/controller/user/Rule.php @@ -13,7 +13,6 @@ use fast\Tree; class Rule extends Backend { - /** * @var \app\admin\model\UserRule */ @@ -28,8 +27,7 @@ class Rule extends Backend $this->view->assign("statusList", $this->model->getStatusList()); // 必须将结果集转换为数组 $ruleList = collection($this->model->order('weigh', 'desc')->select())->toArray(); - foreach ($ruleList as $k => &$v) - { + foreach ($ruleList as $k => &$v) { $v['title'] = __($v['title']); $v['remark'] = __($v['remark']); } @@ -37,10 +35,10 @@ class Rule extends Backend Tree::instance()->init($ruleList); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); $ruledata = [0 => __('None')]; - foreach ($this->rulelist as $k => &$v) - { - if (!$v['ismenu']) + foreach ($this->rulelist as $k => &$v) { + if (!$v['ismenu']) { continue; + } $ruledata[$v['id']] = $v['title']; } $this->view->assign('ruledata', $ruledata); @@ -51,8 +49,7 @@ class Rule extends Backend */ public function index() { - if ($this->request->isAjax()) - { + if ($this->request->isAjax()) { $list = $this->rulelist; $total = count($this->rulelist); @@ -63,22 +60,41 @@ class Rule extends Backend return $this->view->fetch(); } + /** + * 添加 + */ + public function add() + { + if ($this->request->isPost()) { + $this->token(); + } + return parent::add(); + } + + /** + * 编辑 + */ + public function edit($ids = null) + { + if ($this->request->isPost()) { + $this->token(); + } + return parent::edit($ids); + } + /** * 删除 */ public function del($ids = "") { - if ($ids) - { + if ($ids) { $delIds = []; - foreach (explode(',', $ids) as $k => $v) - { - $delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, TRUE)); + foreach (explode(',', $ids) as $k => $v) { + $delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true)); } $delIds = array_unique($delIds); $count = $this->model->where('id', 'in', $delIds)->delete(); - if ($count) - { + if ($count) { $this->success(); } } diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 4bf19a82..9a3ee80d 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -3,6 +3,7 @@ namespace app\admin\controller\user; use app\common\controller\Backend; +use app\common\library\Auth; /** * 会员管理 @@ -13,7 +14,7 @@ class User extends Backend { protected $relationSearch = true; - + protected $searchFields = 'id,username,nickname'; /** * @var \app\admin\model\User @@ -60,17 +61,46 @@ class User extends Backend return $this->view->fetch(); } + /** + * 添加 + */ + public function add() + { + if ($this->request->isPost()) { + $this->token(); + } + return parent::add(); + } + /** * 编辑 */ - public function edit($ids = NULL) + public function edit($ids = null) { + if ($this->request->isPost()) { + $this->token(); + } $row = $this->model->get($ids); $this->modelValidate = true; - if (!$row) + if (!$row) { $this->error(__('No Results were found')); + } $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker'])); return parent::edit($ids); } + /** + * 删除 + */ + public function del($ids = "") + { + $row = $this->model->get($ids); + $this->modelValidate = true; + if (!$row) { + $this->error(__('No Results were found')); + } + Auth::instance()->delete($row['id']); + $this->success(); + } + } diff --git a/application/admin/lang/zh-cn/index.php b/application/admin/lang/zh-cn/index.php index 04aa0935..452c36dc 100644 --- a/application/admin/lang/zh-cn/index.php +++ b/application/admin/lang/zh-cn/index.php @@ -54,4 +54,5 @@ return [ 'Forum' => '交流社区', 'QQ qun' => 'QQ交流群', 'Captcha' => '验证码', + 'Security tips' => ' 安全提示:为了你的后台安全,请勿将后台管理入口设置为admin或admin.php', ]; diff --git a/application/admin/model/User.php b/application/admin/model/User.php index 8a7d7538..822c81b1 100644 --- a/application/admin/model/User.php +++ b/application/admin/model/User.php @@ -101,6 +101,11 @@ class User extends Model return $value && !is_numeric($value) ? strtotime($value) : $value; } + protected function setBirthdayAttr($value) + { + return $value ? $value : null; + } + public function group() { return $this->belongsTo('UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0); diff --git a/application/admin/validate/User.php b/application/admin/validate/User.php index c2ab92e2..ab062205 100644 --- a/application/admin/validate/User.php +++ b/application/admin/validate/User.php @@ -10,13 +10,13 @@ class User extends Validate * 验证规则 */ protected $rule = [ - 'username' => 'require|regex:\w{3,12}|unique:user', + 'username' => 'require|regex:\w{3,32}|unique:user', 'nickname' => 'require|unique:user', 'password' => 'regex:\S{6,32}', 'email' => 'require|email|unique:user', - 'mobile' => 'require|unique:user' + 'mobile' => 'unique:user' ]; - + /** * 字段描述 */ @@ -46,5 +46,5 @@ class User extends Validate ]; parent::__construct($rules, $message, $field); } - + } diff --git a/application/admin/view/category/add.html b/application/admin/view/category/add.html index 806d9f4a..a94bf7ef 100644 --- a/application/admin/view/category/add.html +++ b/application/admin/view/category/add.html @@ -1,5 +1,5 @@