function execute_backup_restore($dump_options) { global $ADMIN_PATH; // Disable time limit @set_time_limit(0); $str = get_tr(); echo '<h1>' . $str['restore_init'] . "</h1>\n"; flush(); global $known_arrays; // Array of archive names that may present in backup. FIXME: change variable name to something related with it's meaning! if (!isset($_POST['mysql_host']) || !isset($_POST['mysql_user']) || !isset($_POST['mysql_password']) || !isset($_POST['mysql_db_name']) || !$_POST['mysql_db_name'] || !isset($_POST['mysql_charset'])) { echo '<p class="error">' . $str['err_nosettings'] . '</p>'; return show_form($dump_options); } // Get MySQL settings $MYSQL_HOST = trim($_POST['mysql_host']); if ($MYSQL_HOST === "") { $MYSQL_HOST = "localhost"; } $MYSQL_USER = trim($_POST['mysql_user']); $MYSQL_PASSWORD = $_POST['mysql_password']; $MYSQL_DB_NAME = trim($_POST['mysql_db_name']); $MYSQL_CHARSET = trim($_POST['mysql_charset']); if ($MYSQL_CHARSET === "") { $MYSQL_CHARSET = "utf8"; } // Restore database dump echo $str['dbrestore'] . "\n"; flush(); $dump_result = restore_dump($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DB_NAME, $MYSQL_CHARSET); if ($dump_result !== true) { echo '<p class="error">' . $str['err_restore'] . ': ' . $dump_result . '</p>'; return show_form($dump_options); } echo $str['done'] . '<br />'; flush(); if ($dump_options['mode'] != 'sql') { // Extract files extract_files($known_arrays); // Update vars.inc.php update_varsinc($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DB_NAME, $MYSQL_CHARSET); } echo '<p>' . $str['finish_text'] . ' <a href="' . $ADMIN_PATH . '">' . $str['finish_link_title'] . '</a>.</p>'; }
<?php /* Restores uploaded backup */ ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><?php $str = get_tr(); echo $str['header']; ?> </title> </head> <body> <?php if (isset($_POST["execute_backup_restore"]) && intval($_POST["execute_backup_restore"]) === 1) { execute_backup_restore($dump_options); } else { show_form($dump_options); } ?> </body> </html>