diff --git a/upload/source/admincp/admincp_db.php b/upload/source/admincp/admincp_db.php
index 86ed490261e9e6059618774ab487731fc5f9a6fe..eb36c8f749e0fa65153903a331a5255ee00069c9 100644
--- a/upload/source/admincp/admincp_db.php
+++ b/upload/source/admincp/admincp_db.php
@@ -100,22 +100,22 @@ if($operation == 'export') {
showtitle('db_export_options');
showsetting('db_export_options_extended_insert', 'extendins', 0, 'radio');
showsetting('db_export_options_sql_compatible', array('sqlcompat', array(
- array('', $lang['default']),
+ array('0', $lang['default']),
array('MYSQL40', 'MySQL 3.23/4.0.x'),
array('MYSQL41', 'MySQL 4.1.x/5.x')
- )), '', 'mradio');
+ )), '0', 'mradio');
showsetting('db_export_options_charset', array('sqlcharset', array(
- array('', cplang('default')),
+ array('0', cplang('default')),
$dbcharset ? array($dbcharset, strtoupper($dbcharset)) : array(),
$db->version() > '4.1' && $dbcharset != 'utf8' ? array('utf8', 'UTF-8') : array()
- ), TRUE), 0, 'mradio');
+ ), TRUE), '0', 'mradio');
showsetting('db_export_usehex', 'usehex', 1, 'radio');
if(function_exists('gzcompress')) {
showsetting('db_export_usezip', array('usezip', array(
array('1', $lang['db_export_zip_1']),
array('2', $lang['db_export_zip_2']),
array('0', $lang['db_export_zip_3'])
- )), 0, 'mradio');
+ )), '0', 'mradio');
}
showsetting('db_export_filename', '', '', '.sql');
showtagfooter('tbody');
@@ -133,6 +133,18 @@ if($operation == 'export') {
cpmsg('database_export_filename_invalid', '', 'error');
}
+ if(!in_array($_GET['type'], array('discuz', 'discuz_uc', 'custom'))) {
+ $_GET['type'] = 'discuz';
+ }
+
+ if(!in_array($_GET['method'], array('multivol', 'shell'))) {
+ $_GET['method'] = 'multivol';
+ }
+
+ if(!$_GET['sqlcharset'] || !preg_match('/^[\w\_\-]+$/', $_GET['sqlcharset'])) {
+ $_GET['sqlcharset'] = strtolower($dbcharset);
+ }
+
$time = dgmdate(TIMESTAMP);
if($_GET['type'] == 'discuz' || $_GET['type'] == 'discuz_uc') {
$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
@@ -156,7 +168,7 @@ if($operation == 'export') {
}
$volume = intval($_GET['volume']) + 1;
- $idstring = '# Identify: '.base64_encode("$_G[timestamp],".$_G['setting']['version'].",{$_GET['type']},{$_GET['method']},{$volume},{$tablepre},{$dbcharset}")."\n";
+ $idstring = '# Identify: '.base64_encode("$_G[timestamp],".$_G['setting']['version'].",{$_GET['type']},{$_GET['method']},{$volume},{$tablepre},{$_GET['sqlcharset']}")."\n";
$dumpcharset = $_GET['sqlcharset'] ? $_GET['sqlcharset'] : str_replace('-', '', $_G['charset']);
@@ -209,7 +221,7 @@ if($operation == 'export') {
"# Type: {$_GET['type']}\n".
"# Table Prefix: $tablepre\n".
"#\n".
- "# Discuz! Home: http://www.discuz.com\n".
+ "# Discuz! Home: http://www.discuz.net\n".
"# Please visit our website for newest infomation about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
"$setnames".
@@ -314,9 +326,8 @@ if($operation == 'export') {
$dumpfile = addslashes(dirname(dirname(dirname(__FILE__)))).'/'.$backupfilename.'.sql';
@unlink($dumpfile);
- $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
- @shell_exec($mysqlbin.'mysqldump --force --quick '.($db->version() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($_GET['extendins'] == 1 ? ' --extended-insert' : '').''.($db->version() > '4.1' && $_GET['sqlcompat'] == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="'.$dbuser.'" --password="'.$dbpw.'" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);
-
+ $mysqlbin = $mysql_base == '/' ? '' : addslashes(rtrim($mysql_base, '/\\')).'/bin/';
+ @shell_exec($mysqlbin.'mysqldump --force --quick '.($db->version() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($_GET['extendins'] == 1 ? ' --extended-insert' : '').''.($db->version() > '4.1' && $_GET['sqlcompat'] == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.'"'.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').' --user="'.$dbuser.'" --password="'.$dbpw.'" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);
if(@file_exists($dumpfile)) {
if($_GET['usezip']) {
@@ -371,7 +382,7 @@ if($operation == 'export') {
if(!submitcheck('deletesubmit')) {
- $exportlog = $exportsize = $exportziplog = array();
+ $exportlog = $exportziplog = $exportsize = $exportzipsize = $exportfiletime = $exportzipfiletime = array();
if(is_dir(DISCUZ_ROOT.'./data/'.$backupdir)) {
$dir = dir(DISCUZ_ROOT.'./data/'.$backupdir);
while($entry = $dir->read()) {
@@ -379,6 +390,7 @@ if($operation == 'export') {
if(is_file($entry)) {
if(preg_match("/\.sql$/i", $entry)) {
$filesize = filesize($entry);
+ $filemtime = filemtime($entry);
$fp = fopen($entry, 'rb');
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
fclose($fp);
@@ -389,23 +401,33 @@ if($operation == 'export') {
'method' => $identify[3],
'volume' => $identify[4],
'filename' => $entry,
- 'dateline' => filemtime($entry),
+ 'dateline' => $filemtime,
'size' => $filesize
);
$exportsize[$key] += $filesize;
+ $exportfiletime[$key] = $filemtime;
} elseif(preg_match("/\.zip$/i", $entry)) {
- $key = preg_replace('/^(.+?)(\-\d+)\.zip$/i', '\\1', basename($entry));
+ $key = preg_replace('/^(.+?)(\-\d+)\.zip$/i', '\\1', basename($entry));
$filesize = filesize($entry);
- $exportziplog[$key] = array(
+ $filemtime = filemtime($entry);
+ $exportziplog[$key][] = array(
'type' => 'zip',
'filename' => $entry,
- 'size' => filesize($entry),
- 'dateline' => filemtime($entry)
+ 'size' => $filesize,
+ 'dateline' => $filemtime
);
+ $exportzipsize[$key] += $filesize;
+ $exportzipfiletime[$key] = $filemtime;
}
}
}
$dir->close();
+ if (!empty($exportlog)) {
+ array_multisort($exportfiletime, SORT_DESC, SORT_STRING, $exportlog);
+ }
+ if (!empty($exportziplog)) {
+ array_multisort($exportzipfiletime, SORT_DESC, SORT_STRING, $exportziplog);
+ }
} else {
cpmsg('database_export_dest_invalid', '', 'error');
}
@@ -437,18 +459,18 @@ if($operation == 'export') {
$info['dateline'] = is_int($info['dateline']) ? dgmdate($info['dateline']) : $lang['unknown'];
$info['size'] = sizecount($exportsize[$key]);
$info['volume'] = count($val);
- $info['method'] = $info['type'] != 'zip' ? ($info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell']) : '';
+ $info['method'] = $info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell'];
$datafile_server = '.'.$info['filename'];
showtablerow('', '', array(
"",
- "".$key."",
+ "".basename($info['filename'])."",
$info['version'],
$info['dateline'],
$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
- $info['volume'],
- $info['type'] == 'zip' ? "$lang[db_import_unzip]" : "$lang[import]"
+ "".$info['volume']."",
+ "$lang[import]"
));
echo '
';
foreach($val as $info) {
@@ -462,29 +484,30 @@ if($operation == 'export') {
'',
$info['size'],
'',
- $info['volume'],
+ '',
''
));
}
echo '';
}
- foreach($exportziplog as $info) {
- sort($val);//修改 确保-1.zip排前面,才会自动解压-2.zip
- $info = $val[0];
+ foreach($exportziplog as $key => $val) {
+ sort($val);//修改 确保-1.zip排前面,才会自动解压-2.zip
+ $info = $val[0];
+ $info['volume'] = count($val);
$info['dateline'] = is_int($info['dateline']) ? dgmdate($info['dateline']) : $lang['unknown'];
- $info['size'] = sizecount($info['size']);
+ $info['size'] = sizecount($exportzipsize[$key]);
$info['method'] = $info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_zip'];
$datafile_server = '.'.$info['filename'];
showtablerow('', '', array(
"",
- "".substr(strrchr($info['filename'], "/"), 1)."",
+ "".basename($info['filename'])."",
'',
$info['dateline'],
- $lang['db_export_'.$info['type']],
+ ($info['volume'] > 1 ? $lang['db_multivol'] : '').$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
- '',
+ "".$info['volume']."",
"$lang[db_import_unzip]"
));
echo '';
@@ -499,10 +522,11 @@ if($operation == 'export') {
'',
$info['size'],
'',
- "",
+ '',
''
));
}
+ echo '';
}
showsubmit('deletesubmit', 'submit', 'del');
@@ -534,7 +558,7 @@ if($operation == 'export') {
}
}
}
- cpmsg('database_file_delete_succeed', '', 'succeed');
+ cpmsg('database_file_delete_succeed', 'action=db&operation=import', 'succeed');
} else {
cpmsg('database_file_delete_invalid', '', 'error');
}
diff --git a/upload/source/language/lang_admincp.php b/upload/source/language/lang_admincp.php
index 756962e96ab46b9ff340c7aab78706268a001f53..09030495f23ad73ca0879e2d9cb20ca5b6157438 100644
--- a/upload/source/language/lang_admincp.php
+++ b/upload/source/language/lang_admincp.php
@@ -6031,7 +6031,7 @@ $lang = array
'db_import_confirm' => '导入和当前 Discuz! 版本不一致的数据极有可能产生无法解决的故障,您确定继续吗?',
'db_import_confirm_sql' => '您确定导入该备份吗?',
'db_import_confirm_zip' => '您确定解压该备份吗?',
- 'db_import_tips' => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。恢复数据前请在 Discuz! X2.5 安装文件目录下utility文件夹内找到 restore.php 文件,然后将 restore.php 文件上传到程序文件夹data目录下。为了您站点的安全,成功恢复数据后请务必及时删除 restore.php 文件。您可以在数据备份记录处查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。',
+ 'db_import_tips' => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。恢复数据前请在 Discuz! 安装文件目录下 utility 文件夹内找到 restore.php 文件,然后将 restore.php 文件上传到程序文件夹data目录下。为了您站点的安全,成功恢复数据后请务必及时删除 restore.php 文件。您可以在数据备份记录处查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。',
'do_import_option' => '- 您可以在本页面数据备份记录处导入备份恢复数据,也可以通过在浏览器中执行 {restore_url} 恢复数据',
'db_import_from_server' => '从服务器(填写文件名或 URL)',
'db_import_from_local' => '从本地文件',
diff --git a/upload/source/language/lang_admincp_searchindex.php b/upload/source/language/lang_admincp_searchindex.php
index c7db39f8ad782da3139fe2f3d00cfb7ffd45bc97..d29a0929d3018d61cfcd85e4b29ece55a14a2d3f 100644
--- a/upload/source/language/lang_admincp_searchindex.php
+++ b/upload/source/language/lang_admincp_searchindex.php
@@ -2234,7 +2234,7 @@ $lang = array (
17 => 'db_export_filename',
18 => '备份文件名',
19 => 'db_import_tips',
- 20 => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。恢复数据前请在 Discuz! X2.5 安装文件目录下utility文件夹内找到 restore.php 文件,然后将 restore.php 文件上传到程序文件夹data目录下。为了您站点的安全,成功恢复数据后请务必及时删除 restore.php 文件。您可以在数据备份记录处查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。',
+ 20 => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。恢复数据前请在 Discuz! 安装文件目录下 utility 文件夹内找到 restore.php 文件,然后将 restore.php 文件上传到程序文件夹data目录下。为了您站点的安全,成功恢复数据后请务必及时删除 restore.php 文件。您可以在数据备份记录处查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。',
21 => 'db_import',
22 => '数据恢复',
),
diff --git a/utility/restore.php b/utility/restore.php
index beaa7fcf3f4473b384eadce1038df6c99226e121..4400f99cc13d70665486e28a913eeb1ebba2fa42 100644
--- a/utility/restore.php
+++ b/utility/restore.php
@@ -41,13 +41,13 @@ if(!@$db->connect($_config['db']['1']['dbhost'], $_config['db']['1']['dbuser'],
if($operation == 'import') {
if(!submitcheck('importsubmit', 1)) {
- $exportlog = $exportsize = $exportziplog = array();
- check_exportfile($exportlog, $exportziplog, $exportsize);
+ $exportlog = $exportsize = $exportziplog = $exportzipsize = array();
+ check_exportfile($exportlog, $exportziplog, $exportsize, $exportzipsize);
if(empty($exportlog) && empty($exportziplog)) {
show_msg('backup_file_unexist');
}
- show_importfile_list($exportlog, $exportziplog, $exportsize);
+ show_importfile_list($exportlog, $exportziplog, $exportsize, $exportzipsize);
} else {
@@ -58,31 +58,34 @@ if($operation == 'import') {
} else {
$datafile = getgpc('datafile_server', 'G');
}
- $datafile = urldecode($datafile);
- if(!file_exists($datafile)) {
- if(getgpc('autoimport', 'G')) {
- touch($lock_file);
- show_msg('database_import_multivol_succeed', '', 'message', 1);
- } else {
- show_msg('database_import_file_illegal');
- }
+ if(!preg_match("#^\.\./data/backup_\w+/[\w\-]+\.sql$#i", $datafile)) {
+ touch($lock_file);
+ show_msg('database_import_format_illegal');
}
- if(@$fp = fopen($datafile, 'rb')) {
+ if(file_exists($datafile) && @$fp = fopen($datafile, 'rb')) {
$confirm = trim(getgpc('confirm', 'G'));
+ $delunzip = getgpc('delunzip', 'G');
+ $start = trim(getgpc('start', 'G'));
+ $start = $start ? 1 : 0;
+ if(!$start) {
+ show_msg(lang('database_import_multivol_start', TRUE, array()),
+ $siteurl."restore.php?operation=import&datafile_server=$datafile&autoimport=yes&importsubmit=yes&start=yes".(!empty($confirm) ? '&confirm=yes' : '').(!empty($delunzip) ? '&delunzip=yes' : ''),
+ 'redirect');
+ }
$confirm = $confirm ? 1 : 0;
$sqldump = fgets($fp, 256);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", $sqldump)));
- $dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]), 'tablepre' => $identify[5], 'dbcharset' => $identify[6]);
+ $dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]), 'tablepre' => $identify[5], 'dbcharset' => strtolower($identify[6]));
if(!$confirm) {
$showmsg = '';
if($dumpinfo['tablepre'] != $_config['db']['1']['tablepre'] && !getgpc('ignore_tablepre', 'G')) {
$showmsg .= lang('tableprediff');
}
- if($dumpinfo['dbcharset'] != $_config['db']['1']['dbcharset']) {
+ if($dumpinfo['dbcharset'] != strtolower($_config['db']['1']['dbcharset'])) {
$showmsg .= lang('dbcharsetdiff');
}
if($showmsg) {
- show_msg(lang('different_dbcharset_tablepre', TRUE, array('diff' => $showmsg)), $siteurl.'restore.php?operation=import&datafile_server='.$datafile.'&autoimport=yes&importsubmit=yes&confirm=yes', 'confirm');
+ show_msg(lang('different_dbcharset_tablepre', TRUE, array('diff' => $showmsg)), $siteurl.'restore.php?operation=import&datafile_server='.$datafile.'&autoimport=yes&importsubmit=yes&start=yes&confirm=yes', 'confirm');
}
}
@@ -115,7 +118,6 @@ if($operation == 'import') {
}
}
- $delunzip = getgpc('delunzip', 'G');
if($delunzip) {
@unlink($datafile);
}
@@ -124,14 +126,15 @@ if($operation == 'import') {
$datafile_next = urlencode($datafile_next);
if($dumpinfo['volume'] == 1) {
show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])),
- $siteurl."restore.php?operation=import&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes&confirm=yes".(!empty($delunzip) ? '&delunzip=yes' : ''),
+ $siteurl."restore.php?operation=import&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes&start=yes&confirm=yes".(!empty($delunzip) ? '&delunzip=yes' : ''),
'redirect');
} elseif(getgpc('autoimport', 'G')) {
- show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])), $siteurl."restore.php?operation=import&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes&confirm=yes".(!empty($delunzip) ? '&delunzip=yes' : ''), 'redirect');
+ show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])), $siteurl."restore.php?operation=import&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes&start=yes&confirm=yes".(!empty($delunzip) ? '&delunzip=yes' : ''), 'redirect');
} else {
show_msg('database_import_succeed', '', 'message', 1);
}
} elseif($dumpinfo['method'] == 'shell') {
+ touch($lock_file);
$dbhost = $_config['db'][1]['dbhost'];
$dbname = $_config['db'][1]['dbname'];
$dbpw = $_config['db'][1]['dbpw'];
@@ -140,10 +143,11 @@ if($operation == 'import') {
$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
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.'" < '.$datafile);
-
+ $mysqlbin = $mysql_base == '/' ? '' : addslashes(rtrim($mysql_base, '/\\')).'/bin/';
+ @shell_exec($mysqlbin.'mysql -h"'.$dbhost.'"'.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : '').' -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile);
+ if($delunzip) {
+ @unlink($datafile);
+ }
show_msg('database_import_succeed', '', 'message', 1);
} else {
show_msg('database_import_format_illegal');
@@ -163,6 +167,14 @@ if($operation == 'import') {
$datafile_vol1 = trim(getgpc('datafile_vol1', 'G'));
$multivol = intval(getgpc('multivol', 'G'));
+ $confirm = trim(getgpc('confirm', 'G'));
+ $delunzip = getgpc('delunzip', 'G');
+ $start = trim(getgpc('start', 'G'));
+ $start = $start ? 1 : 0;
+ if(!$start) {
+ show_msg(lang('database_import_multivol_unzip_start', TRUE, array()), $siteurl.'restore.php?operation=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.$datafile_server.'&importsubmit=yes&start=yes'.(!empty($confirm) ? '&confirm=yes' : ''), 'redirect');
+ }
+
require_once ROOT_PATH.'./source/class/class_zip.php';
$unzip = new SimpleUnzip();
$backupdir = substr($datafile_server, 8, 13);
@@ -176,7 +188,7 @@ if($operation == 'import') {
$confirm = getgpc('confirm', 'G');
$confirm = !empty($confirm) ? 1 : 0;
if(!$confirm && $identify[1] != DISCUZ_VERSION) {
- show_msg('database_import_confirm', $siteurl.'restore.php?operation=importzip&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'confirm');
+ show_msg('database_import_confirm', $siteurl.'restore.php?operation=importzip&datafile_server='.$datafile_server.'&importsubmit=yes&start=yes&confirm=yes', 'confirm');
}
$sqlfilecount = 0;
@@ -199,7 +211,7 @@ if($operation == 'import') {
$multivol++;
$datafile_server = preg_replace("/-(\d+)(\..+)$/", "-$multivol\\2", $datafile_server);
if(file_exists($datafile_server)) {
- show_msg(lang('database_import_multivol_unzip_redirect', TRUE, array('multivol' => $multivol)), $siteurl.'restore.php?operation=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'redirect');
+ show_msg(lang('database_import_multivol_unzip_redirect', TRUE, array('multivol' => $multivol)), $siteurl.'restore.php?operation=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.$datafile_server.'&importsubmit=yes&start=yes&confirm=yes', 'redirect');
} else {
show_msg('database_import_multivol_confirm', $siteurl.'restore.php?operation=import&datafile_server='.$datafile_vol1.'&importsubmit=yes&delunzip=yes', 'confirm');
}
@@ -210,7 +222,7 @@ if($operation == 'import') {
$datafile_server = preg_replace("/-1(\..+)$/", "-2\\1", $datafile_server);
if(file_exists($datafile_server)) {
- show_msg(lang('database_import_multivol_unzip_redirect', TRUE, array('multivol' => 1)), $siteurl.'restore.php?operation=importzip&multivol=1&datafile_vol1=../data/'.$backupdir.'/'.$importfile.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'redirect');
+ show_msg(lang('database_import_multivol_unzip_redirect', TRUE, array('multivol' => 1)), $siteurl.'restore.php?operation=importzip&multivol=1&datafile_vol1=../data/'.$backupdir.'/'.$importfile.'&datafile_server='.$datafile_server.'&importsubmit=yes&start=yes&confirm=yes', 'redirect');
}
}
@@ -230,13 +242,13 @@ function get_backup_dir() {
return $backupdirs;
}
-function check_exportfile(&$exportlog, &$exportziplog, &$exportsize) {
+function check_exportfile(&$exportlog, &$exportziplog, &$exportsize, &$exportzipsize) {
$backupdirs = get_backup_dir();
if(empty($backupdirs)) {
return;
}
-
+ $exportfiletime = $exportzipfiletime = array();
foreach($backupdirs as $backupdir) {
$dir = dir(ROOT_PATH.'./data/'.$backupdir);
while($entry = $dir->read()) {
@@ -244,6 +256,7 @@ function check_exportfile(&$exportlog, &$exportziplog, &$exportsize) {
if(is_file($entry)) {
if(preg_match("/\.sql$/i", $entry)) {
$filesize = filesize($entry);
+ $filemtime = filemtime($entry);
$fp = fopen($entry, 'rb');
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
fclose($fp);
@@ -256,27 +269,37 @@ function check_exportfile(&$exportlog, &$exportziplog, &$exportsize) {
'tablepre' => $identify[5],
'dbcharset' => $identify[6],
'filename' => $entry,
- 'dateline' => filemtime($entry),
+ 'dateline' => $filemtime,
'size' => $filesize
);
$exportsize[$key] += $filesize;
+ $exportfiletime[$key] = $filemtime;
} elseif(preg_match("/\.zip$/i", $entry)) {
$key = preg_replace('/^(.+?)(\-\d+)\.zip$/i', '\\1', basename($entry));
$filesize = filesize($entry);
+ $filemtime = filemtime($entry);
$exportziplog[$key][] = array(
'type' => 'zip',
'filename' => $entry,
- 'size' => filesize($entry),
- 'dateline' => filemtime($entry)
+ 'size' => $filesize,
+ 'dateline' => $filemtime
);
+ $exportzipsize[$key] += $filesize;
+ $exportzipfiletime[$key] = $filemtime;
}
}
}
$dir->close();
+ if (!empty($exportlog)) {
+ array_multisort($exportfiletime, SORT_DESC, SORT_STRING, $exportlog);
+ }
+ if (!empty($exportziplog)) {
+ array_multisort($exportzipfiletime, SORT_DESC, SORT_STRING, $exportziplog);
+ }
}
}
-function show_importfile_list($exportlog = array(), $exportziplog = array(), $exportsize = array()) {
+function show_importfile_list($exportlog = array(), $exportziplog = array(), $exportsize = array(), $exportzipsize = array()) {
show_header();
show_tips('db_import_tips');
@@ -319,7 +342,7 @@ function show_importfile_list($exportlog = array(), $exportziplog = array(), $ex
'
| ',
"".$info['size']." | ",
' | ',
- "".$info['volume']." | ",
+ " | ",
' | '
;
echo "\n";
@@ -331,14 +354,15 @@ function show_importfile_list($exportlog = array(), $exportziplog = array(), $ex
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['size'] = sizecount($exportzipsize[$key]);
+ $info['volume'] = count($val);
$info['method'] = $info['method'] == 'multivol' ? lang('db_multivol') : lang('db_zip');
echo "";
echo
"".basename($info['filename'])." | ",
"".dirname($info['filename'])." | ",
"".$info['dateline']." | ",
- "".lang('db_export_'.$info['type'])." | ",
+ "".($info['volume'] > 1 ? lang('db_multivol') : '').lang('db_export_'.$info['type'])." | ",
"".$info['size']." | ",
"".$info['method']." | ",
"".lang('db_import_unzip')." | "
@@ -355,7 +379,7 @@ function show_importfile_list($exportlog = array(), $exportziplog = array(), $ex
"".$info['dateline']." | ",
"".lang('db_export_'.$info['type'])." | ",
"".$info['size']." | ",
- "".$info['method']." | "
+ " | "
;
echo "
\n";
}
@@ -504,7 +528,7 @@ function show_msg($message, $url_forward = '', $type = 'message', $success = 0)
echo "";
} elseif($type == 'confirm') {
echo "$message";
- echo "
";
+ echo "
";
}
show_footer();
@@ -554,46 +578,50 @@ function show_tips($tip, $title = '', $comment = '', $style = 1) {
}
function lang($lang_key, $force = true, $replace = array()) {
- $lang = array('filename' => '文件名称',
- 'director' => '所在目录',
- 'version' => '版本',
- 'time' => '备份时间',
- 'type' => '类型',
- 'size' => '尺寸',
- 'db_method' => '方式',
- 'db_volume' => '卷数',
- 'import' => '导入',
- 'different_dbcharset_tablepre' => '检测到导入的备份数据与配置文件的{diff} 不同,您还要继续运行此程序吗?',
- 'db_import_tips' => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。
您可以通过数据备份管理功能查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。
恢复数据的整个过程会在一个新页面完成,您成功恢复数据后请务必及时删除restore.php文件。
',
- 'db_export_discuz' => 'Discuz! 数据(不含UCenter)',
- 'db_export_discuz_uc' => 'Discuz! 和 UCenter 数据',
- 'db_multivol' => '多卷',
- 'db_import_unzip' => '解压缩',
- 'db_export_custom' => '自定义备份',
- 'db_export_zip' => '压缩备份',
- 'db_zip' => 'ZIP',
- 'db_shell' => 'Shell',
- 'unknown' => '未知',
- 'backup_file_unexist' => '备份文件不存在',
- 'connect_error' => '连接数据库失败,请您查看数据库配置文件config/config_global.php和config/config_ucenter.php是否存在以及配置是否正确',
- 'dbcharsetdiff' => ' 数据库字符集($_config[\'db\'][\'1\'][\'dbcharset\'])',
- 'tableprediff' => ' 表前缀($_config[\'db\'][\'1\'][\'tablepre\'])',
- 'database_import_multivol_succeed' => '分卷数据成功导入站点数据库
请在后台更新缓存
请尽快删除restore.php文件,以免对数据造成影响',
- 'database_import_file_illegal' => '数据文件不存在:可能服务器不允许上传文件或文件大小超过限制',
- 'database_import_multivol_prompt' => '分卷数据第一卷成功导入数据库,您需要自动导入本次备份的其他分卷吗?',
- 'database_import_succeed' => '数据已成功导入站点数据库
请在后台更新缓存
请尽快删除restore.php文件,以免对数据造成影响',
- 'database_import_format_illegal' => '数据文件非 Discuz! 格式,无法导入',
- 'database_import_unzip' => '{info}
备份文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除',
- 'database_import_multivol_unzip' => '{info}
备份文件解压缩完毕,您需要自动解压缩其他的分卷文件吗?',
- 'database_import_multivol_unzip_redirect' => '数据文件 #{multivol} 解压缩成功,程序将自动继续',
- 'database_import_confirm' => '导入和当前 Discuz! 版本不一致的数据极有可能产生无法解决的故障,您确定继续吗?',
- 'database_import_confirm_sql' => '您确定导入该备份吗?',
- 'database_import_confirm_zip' => '您确定解压该备份吗?',
- 'database_import_multivol_confirm' => '所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除',
- 'database_import_multivol_redirect' => '数据文件 #{volume} 成功导入,程序将自动继续',
- 'error_quit_msg' => '必须解决以上问题,才能继续恢复数据',
- 'restored_error' => '恢复数据功能锁定,已经恢复过了,如果您确定要恢复数据,请到服务器上删除./data/restore.lock',
- );
+ global $_config;
+ $lang = array(
+ 'filename' => '文件名称',
+ 'director' => '所在目录',
+ 'version' => '版本',
+ 'time' => '备份时间',
+ 'type' => '类型',
+ 'size' => '尺寸',
+ 'db_method' => '方式',
+ 'db_volume' => '卷数',
+ 'import' => '导入',
+ 'different_dbcharset_tablepre' => '检测到导入的备份数据与配置文件的{diff} 不同,您还要继续运行此程序吗?',
+ 'db_import_tips' => '本功能在恢复备份数据的同时,将全部覆盖原有数据,请确定恢复前已将论坛关闭,恢复全部完成后可以将论坛重新开放。
您可以通过数据备份管理功能查看站点的备份文件的详细信息,删除过期的备份,并导入需要的备份。
恢复数据的整个过程会在一个新页面完成,您成功恢复数据后请务必及时删除restore.php文件。
',
+ 'db_export_discuz' => 'Discuz! 数据(不含UCenter)',
+ 'db_export_discuz_uc' => 'Discuz! 和 UCenter 数据',
+ 'db_multivol' => '多卷',
+ 'db_import_unzip' => '解压缩',
+ 'db_export_custom' => '自定义备份',
+ 'db_export_zip' => '压缩备份',
+ 'db_zip' => 'ZIP',
+ 'db_shell' => 'Shell',
+ 'unknown' => '未知',
+ 'backup_file_unexist' => '备份文件不存在',
+ 'connect_error' => '连接数据库失败,请您查看数据库配置文件config/config_global.php和config/config_ucenter.php是否存在以及配置是否正确',
+ 'dbcharsetdiff' => ' 数据库字符集('.$_config['db']['1']['dbcharset'].')',
+ 'tableprediff' => ' 表前缀('.$_config['db']['1']['tablepre'].')',
+ 'database_import_multivol_succeed' => '分卷数据成功导入站点数据库
请在后台更新缓存
请尽快删除restore.php文件,以免对数据造成影响',
+ 'database_import_file_illegal' => '数据文件不存在:可能服务器不允许上传文件或文件大小超过限制',
+ 'database_import_multivol_prompt' => '分卷数据第一卷成功导入数据库,您需要自动导入本次备份的其他分卷吗?',
+ 'database_import_succeed' => '数据已成功导入站点数据库
请在后台更新缓存
请尽快删除restore.php文件,以免对数据造成影响',
+ 'database_import_format_illegal' => '数据文件非 Discuz! 格式,无法导入',
+ 'database_import_unzip' => '{info}
备份文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除',
+ 'database_import_multivol_unzip' => '{info}
备份文件解压缩完毕,您需要自动解压缩其他的分卷文件吗?',
+ 'database_import_multivol_unzip_start' => '正在解压备份文件,程序将自动继续',
+ 'database_import_multivol_unzip_redirect' => '数据文件 #{multivol} 解压缩成功,程序将自动继续',
+ 'database_import_confirm' => '导入和当前 Discuz! 版本不一致的数据极有可能产生无法解决的故障,您确定继续吗?',
+ 'database_import_confirm_sql' => '您确定导入该备份吗?',
+ 'database_import_confirm_zip' => '您确定解压该备份吗?',
+ 'database_import_multivol_confirm' => '所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除',
+ 'database_import_multivol_start' => '正在导入备份文件,程序将自动继续',
+ 'database_import_multivol_redirect' => '数据文件 #{volume} 成功导入,程序将自动继续',
+ 'error_quit_msg' => '必须解决以上问题,才能继续恢复数据',
+ 'restored_error' => '恢复数据功能锁定,已经恢复过了,如果您确定要恢复数据,请到服务器上删除./data/restore.lock',
+ );
$return = isset($lang[$lang_key]) ? $lang[$lang_key] : ($force ? $lang_key : '');
if($replace && is_array($replace)) {
$searchs = $replaces = array();