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.

49 lines
1.3KB

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