Commit f94449ba9b9acf65a1e8b442c9a31ee3c1652922
1 parent
83b27bbb
Work around Microsoft IE KB812935 issue with Cache-Control headers (used
to prevent using cached versions) by setting Last-Modified and using must-revalidate instead. Submitted by: freboulet SF Tracker: 1179269 SF Tracker: 1165451 git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3238 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
52 additions
and
48 deletions
lib/documentmanagement/PhysicalDocumentManager.inc
| @@ -92,22 +92,24 @@ class PhysicalDocumentManager { | @@ -92,22 +92,24 @@ class PhysicalDocumentManager { | ||
| 92 | * @todo investigate possible problem in MSIE 5.5 concerning Content-Disposition header | 92 | * @todo investigate possible problem in MSIE 5.5 concerning Content-Disposition header |
| 93 | */ | 93 | */ |
| 94 | function downloadPhysicalDocument($iDocumentID) { | 94 | function downloadPhysicalDocument($iDocumentID) { |
| 95 | - //get the document | ||
| 96 | - $oDocument = & Document::get($iDocumentID); | ||
| 97 | - //get the path to the document on the server | ||
| 98 | - $sDocumentFileSystemPath = $oDocument->getPath(); | ||
| 99 | - if (file_exists($sDocumentFileSystemPath)) { | ||
| 100 | - //set the correct headers | ||
| 101 | - Header("Content-Type: " . PhysicalDocumentManager::getMimeTypeName($oDocument->getMimeTypeID())); | ||
| 102 | - Header("Content-Length: ". $oDocument->getFileSize()); | ||
| 103 | - Header("Content-Disposition: attachment; filename=\"" . $oDocument->getFileName() . "\""); | ||
| 104 | - Header("Pragma: no-cache"); | ||
| 105 | - Header("Cache-Control: no-cache"); | ||
| 106 | - Header("Expires: 0"); | ||
| 107 | - readfile($sDocumentFileSystemPath); | ||
| 108 | - } else { | 95 | + //get the document |
| 96 | + $oDocument = & Document::get($iDocumentID); | ||
| 97 | + //get the path to the document on the server | ||
| 98 | + $sDocumentFileSystemPath = $oDocument->getPath(); | ||
| 99 | + if (file_exists($sDocumentFileSystemPath)) { | ||
| 100 | + //set the correct headers | ||
| 101 | + header("Content-Type: application/octet-stream"); | ||
| 102 | + header("Content-Length: ". $oDocument->getFileSize()); | ||
| 103 | + header("Content-Disposition: attachment; filename=\"" . $oDocument->getFileName() . "\""); | ||
| 104 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | ||
| 105 | + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | ||
| 106 | + header("Cache-Control: must-revalidate"); | ||
| 107 | + header("Content-Location: ".$oDocument->getFileName()); | ||
| 108 | + | ||
| 109 | + readfile($sDocumentFileSystemPath); | ||
| 110 | + } else { | ||
| 109 | return false; | 111 | return false; |
| 110 | - } | 112 | + } |
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | /** | 115 | /** |
| @@ -118,24 +120,25 @@ class PhysicalDocumentManager { | @@ -118,24 +120,25 @@ class PhysicalDocumentManager { | ||
| 118 | * @return int number of bytes read from file on success or false otherwise; | 120 | * @return int number of bytes read from file on success or false otherwise; |
| 119 | */ | 121 | */ |
| 120 | function downloadVersionedPhysicalDocument($iDocumentID, $sVersion) { | 122 | function downloadVersionedPhysicalDocument($iDocumentID, $sVersion) { |
| 121 | - //get the document | ||
| 122 | - $oDocument = & Document::get($iDocumentID); | ||
| 123 | - //get the path to the document on the server | ||
| 124 | - $sDocumentFileSystemPath = $oDocument->getPath() . "-$sVersion"; | ||
| 125 | - if (file_exists($sDocumentFileSystemPath)) { | ||
| 126 | - //set the correct headers | ||
| 127 | - Header("Content-Type: " . PhysicalDocumentManager::getMimeTypeName($oDocument->getMimeTypeID())); | ||
| 128 | - header("Content-Length: ". $oDocument->getFileSize()); | ||
| 129 | - // prefix the filename presented to the browser to preserve the document extension | ||
| 130 | - header("Content-Disposition: attachment; filename=" . "$sVersion-" . $oDocument->getFileName()); | ||
| 131 | - Header("Pragma: no-cache"); | ||
| 132 | - Header("Cache-Control: no-cache"); | ||
| 133 | - header("Expires: 0"); | ||
| 134 | - readfile($sDocumentFileSystemPath); | ||
| 135 | - } else { | ||
| 136 | - return false; | 123 | + //get the document |
| 124 | + $oDocument = & Document::get($iDocumentID); | ||
| 125 | + //get the path to the document on the server | ||
| 126 | + $sDocumentFileSystemPath = $oDocument->getPath() . "-$sVersion"; | ||
| 127 | + if (file_exists($sDocumentFileSystemPath)) { | ||
| 128 | + //set the correct headers | ||
| 129 | + header("Content-Type: application/octet-stream"); | ||
| 130 | + header("Content-Length: ". $oDocument->getFileSize()); | ||
| 131 | + // prefix the filename presented to the browser to preserve the document extension | ||
| 132 | + header('Content-Disposition: attachment; filename="' . "$sVersion-" . $oDocument->getFileName() . '"'); | ||
| 133 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | ||
| 134 | + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | ||
| 135 | + header("Cache-Control: must-revalidate"); | ||
| 136 | + header("Content-Location: ".$oDocument->getFileName()); | ||
| 137 | + readfile($sDocumentFileSystemPath); | ||
| 138 | + } else { | ||
| 139 | + return false; | ||
| 140 | + } | ||
| 137 | } | 141 | } |
| 138 | - } | ||
| 139 | 142 | ||
| 140 | /** | 143 | /** |
| 141 | * Move a document to a new folder | 144 | * Move a document to a new folder |
| @@ -378,24 +381,25 @@ class PhysicalDocumentManager { | @@ -378,24 +381,25 @@ class PhysicalDocumentManager { | ||
| 378 | * @todo investigate possible problem in MSIE 5.5 concerning Content-Disposition header | 381 | * @todo investigate possible problem in MSIE 5.5 concerning Content-Disposition header |
| 379 | */ | 382 | */ |
| 380 | function inlineViewPhysicalDocument($iDocumentID) { | 383 | function inlineViewPhysicalDocument($iDocumentID) { |
| 381 | - //get the document | ||
| 382 | - $oDocument = & Document::get($iDocumentID); | ||
| 383 | - //get the path to the document on the server | ||
| 384 | - $sDocumentFileSystemPath = $oDocument->getPath(); | ||
| 385 | - if (file_exists($sDocumentFileSystemPath)) { | ||
| 386 | - Header("Content-Type: " . PhysicalDocumentManager::getMimeTypeName($oDocument->getMimeTypeID())); | ||
| 387 | - Header("Content-Length: " . $oDocument->getFileSize()); | ||
| 388 | - Header("Content-Disposition: inline; filename=" . $oDocument->getFileName()); | ||
| 389 | - Header("Pragma: no-cache"); | ||
| 390 | - Header("Cache-Control: no-cache"); | ||
| 391 | - return readfile($sDocumentFileSystemPath); | ||
| 392 | - } else { | ||
| 393 | - return false; | ||
| 394 | - } | 384 | + //get the document |
| 385 | + $oDocument = & Document::get($iDocumentID); | ||
| 386 | + //get the path to the document on the server | ||
| 387 | + $sDocumentFileSystemPath = $oDocument->getPath(); | ||
| 388 | + if (file_exists($sDocumentFileSystemPath)) { | ||
| 389 | + header("Content-Type: application/octet-stream"); | ||
| 390 | + header("Content-Length: ". $oDocument->getFileSize()); | ||
| 391 | + // prefix the filename presented to the browser to preserve the document extension | ||
| 392 | + header('Content-Disposition: inline; filename="' . $oDocument->getFileName() . '"'); | ||
| 393 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | ||
| 394 | + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | ||
| 395 | + header("Cache-Control: must-revalidate"); | ||
| 396 | + header("Content-Location: ".$oDocument->getFileName()); | ||
| 397 | + return readfile($sDocumentFileSystemPath); | ||
| 398 | + } else { | ||
| 399 | + return false; | ||
| 400 | + } | ||
| 395 | } | 401 | } |
| 396 | 402 | ||
| 397 | - | ||
| 398 | - | ||
| 399 | /** | 403 | /** |
| 400 | * Get the uploaded file information and place it into a document object | 404 | * Get the uploaded file information and place it into a document object |
| 401 | * | 405 | * |