diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index 619afa97..5b556af3 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -392,24 +392,24 @@ CREATE TABLE `fa_sms` ( DROP TABLE IF EXISTS `fa_test`; CREATE TABLE `fa_test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', - `admin_id` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID', - `category_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '分类ID(单选)', - `category_ids` varchar(100) NOT NULL COMMENT '分类ID(多选)', - `week` enum('monday','tuesday','wednesday') NOT NULL COMMENT '星期(单选):monday=星期一,tuesday=星期二,wednesday=星期三', + `admin_id` int(10) DEFAULT '0' COMMENT '管理员ID', + `category_id` int(10) unsigned DEFAULT '0' COMMENT '分类ID(单选)', + `category_ids` varchar(100) COMMENT '分类ID(多选)', + `week` enum('monday','tuesday','wednesday') COMMENT '星期(单选):monday=星期一,tuesday=星期二,wednesday=星期三', `flag` set('hot','index','recommend') DEFAULT '' COMMENT '标志(多选):hot=热门,index=首页,recommend=推荐', - `genderdata` enum('male','female') NOT NULL DEFAULT 'male' COMMENT '性别(单选):male=男,female=女', - `hobbydata` set('music','reading','swimming') NOT NULL COMMENT '爱好(多选):music=音乐,reading=读书,swimming=游泳', - `title` varchar(50) DEFAULT '' COMMENT '标题', - `content` text NOT NULL COMMENT '内容', + `genderdata` enum('male','female') DEFAULT 'male' COMMENT '性别(单选):male=男,female=女', + `hobbydata` set('music','reading','swimming') COMMENT '爱好(多选):music=音乐,reading=读书,swimming=游泳', + `title` varchar(100) DEFAULT '' COMMENT '标题', + `content` text COMMENT '内容', `image` varchar(100) DEFAULT '' COMMENT '图片', `images` varchar(1500) DEFAULT '' COMMENT '图片组', `attachfile` varchar(100) DEFAULT '' COMMENT '附件', - `keywords` varchar(100) DEFAULT '' COMMENT '关键字', + `keywords` varchar(255) DEFAULT '' COMMENT '关键字', `description` varchar(255) DEFAULT '' COMMENT '描述', `city` varchar(100) DEFAULT '' COMMENT '省市', `json` varchar(255) DEFAULT NULL COMMENT '配置:key=名称,value=值', - `price` float(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '价格', - `views` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点击', + `price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '价格', + `views` int(10) unsigned DEFAULT '0' COMMENT '点击', `startdate` date DEFAULT NULL COMMENT '开始日期', `activitytime` datetime DEFAULT NULL COMMENT '活动时间(datetime)', `year` year(4) DEFAULT NULL COMMENT '年', @@ -418,10 +418,10 @@ CREATE TABLE `fa_test` ( `createtime` int(10) DEFAULT NULL COMMENT '创建时间', `updatetime` int(10) DEFAULT NULL COMMENT '更新时间', `deletetime` int(10) DEFAULT NULL COMMENT '删除时间', - `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', - `switch` tinyint(1) NOT NULL DEFAULT '0' COMMENT '开关', - `status` enum('normal','hidden') NOT NULL DEFAULT 'normal' COMMENT '状态', - `state` enum('0','1','2') NOT NULL DEFAULT '1' COMMENT '状态值:0=禁用,1=正常,2=推荐', + `weigh` int(10) DEFAULT '0' COMMENT '权重', + `switch` tinyint(1) DEFAULT '0' COMMENT '开关', + `status` enum('normal','hidden') DEFAULT 'normal' COMMENT '状态', + `state` enum('0','1','2') DEFAULT '1' COMMENT '状态值:0=禁用,1=正常,2=推荐', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='测试表'; diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index 61bd278e..4c68e237 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -417,8 +417,7 @@ class Auth extends \fast\Auth ->where('ismenu', 0) ->where('name', 'like', '%/index') ->column('name,pid'); - $pidArr = array_unique(array_column($ruleList, 'pid')); - unset($pidArr[0]); + $pidArr = array_unique(array_filter(array_column($ruleList, 'pid'))); foreach ($ruleList as $k => &$v) { if (!in_array($v['name'], $userRule)) { unset($ruleList[$k]); @@ -439,8 +438,7 @@ class Auth extends \fast\Auth $selected = $v['name'] == $fixedPage ? $v : $selected; $referer = $v['url'] == $refererUrl ? $v : $referer; } - $lastArr = array_unique(array_column($ruleList, 'pid')); - unset($lastArr[0]); + $lastArr = array_unique(array_filter(array_column($ruleList, 'pid'))); $pidDiffArr = array_diff($pidArr, $lastArr); foreach ($ruleList as $index => $item) { if (in_array($item['id'], $pidDiffArr)) { diff --git a/application/admin/model/AuthRule.php b/application/admin/model/AuthRule.php index c50af8e6..871a820e 100644 --- a/application/admin/model/AuthRule.php +++ b/application/admin/model/AuthRule.php @@ -44,14 +44,16 @@ class AuthRule extends Model return ['addtabs' => __('Addtabs'), 'dialog' => __('Dialog'), 'ajax' => __('Ajax'), 'blank' => __('Blank')]; } - public function setPyAttr($value, $data) { + public function setPyAttr($value, $data) + { if (isset($data['title']) && $data['title']) { return self::$pinyin->abbr($data['title']); } return ''; } - public function setPinyinAttr($value, $data) { + public function setPinyinAttr($value, $data) + { if (isset($data['title']) && $data['title']) { return self::$pinyin->permalink($data['title'], ''); } diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 27bce621..4b3c78fb 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -134,33 +134,6 @@ class Backend extends Controller // 检测IP是否允许 check_ip_allowed(); - $this->auth = Auth::instance(); - - // 设置当前请求的URI - $this->auth->setRequestUri($path); - // 检测是否需要验证登录 - if (!$this->auth->match($this->noNeedLogin)) { - //检测是否登录 - if (!$this->auth->isLogin()) { - Hook::listen('admin_nologin', $this); - $url = Session::get('referer'); - $url = $url ? $url : $this->request->url(); - if ($url == '/') { - $this->redirect('index/login', [], 302, ['referer' => $url]); - exit; - } - $this->error(__('Please login first'), url('index/login', ['url' => $url])); - } - // 判断是否需要验证权限 - if (!$this->auth->match($this->noNeedRight)) { - // 判断控制器和方法是否有对应权限 - if (!$this->auth->check($path)) { - Hook::listen('admin_nopermission', $this); - $this->error(__('You have no permission'), ''); - } - } - } - // 非选项卡时重定向 if (!$this->request->isPost() && !IS_AJAX && !IS_ADDTABS && !IS_DIALOG && input("ref") == 'addtabs') { $url = preg_replace_callback("/([\?|&]+)ref=addtabs(&?)/i", function ($matches) { @@ -176,6 +149,33 @@ class Backend extends Controller exit; } + $this->auth = Auth::instance(); + + // 设置当前请求的URI + $this->auth->setRequestUri($path); + // 检测是否需要验证登录 + if (!$this->auth->match($this->noNeedLogin)) { + //检测是否登录 + if (!$this->auth->isLogin()) { + Hook::listen('admin_nologin', $this); + $url = Session::get('referer'); + $url = $url ? $url : $this->request->url(); + if (in_array($this->request->pathinfo(), ['/', 'index/index'])) { + $this->redirect('index/login', [], 302, ['referer' => $url]); + exit; + } + $this->error(__('Please login first'), url('index/login', ['url' => $url])); + } + // 判断是否需要验证权限 + if (!$this->auth->match($this->noNeedRight)) { + // 判断控制器和方法是否有对应权限 + if (!$this->auth->check($path)) { + Hook::listen('admin_nopermission', $this); + $this->error(__('You have no permission'), ''); + } + } + } + // 设置面包屑导航数据 $breadcrumb = []; if (!IS_DIALOG && !config('fastadmin.multiplenav') && config('fastadmin.breadcrumb')) { diff --git a/application/extra/addons.php b/application/extra/addons.php index 0fc7fe5c..21774683 100644 --- a/application/extra/addons.php +++ b/application/extra/addons.php @@ -5,4 +5,5 @@ return [ 'hooks' => [], 'route' => [], 'priority' => [], + 'domain' => '', ]; diff --git a/application/index/view/common/meta.html b/application/index/view/common/meta.html index 7e0f993e..365cb20d 100644 --- a/application/index/view/common/meta.html +++ b/application/index/view/common/meta.html @@ -1,18 +1,18 @@ -{$title|default=''} – {$site.name} +{$title|default=''|htmlentities} – {$site.name|htmlentities} {if isset($keywords)} - + {/if} {if isset($description)} - + {/if} - + @@ -33,7 +33,7 @@ - {$site.name} + {$site.name|htmlentities}