1
0
Fork 0

Struggeling with relocating

Dieser Commit ist enthalten in:
DSB 2011-06-10 21:28:27 +00:00
Commit 89ea01c429
301 geänderte Dateien mit 59926 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,91 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @version SVN: $rev: $
* @author $Author$
* @lastmodified $Date$
*/
// Restore is finished
include ('./inc/define_icons.php');
$restore = $_SESSION['restore'];
$tplRestoreFinished = new MSDTemplate();
$tplRestoreFinished->set_filenames(
array('tplRestoreFinished' => 'tpl/restore/restore_finished.tpl')
);
$recordsInserted = String::formatNumber($restore['records_inserted']);
$recordsInserted = sprintf($lang['L_RECORDS_INSERTED'], $recordsInserted);
$tablesCreated = sprintf(
$lang['L_RESTORE_COMPLETE'], $restore['table_ready']
);
$timeElapsed = getTimeFormat(time() - $restore['restore_start_time']);
$tplRestoreFinished->assign_vars(
array(
'SESSION_ID' => session_id(),
'ICON_OPEN_FILE' => $icon['small']['open_file'],
'ICON_EDIT' => $icon['small']['edit'],
'ICON_VIEW' => $icon['small']['view'],
'SESSION_ID' => session_id(),
'BACKUPPATH' => $config['paths']['backup'],
'PAGE_REFRESHS' => $restore['page_refreshs'],
'TIME_ELAPSED' => $timeElapsed,
'TABLES_CREATED' => $tablesCreated,
'RECORDS_INSERTED' => $recordsInserted,
'ICONPATH' => $config['files']['iconpath']
)
);
if (count($_SESSION['log']['errors']) > 0) {
$i = 1;
$tplRestoreFinished->assign_block_vars('ERRORS', array());
foreach ($_SESSION['log']['errors'] as $logError) {
$timestamp = substr($logError, 0, 19);
$message = substr($logError, 20);
$tplRestoreFinished->assign_block_vars(
'ERRORS.ERROR',
array(
'NR' => $i,
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
'TIMESTAMP' => $timestamp,
'MSG' => $message
)
);
$i++;
}
}
$i = 1;
foreach ($_SESSION['log']['actions'] as $logAction) {
$timestamp = substr($logAction, 0, 19);
$message = substr($logAction, 20);
$tplRestoreFinished->assign_block_vars(
'ACTION',
array(
'NR' => $i,
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
'TIMESTAMP' => $timestamp,
'ACTION' => $message
)
);
$i++;
}
$i = 1;
if (count($_SESSION['log']['notices']) > 0) {
$tplRestoreFinished->assign_block_vars('NOTICES', array());
foreach ($_SESSION['log']['notices'] as $logAction) {
$timestamp = substr($logAction, 0, 19);
$message = substr($logAction, 20);
$tplRestoreFinished->assign_block_vars(
'NOTICES.NOTICE',
array(
'NR' => $i,
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
'TIMESTAMP' => $timestamp,
'NOTICE' => $message
)
);
$i++;
}
}

Datei anzeigen

