source: contrib/Dms/op/op.Download.php @ 3526

Revision 3526, 1.9 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado modulos Timesheet e DMS para a comunidade.

  • Property svn:executable set to *
Line 
1<?php
2//session_cache_limiter('none');
3include("../inc/inc.Settings.php");
4include("../inc/inc.AccessUtils.php");
5include("../inc/inc.ClassAccess.php");
6include("../inc/inc.ClassDocument.php");
7include("../inc/inc.ClassFolder.php");
8include("../inc/inc.ClassGroup.php");
9include("../inc/inc.ClassUser.php");
10include("../inc/inc.DBAccess.php");
11include("../inc/inc.Language.php");
12include("../inc/inc.OutUtils.php");
13include("../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
21if ($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
38if (is_bool($content) && !$content)
39        die("Version " . $version . " of Document \"" . $document->getName() . "\" not found");
40
41header("Pragma: public");
42header("Expires: 0");
43header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
44header("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() ) );
50header("Content-Disposition: attachment; filename=\"" . $content->getOriginalFileName() . "\"");
51header("Content-Transfer-Encoding: binary\n");
52
53readfile($settings->_contentDir . $content->getPath());
54exit();
55?>
Note: See TracBrowser for help on using the repository browser.