out.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. $tempfilename = $_REQUEST['filename'].'.pdf';
  3. $opname = $_REQUEST['opname'];
  4. $dest = $_REQUEST['dest'];
  5. // Modified by Ivan Tcholakov, 28-JUN-2010.
  6. //if ($tempfilename && file_exists('../tmp/'.$tempfilename)) {
  7. if ($tempfilename && file_exists(_MPDF_TEMP_PATH.$tempfilename)) {
  8. //
  9. header("Pragma: ");
  10. header("Cache-Control: private");
  11. header("Content-transfer-encoding: binary\n");
  12. if ($dest=='I') {
  13. header('Content-Type: application/pdf');
  14. header('Content-disposition: inline; filename='.$opname);
  15. }
  16. else if ($dest=='D') {
  17. if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) {
  18. if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') {
  19. header('HTTP/1.1 200 OK');
  20. header('Status: 200 OK');
  21. header('Pragma: anytextexeptno-cache', true);
  22. header("Cache-Control: public, must-revalidate");
  23. }
  24. else {
  25. header('Cache-Control: public, must-revalidate');
  26. header('Pragma: public');
  27. }
  28. header('Content-Type: application/force-download');
  29. }
  30. else {
  31. header('Content-Type: application/octet-stream');
  32. }
  33. header('Content-disposition: attachment; filename='.$opname);
  34. }
  35. // Modified by Ivan Tcholakov, 28-JUN-2010.
  36. //$filesize = filesize('../tmp/'.$tempfilename);
  37. $filesize = filesize(_MPDF_TEMP_PATH.$tempfilename);
  38. //
  39. header("Content-length:".$filesize);
  40. // Modified by Ivan Tcholakov, 28-JUN-2010.
  41. //$fd=fopen('../tmp/'.$tempfilename,'r');
  42. $fd=fopen(_MPDF_TEMP_PATH.$tempfilename,'r');
  43. //
  44. fpassthru($fd);
  45. fclose($fd);
  46. // Modified by Ivan Tcholakov, 28-JUN-2010.
  47. //unlink('../tmp/'.$tempfilename);
  48. unlink(_MPDF_TEMP_PATH.$tempfilename);
  49. //
  50. // ====================== DELETE OLD FILES FIRST - Housekeeping =========================================
  51. // Clear any files in directory that are >24 hrs old
  52. $interval = 86400;
  53. // Modified by Ivan Tcholakov, 28-JAN-2010.
  54. //if ($handle = opendir('../tmp')) {
  55. // while (false !== ($file = readdir($handle))) {
  56. // if (((filemtime('../tmp/'.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
  57. // unlink('../tmp/'.$file);
  58. // }
  59. // }
  60. // closedir($handle);
  61. //}
  62. if ($handle = opendir(_MPDF_TEMP_PATH)) {
  63. while (false !== ($file = readdir($handle))) {
  64. if (((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
  65. unlink(_MPDF_TEMP_PATH.$file);
  66. }
  67. }
  68. closedir($handle);
  69. }
  70. //
  71. exit;
  72. }
  73. ?>