@ -0,0 +1,250 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @version SVN: $rev: 1207 $
* @author $Author$
* @lastmodified $Date$
*/
if (!defined('MSD_VERSION')) die('No direct access.');
include ('./inc/define_icons.php');
$msg = '';
$showFilelist = true;
// call after selecting tables to restore
//-> save selection and head over to restore.php
if (isset($_POST['restore_tbl'])) {
echo '<script type="text/javascript">'
. 'location.href="index.php?p=restore&filename='
. urlencode($_POST['filename']) . '";</script></body></html>';
exit();
}
if (isset($_POST['restore'])) {
if (isset($_POST['file'])) {
if (isset($_POST['select_tables']) && $_POST['select_tables'] == 1) {
// select tables to restore
include ('./inc/restore/select_tables.php');
$showFilelist = false;
} else {
$encodingFound = true;
$file = $_POST['file'][0];
$statusline = readStatusline($file);
if (isset($_POST['sel_dump_encoding_restore'])) {
// encoding of file was selected -> we can start
$dumpEncoding = $_POST['sel_dump_encoding_restore'];
} else {
if (!isset($statusline['charset'])
|| trim($statusline['charset']) == '?') {
// unknown encoding of a file not created by MySQLDumper
// -> ask user what encoding should be used
$charsets = $dbo->getCharsets();
foreach ($charsets as $name => $val) {
$charsetsDescription[$name] = $name . ' - '
. $val['Description'];
}
$tplRestoreSelectEncoding = new MSDTemplate();
$tplRestoreSelectEncoding->set_filenames(
array(
'tplRestoreSelectEncoding' =>
'tpl/restore/file_select_encoding.tpl'
)
);
$encSelect = Html::getOptionlist(
$charsetsDescription, 'utf8'
);
$tplRestoreSelectEncoding->assign_vars(
array(
'PAGETITLE' => $lang['L_FM_RESTORE'] . ': ' . $file,
'DATABASE' => $config['db_actual'],
'ENCODING_SELECT' => $encSelect,
'FILE_NAME' => $file
)
);
$encodingFound = false;
} else {
// file was created by MySQLDumper ->
// get encoding from statusline
$dumpEncoding = $statusline['charset'];
}
}
if ($encodingFound) {
echo '<script type="text/javascript">'
.'location.href="index.php?p=restore&filename='
. urlencode($file) . '&dump_encoding='
. urlencode($dumpEncoding) . '";</script></body></html>';
obend();
}
}
$showFilelist = false;
} else {
$msg .= Html::getErrorMsg($lang['L_FM_NOFILE']);
}
}
if ($showFilelist) {
// Reset Session
$_SESSION['restore'] = array();
$restore = array();
$tplRestorePrepare = new MSDTemplate();
$tplRestorePrepare->set_filenames(
array('tplRestorePrepare' => 'tpl/restore/restorePrepare.tpl')
);
$dbactualOutput = $dbactive;
if ($dbactive == '~unknown') {
$dbactualOutput = '<i>' . $lang['L_UNKNOWN'] . '</i>';
}
if ($dbactive == '~converted') {
$dbactualOutput = '<i>' . $lang['L_CONVERTED_FILES'] . '</i>';
}
$pageTitle = sprintf($lang['L_FM_RESTORE_HEADER'], $config['db_actual']);
$tplRestorePrepare->assign_vars(
array(
'SESSION_ID' => session_id(),
'PAGETITLE' => $pageTitle,
'DB_ACTUAL' => $config['db_actual'],
'DB_ACTIVE' => $dbactualOutput,
)
);
if ($msg > '') $tplRestorePrepare->assign_block_vars(
'MESSAGE', array('TEXT' => Html::getJsQuote($msg, true))
);
// get info of all backup files
$backups = getBackupfileInfo();
if (!isset($backups['databases'][$dbactive])) {
$tplRestorePrepare->assign_block_vars('NO_FILE_FOUND', array());
}
$i = 0;
// show detailed file info of the selected database at top
foreach ($backups['files'] as $backup) {
if ($backup['db'] == $dbactive) {
$compressed = '-';
if (substr($backup['name'], -3) == '.gz') {
$compressed = $icon['gz'];
}
$dbName = $backup['name'];
if (!in_array($backup['db'], array('~unknown', '~converted'))) {
$dbName = $backup['db'];
}
$scriptVersion = $lang['L_UNKNOWN'];
if ($backup['script'] > '') {
$scriptVersion = $backup['script'];
}
$comment ='&nbsp;';
if ($backup['comment'] > '') {
$comment = nl2br(wordwrap($backup['comment'], 50));
}
$nrOfTables = $lang['L_UNKNOWN'];
if ($backup['tables'] > -1) {
$nrOfTables = String::formatNumber($backup['tables']);
}
$nrOfRecords = $lang['L_UNKNOWN'];
if ($backup['records'] > -1) {
$nrOfRecords = String::formatNumber($backup['records']);
}
$fileCharset = $lang['L_UNKNOWN'];
if ($backup['charset'] != '?') {
$fileCharset = $backup['charset'];
}
$tplRestorePrepare->assign_block_vars(
'FILE',
array(
'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1',
'FILE_INDEX' => $i,
'FILE_NAME' => $backup['name'],
'DB_NAME' => $dbName,
'DB_EXPAND_LINK' => $backup['db'],
'ICON_COMPRESSED' => $compressed,
'SCRIPT_VERSION' => $scriptVersion,
'COMMENT' => $comment,
'FILE_CREATION_DATE' => $backup['date'],
'NR_OF_TABLES' => $nrOfTables,
'NR_OF_RECORDS' => $nrOfRecords,
'FILESIZE' => byteOutput($backup['size']),
'FILE_CHARSET' => $fileCharset,
'NR_OF_MULTIPARTS' => $backup['multipart']
)
);
if ($backup['multipart'] > 0) {
$fileCount = $lang['L_FILES'];
if ($backup['multipart'] == 1) {
$fileCount = $lang['L_FILE'];
}
$tplRestorePrepare->assign_block_vars(
'FILE.IS_MULTIPART', array('FILES' => $fileCount)
);
} else {
$tplRestorePrepare->assign_block_vars(
'FILE.NO_MULTIPART', array()
);
}
$i++;
}
}
// list summary of other backup files grouped by databases
ksort($backups['databases']);
if (count($backups['databases']) > 0) {
$i = 0;
foreach ($backups['databases'] as $db => $info) {
$rowclass = $i % 2 ? 'dbrow' : 'dbrow1';
if ($db == $dbactive) $rowclass = 'dbrowsel';
$dbNameOutput = $db;
if ($db == '~unknown') {
$dbNameOutput = '<i>' . $lang['L_NO_MSD_BACKUPFILE'] . '</i>';
}
if ($db == '~converted') {
$dbNameOutput = '<i>' . $lang['L_CONVERTED_FILES'] . '</i>';
}
$nrOfBackups = '-';
if (isset($info['backup_count'])) {
$nrOfBackups = $info['backup_count'];
}
$latestBackup = '';
if (isset($info['latest_backup_timestamp'])) {
$latestBackup = $info['latest_backup_timestamp'];
}
$sumSize = 0;
if (isset($info['backup_size_total'])) {
$sumSize = byteOutput($info['backup_size_total']);
}
$tplRestorePrepare->assign_block_vars(
'DB',
array(
'ROWCLASS' => $rowclass,
'DB_NAME_LINK' => $db,
'DB_NAME' => $dbNameOutput,
'NR_OF_BACKUPS' => $nrOfBackups,
'LATEST_BACKUP' => $latestBackup,
'SUM_SIZE' => $sumSize
)
);
$i++;
}
}
$tplRestorePrepare->assign_vars(
array(
'ICON_VIEW' => $icon['view'],
'ICON_RESTORE' => $icon['restore'],
'SUM_SIZE' => byteOutput($backups['filesize_total']),
'NOTIFICATION_POSITION' => $config['notification_position']
)
);
$_SESSION['restore'] = $restore;
$_SESSION['log'] = array();
$_SESSION['log']['actions'] = array();
$_SESSION['log']['errors'] = array();
$_SESSION['log']['notices'] = array();
}

