modified 进一步修复因为表前缀引发的BUG

This commit is contained in:
zhaoxiang 2016-11-21 23:57:16 +08:00
parent d9e4de54c7
commit 5b5d2b3763
3 changed files with 10 additions and 10 deletions

View File

@ -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',
]

View File

@ -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');

View File

@ -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']]) ){