diff --git a/application/admin/behavior/AdminLog.php b/application/admin/behavior/AdminLog.php index f5bcd3c9..2a7afc72 100644 --- a/application/admin/behavior/AdminLog.php +++ b/application/admin/behavior/AdminLog.php @@ -4,7 +4,7 @@ namespace app\admin\behavior; class AdminLog { - public function run(&$params) + public function run(&$response) { //只记录POST请求的日志 if (request()->isPost() && config('fastadmin.auto_record_log')) { diff --git a/application/admin/command/Addon.php b/application/admin/command/Addon.php index fb7c437c..7bca186e 100644 --- a/application/admin/command/Addon.php +++ b/application/admin/command/Addon.php @@ -15,7 +15,6 @@ use think\exception\PDOException; class Addon extends Command { - protected function configure() { $this @@ -33,6 +32,7 @@ class Addon extends Command protected function execute(Input $input, Output $output) { + \think\Config::load(dirname(dirname(__FILE__)) . DS . 'config.php'); $name = $input->getOption('name') ?: ''; $action = $input->getOption('action') ?: ''; if (stripos($name, 'addons' . DS) !== false) { @@ -82,7 +82,6 @@ class Addon extends Command $createTableSql = $result[0]['Create Table']; } } catch (PDOException $e) { - } $data = [ @@ -177,12 +176,12 @@ class Addon extends Command if (!$info) { throw new Exception(__('Addon info file data incorrect')); } - $infoname = isset($info['name']) ? $info['name'] : ''; + $infoname = $info['name'] ?? ''; if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name) { throw new Exception(__('Addon info name incorrect')); } - $infoversion = isset($info['version']) ? $info['version'] : ''; + $infoversion = $info['version'] ?? ''; if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion)) { throw new Exception(__('Addon info version incorrect')); } @@ -340,5 +339,4 @@ class Addon extends Command { return __DIR__ . '/Addon/stubs/' . $name . '.stub'; } - } diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 3845fa4c..ced92450 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -152,7 +152,7 @@ class Crud extends Command /** * JSON后缀 */ - protected $jsonSuffix = ['json']; + protected $jsonSuffix = ['json', 'array']; /** * 标签后缀 @@ -466,7 +466,7 @@ class Crud extends Command } } $relationTableInfo = $relationTableInfo[0]; - $relationModel = isset($relationModels[$index]) ? $relationModels[$index] : ''; + $relationModel = $relationModels[$index] ?? ''; list($relationNamespace, $relationName, $relationFile) = $this->getModelData($modelModuleName, $relationModel, $relationName); @@ -666,8 +666,8 @@ class Crud extends Command //如果是关联模型 foreach ($relations as $index => &$relation) { if ($relation['relationMode'] == 'hasone') { - $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id"; - $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey; + $relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id"; + $relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey; if (!in_array($relationForeignKey, $relation['relationFieldList'])) { throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']'); @@ -676,8 +676,8 @@ class Crud extends Command throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationPrimaryKey . ']'); } } elseif ($relation['relationMode'] == 'belongsto') { - $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : Loader::parseName($relation['relationName']) . "_id"; - $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $relation['relationPriKey']; + $relationForeignKey = $relation['relationForeignKey'] ?: Loader::parseName($relation['relationName']) . "_id"; + $relationPrimaryKey = $relation['relationPrimaryKey'] ?: $relation['relationPriKey']; if (!in_array($relationForeignKey, $fieldArr)) { throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationForeignKey . ']'); } @@ -685,8 +685,8 @@ class Crud extends Command throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationPrimaryKey . ']'); } } elseif ($relation['relationMode'] == 'hasmany') { - $relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id"; - $relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey; + $relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id"; + $relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey; if (!in_array($relationForeignKey, $relation['relationFieldList'])) { throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']'); } @@ -879,7 +879,7 @@ class Crud extends Command $formEditElement = Form::input('text', $fieldName, $editValue, $attrArr); } elseif ($inputType == 'fieldlist') { $itemArr = $this->getItemArray($itemArr, $field, $v['COLUMN_COMMENT']); - $templateName = !isset($itemArr['key']) && !isset($itemArr['value']) && count($itemArr) > 0 ? 'fieldlist-template' : 'fieldlist'; + $templateName = !isset($itemArr['key']) && count($itemArr) > 0 ? (isset($itemArr['value']) && count($itemArr) === 1 ? 'fieldlist-array' : 'fieldlist-template') : 'fieldlist'; $itemKey = isset($itemArr['key']) ? ucfirst($itemArr['key']) : 'Key'; $itemValue = isset($itemArr['value']) ? ucfirst($itemArr['value']) : 'Value'; $theadListArr = $tbodyListArr = []; @@ -901,6 +901,12 @@ class Crud extends Command $cssClassArr[] = 'selectpage'; $selectpageTable = substr($field, 0, strripos($field, '_')); $selectpageField = ''; + foreach ($relations as $index => $relation) { + if ($relation['relationForeignKey'] === $field) { + $selectpageTable = substr($relation['relationTableName'], strlen($prefix)); + break; + } + } $selectpageController = str_replace('_', '/', $selectpageTable); $attrArr['data-source'] = $selectpageController . "/index"; //如果是类型表需要特殊处理下 @@ -931,7 +937,6 @@ class Crud extends Command } } } catch (\Exception $e) { - } if (!$selectpageField) { foreach ($this->fieldSelectpageMap as $m => $n) { @@ -993,7 +998,7 @@ class Crud extends Command } if (!$fields || in_array($field, explode(',', $fields))) { //构造JS列信息 - $javascriptList[] = $this->getJsColumn($field, $v['DATA_TYPE'], $inputType && in_array($inputType, ['select', 'checkbox', 'radio']) ? '_text' : '', $itemArr); + $javascriptList[] = $this->getJsColumn($field, $v['DATA_TYPE'], $inputType && in_array($inputType, ['select', 'checkbox', 'radio']) ? '_text' : '', $itemArr, $v); } if ($this->headingFilterField && $this->headingFilterField == $field && $itemArr) { $headingHtml = $this->getReplacedStub('html/heading-html', ['field' => $field, 'fieldName' => Loader::parseName($field, 1, false)]); @@ -1048,7 +1053,7 @@ class Crud extends Command //过滤text类型字段 if ($v['DATA_TYPE'] != 'text') { //构造JS列信息 - $javascriptList[] = $this->getJsColumn($relationField, $v['DATA_TYPE']); + $javascriptList[] = $this->getJsColumn($relationField, $v['DATA_TYPE'], '', [], $v); } } } @@ -1537,7 +1542,7 @@ EOD; { $itemArr = []; $comment = str_replace(',', ',', $comment); - if (stripos($comment, ':') !== false && stripos($comment, ',') && stripos($comment, '=') !== false) { + if (stripos($comment, ':') !== false && stripos($comment, '=') !== false) { list($fieldLang, $item) = explode(':', $comment); $itemArr = []; foreach (explode(',', $item) as $k => $v) { @@ -1699,9 +1704,10 @@ EOD; * @param string $datatype * @param string $extend * @param array $itemArr + * @param array $fieldConfig * @return string */ - protected function getJsColumn($field, $datatype = '', $extend = '', $itemArr = []) + protected function getJsColumn($field, $datatype = '', $extend = '', $itemArr = [], $fieldConfig = []) { $lang = mb_ucfirst($field); $formatter = ''; @@ -1739,7 +1745,7 @@ EOD; $noSearchFiles = ['file$', 'files$', 'image$', 'images$', '^weigh$']; if (preg_match("/" . implode('|', $noSearchFiles) . "/i", $field)) { $html .= ", operate: false"; - } else if (in_array($datatype, ['varchar'])) { + } elseif (in_array($datatype, ['varchar'])) { $html .= ", operate: 'LIKE'"; } @@ -1751,6 +1757,10 @@ EOD; if (in_array($datatype, ['set'])) { $html .= ", operate:'FIND_IN_SET'"; } + if (isset($fieldConfig['CHARACTER_MAXIMUM_LENGTH']) && $fieldConfig['CHARACTER_MAXIMUM_LENGTH'] >= 255 && in_array($datatype, ['varchar']) && !$formatter) { + $formatter = 'content'; + $html .= ", table: table, class: 'autocontent'"; + } if (in_array($formatter, ['image', 'images'])) { $html .= ", events: Table.api.events.image"; } diff --git a/application/admin/command/Crud/stubs/add.stub b/application/admin/command/Crud/stubs/add.stub index e51cf203..1a6563f3 100644 --- a/application/admin/command/Crud/stubs/add.stub +++ b/application/admin/command/Crud/stubs/add.stub @@ -5,7 +5,6 @@
-
diff --git a/application/admin/command/Crud/stubs/edit.stub b/application/admin/command/Crud/stubs/edit.stub index 1c05f20e..6e51faa9 100644 --- a/application/admin/command/Crud/stubs/edit.stub +++ b/application/admin/command/Crud/stubs/edit.stub @@ -5,7 +5,6 @@
-
diff --git a/application/admin/command/Crud/stubs/html/fieldlist-array.stub b/application/admin/command/Crud/stubs/html/fieldlist-array.stub new file mode 100644 index 00000000..e6093fdd --- /dev/null +++ b/application/admin/command/Crud/stubs/html/fieldlist-array.stub @@ -0,0 +1,21 @@ + +
+
+ {:__('{%itemValue%}')} +
+
+ {:__('Append')} +
+
+ + + + diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index e32a8a4b..36abc123 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -336,16 +336,16 @@ INSERT INTO `fa_config` VALUES (4, 'version', 'basic', 'Version', '如果静态 INSERT INTO `fa_config` VALUES (5, 'timezone', 'basic', 'Timezone', '', 'string', '', 'Asia/Shanghai', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (6, 'forbiddenip', 'basic', 'Forbidden ip', '一行一条记录', 'text', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (7, 'languages', 'basic', 'Languages', '', 'array', '', '{\"backend\":\"zh-cn\",\"frontend\":\"zh-cn\"}', '', 'required', '', ''); -INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '请尽量输入左侧菜单栏存在的链接', 'string', '', 'dashboard', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '请输入左侧菜单栏存在的链接', 'string', '', 'dashboard', '', 'required', '', ''); INSERT INTO `fa_config` VALUES (9, 'categorytype', 'dictionary', 'Category type', '', 'array', '', '{\"default\":\"Default\",\"page\":\"Page\",\"article\":\"Article\",\"test\":\"Test\"}', '', '', '', ''); INSERT INTO `fa_config` VALUES (10, 'configgroup', 'dictionary', 'Config group', '', 'array', '', '{\"basic\":\"Basic\",\"email\":\"Email\",\"dictionary\":\"Dictionary\",\"user\":\"User\",\"example\":\"Example\"}', '', '', '', ''); INSERT INTO `fa_config` VALUES (11, 'mail_type', 'email', 'Mail type', '选择邮件发送方式', 'select', '', '1', '[\"请选择\",\"SMTP\"]', '', '', ''); INSERT INTO `fa_config` VALUES (12, 'mail_smtp_host', 'email', 'Mail smtp host', '错误的配置发送邮件会导致服务器超时', 'string', '', 'smtp.qq.com', '', '', '', ''); INSERT INTO `fa_config` VALUES (13, 'mail_smtp_port', 'email', 'Mail smtp port', '(不加密默认25,SSL默认465,TLS默认587)', 'string', '', '465', '', '', '', ''); -INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '', '10000', '', '', '', ''); -INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'password', '', 'password', '', '', '', ''); +INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '', '', '', '', '', ''); +INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码或授权码)', 'password', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', '(SMTP验证方式[推荐SSL])', 'select', '', '2', '[\"无\",\"TLS\",\"SSL\"]', '', '', ''); -INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '', '10000@qq.com', '', '', '', ''); +INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '', '', '', '', '', ''); INSERT INTO `fa_config` VALUES (18, 'attachmentcategory', 'dictionary', 'Attachment category', '', 'array', '', '{\"category1\":\"Category1\",\"category2\":\"Category2\",\"custom\":\"Custom\"}', '', '', '', ''); COMMIT; @@ -399,7 +399,8 @@ CREATE TABLE `fa_test` ( `keywords` varchar(255) DEFAULT '' COMMENT '关键字', `description` varchar(255) DEFAULT '' COMMENT '描述', `city` varchar(100) DEFAULT '' COMMENT '省市', - `json` varchar(255) DEFAULT NULL COMMENT '配置:key=名称,value=值', + `array` varchar(255) DEFAULT '' COMMENT '数组:value=值', + `json` varchar(255) DEFAULT '' COMMENT '配置:key=名称,value=值', `multiplejson` varchar(1500) DEFAULT '' COMMENT '二维数组:title=标题,intro=介绍,author=作者,age=年龄', `price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '价格', `views` int(10) unsigned DEFAULT '0' COMMENT '点击', @@ -423,7 +424,7 @@ CREATE TABLE `fa_test` ( -- Records of fa_test -- ---------------------------- BEGIN; -INSERT INTO `fa_test` VALUES (1, 1, 1, 12, '12,13', '互联网,计算机', 'monday', 'hot,index', 'male', 'music,reading', '我是一篇测试文章', '

我是测试内容

', '/assets/img/avatar.png', '/assets/img/avatar.png,/assets/img/qrcode.png', '/assets/img/avatar.png', '关键字', '我是一篇测试文章描述,内容过多时将自动隐藏', '广西壮族自治区/百色市/平果县', '{\"a\":\"1\",\"b\":\"2\"}', '[{\"title\":\"标题一\",\"intro\":\"介绍一\",\"author\":\"小明\",\"age\":\"21\"}]', 0.00, 0, '2020-10-01 00:00:00 - 2021-10-31 23:59:59', '2017-07-10', '2017-07-10 18:24:45', 2017, '18:24:45', 1491635035, 1491635035, 1491635035, NULL, 0, 1, 'normal', '1'); +INSERT INTO `fa_test` VALUES (1, 1, 1, 12, '12,13', '互联网,计算机', 'monday', 'hot,index', 'male', 'music,reading', '我是一篇测试文章', '

我是测试内容

', '/assets/img/avatar.png', '/assets/img/avatar.png,/assets/img/qrcode.png', '/assets/img/avatar.png', '关键字', '我是一篇测试文章描述,内容过多时将自动隐藏', '广西壮族自治区/百色市/平果县', '[\"a\",\"b\"]', '{\"a\":\"1\",\"b\":\"2\"}', '[{\"title\":\"标题一\",\"intro\":\"介绍一\",\"author\":\"小明\",\"age\":\"21\"}]', 0.00, 0, '2020-10-01 00:00:00 - 2021-10-31 23:59:59', '2017-07-10', '2017-07-10 18:24:45', 2017, '18:24:45', 1491635035, 1491635035, 1491635035, NULL, 0, 1, 'normal', '1'); COMMIT; -- ---------------------------- @@ -468,7 +469,7 @@ CREATE TABLE `fa_user` ( -- Records of fa_user -- ---------------------------- BEGIN; -INSERT INTO `fa_user` VALUES (1, 1, 'admin', 'admin', '', '', 'admin@163.com', '13888888888', '', 0, 0, '2017-04-08', '', 0, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal',''); +INSERT INTO `fa_user` VALUES (1, 1, 'admin', 'admin', '', '', 'admin@163.com', '13000000000', '', 0, 0, '2017-04-08', '', 0, 0, 1, 1, 1491635035, 1491635035, '127.0.0.1', 0, '127.0.0.1', 1491635035, 0, 1491635035, '', 'normal',''); COMMIT; -- ---------------------------- diff --git a/application/admin/controller/Addon.php b/application/admin/controller/Addon.php index 355ddab6..8fc7a886 100644 --- a/application/admin/controller/Addon.php +++ b/application/admin/controller/Addon.php @@ -95,19 +95,24 @@ class Addon extends Backend } $tips = []; $groupList = []; + $ungroupList = []; foreach ($config as $index => &$item) { //如果有设置分组 if (isset($item['group']) && $item['group']) { if (!in_array($item['group'], $groupList)) { $groupList["custom" . (count($groupList) + 1)] = $item['group']; } + } elseif ($item['name'] != '__tips__') { + $ungroupList[] = $item['name']; } if ($item['name'] == '__tips__') { $tips = $item; unset($config[$index]); } } - $groupList['other'] = '其它'; + if ($ungroupList) { + $groupList['other'] = '其它'; + } $this->view->assign("groupList", $groupList); $this->view->assign("addon", ['info' => $info, 'config' => $config, 'tips' => $tips]); $configFile = ADDON_PATH . $name . DS . 'config.html'; @@ -230,6 +235,7 @@ class Addon extends Backend $uid = $this->request->post("uid"); $token = $this->request->post("token"); $faversion = $this->request->post("faversion"); + $force = $this->request->post("force"); if (!$uid || !$token) { throw new Exception(__('Please login and try to install')); } @@ -238,7 +244,7 @@ class Addon extends Backend 'token' => $token, 'faversion' => $faversion ]; - $info = Service::local($file, $extend); + $info = Service::local($file, $extend, $force); } catch (AddonException $e) { $this->result($e->getData(), $e->getCode(), __($e->getMessage())); } catch (Exception $e) { @@ -441,8 +447,11 @@ class Addon extends Backend } catch (\Exception $e) { } - $rows = isset($json['rows']) ? $json['rows'] : []; + $rows = $json['rows'] ?? []; foreach ($rows as $index => $row) { + if (!isset($row['name'])) { + continue; + } $onlineaddons[$row['name']] = $row; } Cache::set("onlineaddons", $onlineaddons, 600); diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 63c2ba92..fe560fb3 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -44,7 +44,6 @@ class Index extends Backend 'dashboard' => 'hot', 'addon' => ['new', 'red', 'badge'], 'auth/rule' => __('Menu'), - 'general' => ['new', 'purple'], ], $this->view->site['fixedpage']); $action = $this->request->request('action'); if ($this->request->isPost()) { @@ -66,7 +65,8 @@ class Index extends Backend */ public function login() { - $url = $this->request->get('url', 'index/index', 'url_clean'); + $url = $this->request->get('url', '', 'url_clean'); + $url = $url ?: 'index/index'; if ($this->auth->isLogin()) { $this->success(__("You've logged in, do not login again"), $url); } @@ -74,7 +74,7 @@ class Index extends Backend $keeyloginhours = 24; if ($this->request->isPost()) { $username = $this->request->post('username'); - $password = $this->request->post('password'); + $password = $this->request->post('password', '', null); $keeplogin = $this->request->post('keeplogin'); $token = $this->request->post('__token__'); $rule = [ diff --git a/application/admin/controller/auth/Adminlog.php b/application/admin/controller/auth/Adminlog.php index 9ed148ce..1d8cc810 100644 --- a/application/admin/controller/auth/Adminlog.php +++ b/application/admin/controller/auth/Adminlog.php @@ -53,6 +53,7 @@ class Adminlog extends Backend $query->where('admin_id', 'in', $childrenAdminIds); } }) + ->field('content,useragent', true) ->order($sort, $order) ->paginate($limit); diff --git a/application/admin/controller/general/Profile.php b/application/admin/controller/general/Profile.php index feffa995..63b765c9 100644 --- a/application/admin/controller/general/Profile.php +++ b/application/admin/controller/general/Profile.php @@ -74,6 +74,7 @@ class Profile extends Backend $admin->save($params); //因为个人资料面板读取的Session显示,修改自己资料后同时更新Session Session::set("admin", $admin->toArray()); + Session::set("admin.safecode", $this->auth->getEncryptSafecode($admin)); $this->success(); } $this->error(); diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index ba373e56..6908ad67 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -24,7 +24,7 @@ class User extends Backend public function _initialize() { parent::_initialize(); - $this->model = model('User'); + $this->model = new \app\admin\model\User; } /** diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index f2a7efd9..f0e1bc49 100755 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -4,6 +4,8 @@ return [ 'User id' => '会员ID', 'Username' => '用户名', 'Nickname' => '昵称', + 'Mobile' => '手机', + 'Email' => '邮箱', 'Password' => '密码', 'Mobile' => '手机号', 'Sign up' => '注 册', diff --git a/application/admin/lang/zh-cn/addon.php b/application/admin/lang/zh-cn/addon.php index 6c999d2a..abbcb254 100755 --- a/application/admin/lang/zh-cn/addon.php +++ b/application/admin/lang/zh-cn/addon.php @@ -14,11 +14,8 @@ return [ 'Refresh addon cache' => '刷新插件缓存', 'Userinfo' => '会员信息', 'Reload authorization' => '刷新授权', - 'Online store' => '在线商店', 'Local addon' => '本地插件', 'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作', - 'Login tips' => '此处登录账号为FastAdmin官网账号', - 'Logined tips' => '你好!%s
当前你已经登录,将同步保存你的购买记录', 'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!', 'Pay successful tips' => '购买成功!请点击继续安装按钮完成安装!', 'Pay click tips' => '请点击这里在新窗口中进行支付!', @@ -26,8 +23,7 @@ return [ 'Upgrade tips' => '确认升级《%s》

1、请务必做好代码和数据库备份!备份!备份!
2、升级后如出现冗余数据,请根据需要移除即可!
3、不建议在生产环境升级,请在本地完成升级测试

如有重要数据请备份后再操作!', 'Offline installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!', 'Online installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!', - 'Not login tips' => '你当前未登录FastAdmin,请登录后操作!', - 'Please login and try to install' => '请登录FastAdmin后再进行离线安装!', + 'Please login and try to install' => '请登录FastAdmin后再进行本地安装!', 'Not installed tips' => '请安装后再访问插件前台页面!', 'Not enabled tips' => '插件已经禁用,请启用后再访问插件前台页面!', 'New version tips' => '发现新版本:%s 点击查看更新日志', @@ -37,6 +33,7 @@ return [ 'Store not available tips' => '插件市场暂不可用,是否切换到本地插件?', 'Switch to the local' => '切换到本地插件', 'try to reload' => '重新尝试加载', + 'Please disable addon first' => '请先禁用插件再进行操作', 'Please disable the add before trying to upgrade' => '请先禁用插件再进行升级', 'Please disable the add before trying to uninstall' => '请先禁用插件再进行卸载', 'Login now' => '立即登录', @@ -80,7 +77,6 @@ return [ 'Enable' => '启用', 'Your username or email' => '你的手机号、用户名或邮箱', 'Your password' => '你的密码', - 'Login FastAdmin' => '登录', 'Login' => '登录', 'Logout' => '退出登录', 'Register' => '注册账号', diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index 4d3eed7a..9332cdbb 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -339,7 +339,7 @@ class Auth extends \fast\Auth } } // 取出所有分组 - $groupList = \app\admin\model\AuthGroup::where(['status' => 'normal'])->select(); + $groupList = \app\admin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->select(); $objList = []; foreach ($groups as $k => $v) { if ($v['rules'] === '*') { @@ -371,8 +371,7 @@ class Auth extends \fast\Auth $childrenAdminIds = []; if (!$this->isSuperAdmin()) { $groupIds = $this->getChildrenGroupIds(false); - $authGroupList = \app\admin\model\AuthGroupAccess:: - field('uid,group_id') + $authGroupList = \app\admin\model\AuthGroupAccess::field('uid,group_id') ->where('group_id', 'in', $groupIds) ->select(); foreach ($authGroupList as $k => $v) { @@ -418,7 +417,6 @@ class Auth extends \fast\Auth $titleArr[$pathArr[$rule['name']]] = $rule['title']; $menuArr[$pathArr[$rule['name']]] = $rule; } - } ksort($menuArr); $this->breadcrumb = $menuArr; @@ -444,9 +442,9 @@ class Auth extends \fast\Auth foreach ($params as $k => $v) { $url = $k; if (is_array($v)) { - $nums = isset($v[0]) ? $v[0] : 0; - $color = isset($v[1]) ? $v[1] : $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums]; - $class = isset($v[2]) ? $v[2] : 'label'; + $nums = $v[0] ?? 0; + $color = $v[1] ?? $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums]; + $class = $v[2] ?? 'label'; } else { $nums = $v; $color = $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums]; @@ -485,7 +483,7 @@ class Auth extends \fast\Auth } $v['icon'] = $v['icon'] . ' fa-fw'; $v['url'] = isset($v['url']) && $v['url'] ? $v['url'] : '/' . $module . '/' . $v['name']; - $v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : ''; + $v['badge'] = $badgeList[$v['name']] ?? ''; $v['title'] = __($v['title']); $v['url'] = preg_match("/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i", $v['url']) ? $v['url'] : url($v['url']); $v['menuclass'] = in_array($v['menutype'], ['dialog', 'ajax']) ? 'btn-' . $v['menutype'] : ''; diff --git a/application/admin/library/traits/Backend.php b/application/admin/library/traits/Backend.php index fc7032b5..df96bb36 100755 --- a/application/admin/library/traits/Backend.php +++ b/application/admin/library/traits/Backend.php @@ -460,7 +460,7 @@ trait Backend if ($has_admin_id) { $auth = Auth::instance(); foreach ($insert as &$val) { - if (!isset($val['admin_id']) || empty($val['admin_id'])) { + if (empty($val['admin_id'])) { $val['admin_id'] = $auth->isLogin() ? $auth->id : 0; } } diff --git a/application/admin/model/AdminLog.php b/application/admin/model/AdminLog.php index faf7e562..07e33036 100644 --- a/application/admin/model/AdminLog.php +++ b/application/admin/model/AdminLog.php @@ -41,8 +41,8 @@ class AdminLog extends Model /** * 记录日志 - * @param string $title - * @param string $content + * @param string $title 日志标题 + * @param string $content 日志内容 */ public static function record($title = '', $content = '') { @@ -50,6 +50,9 @@ class AdminLog extends Model $admin_id = $auth->isLogin() ? $auth->id : 0; $username = $auth->isLogin() ? $auth->username : __('Unknown'); + // 设置过滤函数 + request()->filter('trim,strip_tags,htmlspecialchars'); + $controllername = Loader::parseName(request()->controller()); $actionname = strtolower(request()->action()); $path = str_replace('.', '/', $controllername) . '/' . $actionname; @@ -60,12 +63,12 @@ class AdminLog extends Model } } } - $content = $content ? $content : self::$content; + $content = $content ?: self::$content; if (!$content) { - $content = request()->param('', null, 'trim,strip_tags,htmlspecialchars'); + $content = request()->param('') ?: file_get_contents("php://input"); $content = self::getPureContent($content); } - $title = $title ? $title : self::$title; + $title = $title ?: self::$title; if (!$title) { $title = []; $breadcrumb = Auth::instance()->getBreadcrumb($path); @@ -77,18 +80,18 @@ class AdminLog extends Model self::create([ 'title' => $title, 'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content, - 'url' => substr(request()->url(), 0, 1500), + 'url' => substr(xss_clean(strip_tags(request()->url())), 0, 1500), 'admin_id' => $admin_id, 'username' => $username, 'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255), - 'ip' => request()->ip() + 'ip' => xss_clean(strip_tags(request()->ip())) ]); } /** * 获取已屏蔽关键信息的数据 * @param $content - * @return false|string + * @return array */ protected static function getPureContent($content) { diff --git a/application/admin/view/addon/config.html b/application/admin/view/addon/config.html index e5220cdd..ec8e5317 100644 --- a/application/admin/view/addon/config.html +++ b/application/admin/view/addon/config.html @@ -105,6 +105,12 @@ {/case} + {case switch} + + + + + {/case} {case bool} diff --git a/application/admin/view/addon/index.html b/application/admin/view/addon/index.html index 0e179389..e72defaf 100644 --- a/application/admin/view/addon/index.html +++ b/application/admin/view/addon/index.html @@ -160,13 +160,18 @@
<%=#__("Are you sure you want to unstall %s?", addon['title'])%>

{:__('Delete all the addon file and cannot be recovered!')}

- {if config('app_debug')} + {if config('app_debug')}

{:__('Delete all the addon database and cannot be recovered!')}

- {/if} + {/if}

{:__('Please backup important data manually before uninstall!')}

+