148
inc/restore/restore_start.php Normale Datei
Datei anzeigen

@ -0,0 +1,148 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @version SVN: $rev: $
* @author $Author$
* @lastmodified $Date$
*/
// start the magic
if (isset($_GET['filename']) || isset($_POST['filename'])) {
// first call -> set defaults
getConfig();
$restore = $_SESSION['restore'];
$restore['filename'] = '';
if (isset($_POST['filename'])) {
$restore['filename'] = urldecode($_POST['filename']);
}
if (isset($_GET['filename'])) {
$restore['filename'] = urldecode($_GET['filename']);
}
$restore['compressed'] = 0;
if (substr(strtolower($restore['filename']), -2) == 'gz') {
$restore['compressed'] = 1;
}
$restore['dump_encoding'] = 'utf8';
if (isset($_POST['sel_dump_encoding'])) {
$restore['dump_encoding'] = $_POST['sel_dump_encoding'];
}
if (isset($_GET['dump_encoding'])) {
$restore['dump_encoding'] = $_GET['dump_encoding'];
}
$restore['part'] = 0;
// Read Statusline of file
$sline = readStatusline($restore['filename']);
// if it is a backup done by MSD we get the charset from the statusline
if (isset($sline['charset']) && $sline['charset']!='?') {
$restore['dump_encoding'] = $sline['charset'];
}
// init some values
$restore['tables_total'] = $sline['tables'];
$restore['records_total'] = $sline['records'];
if ($sline['part'] != 'MP_0') $restore['part'] = 1;
if ($config['empty_db_before_restore'] == 1) {
truncateDb($config['db_actual']);
}
$restore['max_zeit'] = intval(
$config['max_execution_time'] * $config['time_buffer']
);
$restore['restore_start_time'] = time();
$restore['speed'] = $config['minspeed'];
$restore['restore_start_time'] = time();
$restore['fileEOF'] = false;
$restore['actual_table'] = '';
$restore['offset'] = 0;
$restore['page_refreshs'] = 0;
$restore['table_ready'] = 0;
$restore['errors'] = 0;
$restore['notices'] = 0;
$restore['actual_fieldcount'] = 0;
$restore['records_inserted'] = 0;
$restore['records_inserted_table'] = array();
$restore['extended_inserts'] = 0;
$restore['extended_insert_flag'] = -1;
$restore['last_parser_status'] = 0;
$restore['EOB'] = false;
$restore['fileEOF'] = false;
$restore['file_progress_percent'] = 0;
$restore['tables_to_restore'] = false; // restore complete file
// Should we restore the complete file or are only some tables selected ?
if (isset($_POST['sel_tbl'])) {
$restore['tables_to_restore'] = $_POST['sel_tbl'];
//correct the nr of tables and total records to restore
$restore['tables_total'] = 0;
$restore['records_total'] = 0;
$tabledata = getTableHeaderInfoFromBackup($restore['filename']);
foreach ($tabledata as $key => $val) {
if (in_array($val['name'], $restore['tables_to_restore'])) {
$restore['tables_total']++;
$restore['records_total'] += $val['records'];
}
}
}
$_SESSION['config'] = $config;
$_SESSION['databases'] = $databases;
$_SESSION['restore'] = $restore;
$logMsg = sprintf(
$lang['L_START_RESTORE_DB_FILE'],
$config['db_actual'],
$restore['filename']
);
$log->write(Log::PHP, $logMsg);
} else {
$config = $_SESSION['config'];
$databases = $_SESSION['databases'];
$restore = $_SESSION['restore'];
}
// tables to create
$tablesDone = 0;
if ($restore['table_ready'] > 0) {
$tablesDone = $restore['table_ready'];
}
if ($restore['tables_total'] > 0) {
$tablesToDo = $restore['tables_total'];
} else {
$tablesToDo = $lang['L_UNKNOWN'];
}
if ($restore['tables_total'] > 0) {
$tablesToCreate = sprintf(
$lang['L_RESTORE_TABLES_COMPLETED'],
$tablesDone,
$tablesToDo
);
} else {
$tablesToCreate = sprintf(
$lang['L_RESTORE_TABLES_COMPLETED0'], $tablesDone
);
}
$tplRestore = new MSDTemplate();
$tplRestore->set_filenames(array('tplRestore' => 'tpl/restore/restore.tpl'));
$restoringDb = sprintf(
$lang['L_RESTORE_DB'], $config['db_actual'], $config['dbhost']
);
$tplRestore->assign_vars(
array(
'SESSION_ID' => session_id(),
'ICONPATH' => $config['files']['iconpath'],
'ICON_PLUS' => $icon['plus'],
'DB_ON_SERVER' => $restoringDb,
'FILENAME' => $restore['filename'],
'CHARSET' => $restore['dump_encoding'],
'TABLES_TO_CREATE' => $tablesToCreate,
'NOTIFICATION_POSITION' => $config['notification_position']
)
);
if ($restore['part'] > 0) {
$tplRestore->assign_block_vars(
'MULTIPART',
array('PART' => $restore['part'])
);
}
$_SESSION['restore'] = $restore;

