KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1KB

  1. <?php
  2. if (file_exists("/var/www/kxstudio/paste/"))
  3. $base_dir = "/var/www/kxstudio/paste/";
  4. else
  5. $base_dir = "/home/groups/k/kx/kxstudio/htdocs/paste/";
  6. function downloadFile($fullPath) {
  7. // Must be fresh start
  8. if(headers_sent())
  9. die('Headers Sent');
  10. // Required for some browsers
  11. if(ini_get('zlib.output_compression'))
  12. ini_set('zlib.output_compression', 'Off');
  13. $fsize = filesize($fullPath);
  14. header("Pragma: public"); // required
  15. header("Expires: 0");
  16. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  17. header("Cache-Control: private",false); // required for certain browsers
  18. header("Content-Type: application/force-download");
  19. header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
  20. header("Content-Transfer-Encoding: binary");
  21. header("Content-Length: ".$fsize);
  22. ob_clean();
  23. flush();
  24. readfile($fullPath);
  25. }
  26. if (!empty($_GET["id"])) {
  27. $paste_id = htmlspecialchars($_GET["id"]);
  28. $paste_file = $base_dir . "repo/" . $paste_id;
  29. if (!file_exists($paste_file)) die("File does not exist");
  30. downloadFile($paste_file);
  31. }
  32. ?>