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.

download.php 1.1KB

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