Datei anzeigen

@ -0,0 +1,63 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @version SVN: $rev: 1207 $
* @author $Author$
* @lastmodified $Date$
*/
if (!defined('MSD_VERSION')) die('No direct access.');
$fileName = (isset($_GET['filename'])) ? urldecode($_GET['filename']) : '';
if (isset($_POST['file'][0])) {
$fileName = $_POST['file'][0];
}
$tplRestoreSelectTables = new MSDTemplate();
$tplRestoreSelectTables->set_filenames(
array('tplRestoreSelectTables' => 'tpl/restore/selectTables.tpl')
);
//Get Header-Infos from file
$sline = readStatusline($fileName);
if ($sline['records'] == -1) {
// not a backup of MySQLDumper
$tplRestoreSelectTables->assign_block_vars('NO_MSD_BACKUP', array());
} else {
// Get Tableinfo from file header
$tabledata = getTableHeaderInfoFromBackup($fileName);
for ($i = 0; $i < sizeof($tabledata); $i++) {
$klasse = ($i % 2) ? 1 : '';
$tplRestoreSelectTables->assign_block_vars(
'ROW',
array(
'CLASS' => 'dbrow' . $klasse,
'ID' => $i,
'NR' => $i + 1,
'TABLENAME' => $tabledata[$i]['name'],
'RECORDS' => String::formatNumber($tabledata[$i]['records']),
'SIZE' => byteOutput($tabledata[$i]['size']),
'LAST_UPDATE' => $tabledata[$i]['update'],
'TABLETYPE' => $tabledata[$i]['engine']
)
);
}
}
$confirmRestore = $lang['L_FM_ALERTRESTORE1'] . ' `' . $config['db_actual']
. '` ' . $lang['L_FM_ALERTRESTORE2'] . ' ' . $fileName . ' '
. $lang['L_FM_ALERTRESTORE3'];
$tplRestoreSelectTables->assign_vars(
array(
'PAGETITLE' => $lang['L_RESTORE'] . ' - ' . $lang['L_TABLESELECTION'],
'DATABASE' => $config['db_actual'],
'FILENAME' => $fileName,
'ICON_OK' => $icon['ok'],
'ICON_DELETE' => $icon['delete'],
'ICON_RESTORE' => $icon['restore'],
'L_NO_MSD_BACKUP' => $lang['L_NOT_SUPPORTED'],
'CONFIRM_RESTORE' => $confirmRestore
)
);