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' => '