index.php 896 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. session_start();
  5. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  6. // Check token
  7. if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
  8. header('Location: /login/');
  9. exit();
  10. }
  11. $backup = basename($_GET['backup']);
  12. // Check if the backup exists
  13. if (!file_exists('/backup/'.$backup)) {
  14. exit(0);
  15. }
  16. // Data
  17. if ($_SESSION['user'] == 'admin') {
  18. header('Content-type: application/gzip');
  19. header("Content-Disposition: attachment; filename=\"".$backup."\";" );
  20. header("X-Accel-Redirect: /backup/" . $backup);
  21. }
  22. if ((!empty($_SESSION['user'])) && ($_SESSION['user'] != 'admin')) {
  23. if (strpos($backup, $user.'.') === 0) {
  24. header('Content-type: application/gzip');
  25. header("Content-Disposition: attachment; filename=\"".$backup."\";" );
  26. header("X-Accel-Redirect: /backup/" . $backup);
  27. }
  28. }