index.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. ob_start();
  4. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  5. // Check token
  6. verify_csrf($_GET);
  7. $backup = $_GET['backup'];
  8. if (!file_exists('/backup/'.$backup)) {
  9. $backup = quoteshellarg($_GET['backup']);
  10. exec(HESTIA_CMD."v-schedule-user-backup-download ".$user." ".$backup, $output, $return_var);
  11. if ($return_var == 0) {
  12. $_SESSION['error_msg'] = _('BACKUP_DOWNLOAD_SCHEDULED');
  13. } else {
  14. $_SESSION['error_msg'] = implode('<br>', $output);
  15. if (empty($_SESSION['error_msg'])) {
  16. $_SESSION['error_msg'] = _('Error: Hestia did not return any output.');
  17. }
  18. }
  19. unset($output);
  20. header("Location: /list/backup/");
  21. exit;
  22. } else {
  23. if ($_SESSION['userContext'] === 'admin') {
  24. header('Content-type: application/gzip');
  25. header("Content-Disposition: attachment; filename=\"".$backup."\";");
  26. header("X-Accel-Redirect: /backup/" . $backup);
  27. }
  28. if ((!empty($_SESSION['user'])) && ($_SESSION['userContext'] != 'admin')) {
  29. if (strpos($backup, $_SESSION['user'].'.') === 0) {
  30. header('Content-type: application/gzip');
  31. header("Content-Disposition: attachment; filename=\"".$backup."\";");
  32. header("X-Accel-Redirect: /backup/" . $backup);
  33. }
  34. }
  35. }