From: Janusz Dobrowolski Date: Sun, 19 Apr 2015 16:27:30 +0000 (+0200) Subject: Backup/Restore: added option to preserve security settings during database restoration. X-Git-Tag: v2.4.2~19^2~195 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=c81b21accfada966e07e9c1e28d28ecfe3fe48e6 Backup/Restore: added option to preserve security settings during database restoration. --- diff --git a/admin/backups.php b/admin/backups.php index b8fef45b..32130e5b 100644 --- a/admin/backups.php +++ b/admin/backups.php @@ -20,13 +20,13 @@ if (get_post('view')) { if (!get_post('backups')) { display_error(_('Select backup file first.')); } else { - $filename = $SysPrefs->backup_dir().clean_file_name(get_post('backups')); + $filename = $SysPrefs->backup_dir() . clean_file_name(get_post('backups')); if (in_ajax()) $Ajax->popup( $filename ); else { header('Content-type: text/plain'); header('Content-Length: '.filesize($filename)); - header("Content-Disposition: inline"); + header("Content-Disposition: inline; filename=".basename($filename)); readfile($filename); exit(); } @@ -67,7 +67,7 @@ function generate_backup($conn, $ext='no', $comm='') . _("Filename") . ": " . $filename); else display_error(_("Database backup failed.")); - + return $filename; } @@ -138,7 +138,7 @@ if (get_post('creat')) { if (get_post('restore')) { if ($backup_name) { - if (db_import($backup_path, $conn)) + if (db_import($backup_path, $conn, true, false, check_value('protected'))) display_notification(_("Restore backup completed.")); $SysPrefs->refresh(); // re-read system setup } else @@ -166,6 +166,8 @@ if (get_post('upload')) if ($fname) { if (!preg_match("/\.sql(\.zip|\.gz)?$/", $fname)) display_error(_("You can only upload *.sql backup files")); + elseif ($fname != clean_file_name($fname)) + display_error(_("Filename contains forbidden chars. Please rename file and try again.")); elseif (is_uploaded_file($tmpname)) { rename($tmpname, $SysPrefs->backup_dir() . $fname); display_notification(_("File uploaded to backup directory")); @@ -204,7 +206,12 @@ table_section_title(_("Backup scripts maintenance")); echo ""; end_row(); start_row(); -echo ""; + echo "" + . radio(_('Update security settings'), 'protect', 0) . '
' + . radio(_('Protect security settings'), 'protect', 1, true) . ""; +end_row(); +start_row(); + echo ""; submit_cells('upload',_("Upload file"),"style='padding-left:20px'", '', true); end_row(); end_outer_table();