- $filename = BACKUP_PATH . get_post('cmb_backups');
- if (in_ajax())
- $Ajax->popup( $filename );
- else {
- header('Content-type: application/octet-stream');
- header('Content-Length: '.filesize($filename));
- header("Content-Disposition: inline; filename=$filename");
- readfile($filename);
- exit();
+ if (!get_post('backups')) {
+ display_error(_('Select backup file first.'));
+ } else {
+ $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; filename=".basename($filename));
+ if (substr($filename, -3, 3) == '.gz')
+ header("Content-Encoding: gzip");
+
+ if (substr($filename, -4, 4) == '.zip')
+ echo db_unzip('', $filename);
+ else
+ readfile($filename);
+ exit();
+ }