function CommandLineRestore($filename) { if ($C['mysql']) { $command = "{$C['mysql']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "-f " . escapeshellarg($C['db_name']) . " " . " <{$filename} 2>&1"; exec($command); } else { DoRestore($filename); } }
function CommandLineRestore($filename) { global $C, $DB; if (IsEmptyString($filename)) { trigger_error('A filename must be supplied', E_USER_ERROR); } $filename = "{$GLOBALS['BASE_DIR']}/data/" . basename($filename); if (!$C['safe_mode'] && $C['mysql']) { $command = "{$C['mysql']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "-f " . escapeshellarg($C['db_name']) . " " . " <{$filename} >/dev/null 2>&1"; shell_exec($command); } else { DoRestore($filename); } }
function lxRestoreDatabase() { global $DB, $C; VerifyAdministrator(); CheckAccessList(); $filename = SafeFilename("{$GLOBALS['BASE_DIR']}/data/{$_REQUEST['filename']}", FALSE); $tables = array(); IniParse("{$GLOBALS['BASE_DIR']}/includes/tables.php", TRUE, $tables); $GLOBALS['message'] = 'Database restore is in progress, allow a few minutes to complete before downloading the backup file'; // Run mysql in the background if ($C['allow_exec'] && !empty($C['mysql'])) { $command = "{$C['mysql']} " . "-u" . escapeshellarg($C['db_username']) . " " . "-p" . escapeshellarg($C['db_password']) . " " . "-h" . escapeshellarg($C['db_hostname']) . " " . "-f " . escapeshellarg($C['db_name']) . " " . " <{$filename} 2>&1 &"; exec($command); } else { if ($C['allow_exec'] && !empty($C['php_cli'])) { exec("{$C['php_cli']} cron.php --restore " . escapeshellarg($filename) . " >/dev/null 2>&1 &"); } else { DoRestore($filename); $GLOBALS['message'] = 'Database restore has been completed'; } } lxShDatabaseTools(); }