Skip to content

Commit 97ae412

Browse files
committed
Fix for files not downloading
1 parent e603a52 commit 97ae412

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

web/download/backup/index.php

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,38 @@
1111
exit();
1212
}
1313

14-
$v_username = escapeshellarg($user);
15-
exec (HESTIA_CMD."v-schedule-user-backup ".$v_username, $output, $return_var);
16-
if ($return_var == 0) {
17-
$_SESSION['error_msg'] = __('BACKUP_SCHEDULED');
18-
} else {
19-
$_SESSION['error_msg'] = implode('<br>', $output);
20-
if (empty($_SESSION['error_msg'])) {
21-
$_SESSION['error_msg'] = __('Error: hestia did not return any output.');
14+
if(!file_exists('/backup/'.$backup)){
15+
$v_username = escapeshellarg($user);
16+
exec (HESTIA_CMD."v-schedule-user-backup ".$v_username, $output, $return_var);
17+
if ($return_var == 0) {
18+
$_SESSION['error_msg'] = __('BACKUP_SCHEDULED');
19+
} else {
20+
$_SESSION['error_msg'] = implode('<br>', $output);
21+
if (empty($_SESSION['error_msg'])) {
22+
$_SESSION['error_msg'] = __('Error: hestia did not return any output.');
23+
}
24+
25+
if ($return_var == 4) {
26+
$_SESSION['error_msg'] = __('BACKUP_EXISTS');
27+
}
28+
2229
}
30+
unset($output);
31+
header("Location: /list/backup/");
32+
exit;
2333

24-
if ($return_var == 4) {
25-
$_SESSION['error_msg'] = __('BACKUP_EXISTS');
34+
}else{
35+
if ($_SESSION['user'] == 'admin') {
36+
header('Content-type: application/gzip');
37+
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
38+
header("X-Accel-Redirect: /backup/" . $backup);
2639
}
2740

28-
}
29-
unset($output);
30-
header("Location: /list/backup/");
31-
exit;
41+
if ((!empty($_SESSION['user'])) && ($_SESSION['user'] != 'admin')) {
42+
if (strpos($backup, $user.'.') === 0) {
43+
header('Content-type: application/gzip');
44+
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
45+
header("X-Accel-Redirect: /backup/" . $backup);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)