From 5b5d2b376318bf8a15599a682676602f4aad5150 Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Mon, 21 Nov 2016 23:57:16 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E8=BF=9B=E4=B8=80=E6=AD=A5=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=9B=A0=E4=B8=BA=E8=A1=A8=E5=89=8D=E7=BC=80=E5=BC=95?= =?UTF-8?q?=E5=8F=91=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/install/common.php | 4 ++-- application/install/controller/Index.php | 10 +++++----- extend/Permission.php | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/application/install/common.php b/application/install/common.php index fa839a5..d831828 100644 --- a/application/install/common.php +++ b/application/install/common.php @@ -68,7 +68,7 @@ function checkDirFile(){ $items = [ [ 'type' => 'file', - 'path' => APP_PATH . 'database.php', + 'path' => realpath(APP_PATH) .DS. 'database.php', 'title' => '可写', 'icon' => 'fa fa-check text-success', ], @@ -80,7 +80,7 @@ function checkDirFile(){ ], [ 'type' => 'dir', - 'path' => APP_PATH . 'extra' . DS, + 'path' => realpath(APP_PATH) .DS. 'extra' . DS, 'title' => '可写', 'icon' => 'fa fa-check text-success', ] diff --git a/application/install/controller/Index.php b/application/install/controller/Index.php index c4b4314..4840262 100644 --- a/application/install/controller/Index.php +++ b/application/install/controller/Index.php @@ -229,9 +229,9 @@ class Index extends Controller { session('error', true); } }elseif ( strpos($value, 'DROP TABLE') !== false ){ - $name = preg_replace('/.*DROP TABLE IF EXISTS `(\w+)` .*/s', '\1', $value); - $value = str_replace(" `{$name}", " `{$prefix}{$name}", $value); - $msg = "删除数据表{$name}"; + preg_match('/DROP TABLE IF EXISTS `(.*)`.*?/s', $value, $name); + $value = str_replace("DROP TABLE IF EXISTS `{$name[1]}`", "DROP TABLE IF EXISTS `{$prefix}{$name[1]}`", $value); + $msg = "删除数据表{$name[1]}"; if (false !== $db->exec($value)) { Log::record($value,'log'); showMsg($msg . '...成功', 'success'); @@ -242,7 +242,7 @@ class Index extends Controller { } }elseif ( strpos($value, 'LOCK TABLES') !== false ){ $name = preg_replace('/^LOCK TABLES `(\w+)` .*/s', '\1', $value); - $value = str_replace(" `{$name}", " `{$prefix}{$name}", $value); + $value = str_replace("LOCK TABLES `{$name}", "LOCK TABLES `{$prefix}{$name}", $value); $msg = "锁定数据表{$name}"; if (false !== $db->exec($value)) { Log::record($value,'log'); @@ -254,7 +254,7 @@ class Index extends Controller { } }elseif ( strpos($value, 'INSERT INTO') !== false ){ $name = preg_replace('/^INSERT INTO `(\w+)` .*/s', '\1', $value); - $value = str_replace(" `{$name}", " `{$prefix}{$name}", $value); + $value = str_replace("INSERT INTO `{$name}`", "INSERT INTO `{$prefix}{$name}`", $value); $msg = "初始化表{$name}数据"; if (false !== $db->exec($value)) { Log::record($value,'log'); diff --git a/extend/Permission.php b/extend/Permission.php index 61a9c63..ea6b33e 100644 --- a/extend/Permission.php +++ b/extend/Permission.php @@ -101,11 +101,11 @@ class Permission { if ( isset($groups[$uid]) ) { return $groups[$uid]; } - $userGroups = \think\Db::table($this->_config['AUTH_GROUP_ACCESS'])->where(['uid' => $uid])->select(); + $userGroups = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_GROUP_ACCESS'])->where(['uid' => $uid])->select(); if( !empty($userGroups) ){ $groups[$uid] = []; foreach( $userGroups as $value ){ - $groupInfo = \think\Db::table($this->_config['AUTH_GROUP'])->where(['id' => $value['group_id']])->find(); + $groupInfo = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_GROUP'])->where(['id' => $value['group_id']])->find(); if( !is_null($groupInfo) ){ if( $groupInfo['status'] != 1 ){ continue; @@ -148,7 +148,7 @@ class Permission { $authList = []; foreach ($groups as $g) { - $groupRule = \think\Db::table($this->_config['AUTH_RULE'])->where(['group_id' => $g])->select(); + $groupRule = \think\Db::table(config('database')['prefix'].$this->_config['AUTH_RULE'])->where(['group_id' => $g])->select(); if( !empty($groupRule) ){ foreach ( $groupRule as $groupValue ){ if( isset($authList[$groupValue['url']]) ){