[3526] | 1 | <?php |
---|
| 2 | //session_cache_limiter('none'); |
---|
| 3 | include("../inc/inc.Settings.php"); |
---|
| 4 | include("../inc/inc.AccessUtils.php"); |
---|
| 5 | include("../inc/inc.ClassAccess.php"); |
---|
| 6 | include("../inc/inc.ClassDocument.php"); |
---|
| 7 | include("../inc/inc.ClassFolder.php"); |
---|
| 8 | include("../inc/inc.ClassGroup.php"); |
---|
| 9 | include("../inc/inc.ClassUser.php"); |
---|
| 10 | include("../inc/inc.DBAccess.php"); |
---|
| 11 | include("../inc/inc.Language.php"); |
---|
| 12 | include("../inc/inc.OutUtils.php"); |
---|
| 13 | include("../inc/inc.Authentication.php"); |
---|
| 14 | |
---|
| 15 | $documentid = (isset($_GET['documentid'])) ? (int) $_GET['documentid'] : NULL; |
---|
| 16 | $version = (isset($_GET['version'])) ? (int) $_GET['version'] : NULL; |
---|
| 17 | |
---|
| 18 | $document = getDocument($documentid); |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | if ($document->getAccessMode($user) < M_READ) |
---|
| 22 | { |
---|
| 23 | printHTMLHead( getMLText("download") ); |
---|
| 24 | printCenterStart(); |
---|
| 25 | printStartBox(getMLText("download")); |
---|
| 26 | print "<div class=\"standardText\">"; |
---|
| 27 | printMLText("operation_not_allowed"); |
---|
| 28 | printGoBack(); |
---|
| 29 | print "</div>"; |
---|
| 30 | printEndBox(); |
---|
| 31 | printCenterEnd(); |
---|
| 32 | printHTMLFoot(); |
---|
| 33 | exit; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | $content = $document->getContentByVersion($version); |
---|
| 37 | |
---|
| 38 | if (is_bool($content) && !$content) |
---|
| 39 | die("Version " . $version . " of Document \"" . $document->getName() . "\" not found"); |
---|
| 40 | |
---|
| 41 | header("Pragma: public"); |
---|
| 42 | header("Expires: 0"); |
---|
| 43 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 44 | header("Content-Type: " . $content->getMimeType()); |
---|
| 45 | # Content-Length header does not work correctly on firefox and maybe other browser |
---|
| 46 | # the right filesize gets send(like reported by ls on the filesystem) |
---|
| 47 | # but the file stored by the firefox browser is about ~4000 ... 8000 bytes to small |
---|
| 48 | # disabling Content-Length header solves this problem |
---|
| 49 | #header("Content-Length: " . filesize($settings->_contentDir . $content->getPath() ) ); |
---|
| 50 | header("Content-Disposition: attachment; filename=\"" . $content->getOriginalFileName() . "\""); |
---|
| 51 | header("Content-Transfer-Encoding: binary\n"); |
---|
| 52 | |
---|
| 53 | readfile($settings->_contentDir . $content->getPath()); |
---|
| 54 | exit(); |
---|
| 55 | ?> |
---|