BioTorrents.de’s version of Gazelle
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 964B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /*
  3. * Force file downloads
  4. * Currently used to download BibTeX citations
  5. * todo: Make this work with POST and display Show/Hide and Download buttons on the same line
  6. *
  7. if (isset($_POST['file']) && isset($_POST['content'])) {
  8. // Get parameters
  9. $file = urldecode($_POST['file']); // Decode URL-encoded string
  10. $content = urldecode($_POST['file']);
  11. $filepath = "/tmp/$file.bib";
  12. file_put_contents($filepath, $content);
  13. // Process download
  14. if (file_exists($filepath)) {
  15. header('Content-Description: File Transfer');
  16. header('Content-Type: text/plain');
  17. header('Content-Disposition: attachment; filename="'.basename($filepath).'"');
  18. header('Expires: 0');
  19. header('Cache-Control: must-revalidate');
  20. header('Pragma: public');
  21. header('Content-Length: ' . filesize($filepath));
  22. flush(); // Flush system output buffer
  23. readfile($filepath);
  24. exit;
  25. }
  26. }
  27. */