KXStudio scripts and misc stuff
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.

39 lines
1.0KB

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