Skip to content

Commit

Permalink
Make the database backup download more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
chetcuti committed May 18, 2020
1 parent d286246 commit be4a23f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions admin/backup/download/index.php
Expand Up @@ -33,6 +33,8 @@
$system->authCheck();
$system->checkAdminUser($_SESSION['s_is_admin']);

$download_filename = 'domainmod-backup.sql';

use Ifsnop\Mysqldump as IMysqldump;

try {
Expand All @@ -41,14 +43,14 @@
'add-drop-table' => true
);

if (file_exists(DIR_ROOT . '/temp/domainmod-backup.sql')) {
if (file_exists(DIR_TEMP . '/' . $download_filename)) {

unlink(DIR_ROOT . '/temp/domainmod-backup.sql');
unlink(DIR_TEMP . '/' . $download_filename);

}

$dump = new IMysqldump\Mysqldump('mysql:host=' . $dbhostname . ';dbname=' . $dbname, $dbusername, $dbpassword, $DumpSettings);
$dump->start(DIR_ROOT . '/temp/domainmod-backup.sql');
$dump->start(DIR_TEMP . '/' . $download_filename);

} catch (Exception $e) {

Expand All @@ -60,5 +62,7 @@

}

header("Location: ../../../temp/domainmod-backup.sql");
exit;
header('Content-Type: application/octet-stream');
header("Content-disposition: attachment; filename=" . $download_filename);
readfile(DIR_TEMP . '/' . $download_filename);
exit();

0 comments on commit be4a23f

Please sign in to comment.