mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-24 18:30:18 +08:00
modified 进一步修复因为表前缀引发的BUG
This commit is contained in:
parent
d9e4de54c7
commit
5b5d2b3763
@ -68,7 +68,7 @@ function checkDirFile(){
|
|||||||
$items = [
|
$items = [
|
||||||
[
|
[
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'path' => APP_PATH . 'database.php',
|
'path' => realpath(APP_PATH) .DS. 'database.php',
|
||||||
'title' => '可写',
|
'title' => '可写',
|
||||||
'icon' => 'fa fa-check text-success',
|
'icon' => 'fa fa-check text-success',
|
||||||
],
|
],
|
||||||
@ -80,7 +80,7 @@ function checkDirFile(){
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => 'dir',
|
'type' => 'dir',
|
||||||
'path' => APP_PATH . 'extra' . DS,
|
'path' => realpath(APP_PATH) .DS. 'extra' . DS,
|
||||||
'title' => '可写',
|
'title' => '可写',
|
||||||
'icon' => 'fa fa-check text-success',
|
'icon' => 'fa fa-check text-success',
|
||||||
]
|
]
|
||||||
|
@ -229,9 +229,9 @@ class Index extends Controller {
|
|||||||
session('error', true);
|
session('error', true);
|
||||||
}
|
}
|
||||||
}elseif ( strpos($value, 'DROP TABLE') !== false ){
|
}elseif ( strpos($value, 'DROP TABLE') !== false ){
|
||||||
$name = preg_replace('/.*DROP TABLE IF EXISTS `(\w+)` .*/s', '\1', $value);
|
preg_match('/DROP TABLE IF EXISTS `(.*)`.*?/s', $value, $name);
|
||||||
$value = str_replace(" `{$name}", " `{$prefix}{$name}", $value);
|
$value = str_replace("DROP TABLE IF EXISTS `{$name[1]}`", "DROP TABLE IF EXISTS `{$prefix}{$name[1]}`", $value);
|
||||||
$msg = "删除数据表{$name}";
|
$msg = "删除数据表{$name[1]}";
|
||||||
if (false !== $db->exec($value)) {
|
if (false !== $db->exec($value)) {
|
||||||
Log::record($value,'log');
|
Log::record($value,'log');
|
||||||
showMsg($msg . '...成功', 'success');
|
showMsg($msg . '...成功', 'success');
|
||||||
@ -242,7 +242,7 @@ class Index extends Controller {
|
|||||||
}
|
}
|
||||||
}elseif ( strpos($value, 'LOCK TABLES') !== false ){
|
}elseif ( strpos($value, 'LOCK TABLES') !== false ){
|
||||||
$name = preg_replace('/^LOCK TABLES `(\w+)` .*/s', '\1', $value);
|
$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}";
|
$msg = "锁定数据表{$name}";
|
||||||
if (false !== $db->exec($value)) {
|
if (false !== $db->exec($value)) {
|
||||||
Log::record($value,'log');
|
Log::record($value,'log');
|
||||||
@ -254,7 +254,7 @@ class Index extends Controller {
|
|||||||
}
|
}
|
||||||
}elseif ( strpos($value, 'INSERT INTO') !== false ){
|
}elseif ( strpos($value, 'INSERT INTO') !== false ){
|
||||||
$name = preg_replace('/^INSERT INTO `(\w+)` .*/s', '\1', $value);
|
$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}数据";
|
$msg = "初始化表{$name}数据";
|
||||||
if (false !== $db->exec($value)) {
|
if (false !== $db->exec($value)) {
|
||||||
Log::record($value,'log');
|
Log::record($value,'log');
|
||||||
|
@ -101,11 +101,11 @@ class Permission {
|
|||||||
if ( isset($groups[$uid]) ) {
|
if ( isset($groups[$uid]) ) {
|
||||||
return $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) ){
|
if( !empty($userGroups) ){
|
||||||
$groups[$uid] = [];
|
$groups[$uid] = [];
|
||||||
foreach( $userGroups as $value ){
|
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( !is_null($groupInfo) ){
|
||||||
if( $groupInfo['status'] != 1 ){
|
if( $groupInfo['status'] != 1 ){
|
||||||
continue;
|
continue;
|
||||||
@ -148,7 +148,7 @@ class Permission {
|
|||||||
|
|
||||||
$authList = [];
|
$authList = [];
|
||||||
foreach ($groups as $g) {
|
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) ){
|
if( !empty($groupRule) ){
|
||||||
foreach ( $groupRule as $groupValue ){
|
foreach ( $groupRule as $groupValue ){
|
||||||
if( isset($authList[$groupValue['url']]) ){
|
if( isset($authList[$groupValue['url']]) ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user