From b9a63cb00483f15f9f9f3a99954e847517dea55a Mon Sep 17 00:00:00 2001 From: brotherand2 <547996854@qq.com> Date: Sat, 16 Jan 2021 22:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=B7=A5=E5=85=B7=E8=8B=A5=E5=B9=B2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utility/restore.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/utility/restore.php b/utility/restore.php index 100abec1d..6dd136ede 100644 --- a/utility/restore.php +++ b/utility/restore.php @@ -124,14 +124,17 @@ if($operation == 'import') { show_msg('database_import_succeed', '', 'message', 1); } } elseif($dumpinfo['method'] == 'shell') { - + $dbhost = $_config['db'][1]['dbhost']; + $dbname = $_config['db'][1]['dbname']; + $dbpw = $_config['db'][1]['dbpw']; + $dbuser = $_config['db'][1]['dbuser']; list($dbhost, $dbport) = explode(':', $dbhost); $query = $db->query("SHOW VARIABLES LIKE 'basedir'"); - list(, $mysql_base) = $db->fetch($query, $db->drivertype == 'mysqli' ? MYSQLI_NUM : MYSQL_NUM); - + list(, $mysql_base) = $db->fetch_array($query, $db->drivertype == 'mysqli' ? MYSQLI_NUM : MYSQL_NUM); + $datafile = addslashes(dirname(dirname(__FILE__))).str_replace('..', '', $datafile) ; $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/'; shell_exec($mysqlbin.'mysql -h"'.$dbhost.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : ''). - '" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.getgpc('datafile')); + '" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile); show_msg('database_import_succeed', '', 'message', 1); } else { @@ -317,14 +320,14 @@ function show_importfile_list($exportlog = array(), $exportziplog = array(), $ex } foreach($exportziplog as $key => $val) { - + sort($val);//确保-1.zip排前面,才会自动解压-2.zip $info = $val[0]; $info['dateline'] = is_int($info['dateline']) ? gmdate('Y-m-d H:i:s', $info['dateline'] + 3600 * 8) : lang('unknown'); $info['size'] = sizecount($info['size']); $info['method'] = $info['method'] == 'multivol' ? lang('db_multivol') : lang('db_zip'); echo ""; echo - "".basename($info['filename'])."", + "".basename($info['filename'])."", "".dirname($info['filename'])."", "".$info['dateline']."", "".lang('db_export_'.$info['type'])."", @@ -333,7 +336,7 @@ function show_importfile_list($exportlog = array(), $exportziplog = array(), $ex "".lang('db_import_unzip')."" ; echo "\n"; - echo ''; + echo ''; foreach($val as $info) { $info['dateline'] = is_int($info['dateline']) ? gmdate('Y-m-d H:i:s', $info['dateline'] + 3600 * 8) : lang('unknown'); $info['size'] = sizecount($info['size']); @@ -558,6 +561,7 @@ function lang($lang_key, $force = true, $replace = array()) { 'db_export_discuz_uc' => 'Discuz! 和 UCenter 数据', 'db_multivol' => '多卷', 'db_import_unzip' => '解压缩', + 'db_export_custom' => '自定义备份', 'db_export_zip' => '压缩备份', 'db_zip' => 'ZIP', 'db_shell' => 'Shell', -- Gitee