2011-02-08 08:58:36 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
|
|
|
// Copyright (C) 2010 Matteo Lucarelli
|
2012-12-14 08:00:30 +00:00
|
|
|
// Copyright (C) 2011-2013 Uwe Steinmann
|
2011-02-08 08:58:36 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
include("../inc/inc.Settings.php");
|
2013-07-21 09:53:28 +00:00
|
|
|
include("../inc/inc.LogInit.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Language.php");
|
2011-02-08 08:58:36 +00:00
|
|
|
include("../inc/inc.Utils.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Init.php");
|
|
|
|
include("../inc/inc.Extension.php");
|
2010-10-29 13:19:51 +00:00
|
|
|
include("../inc/inc.DBInit.php");
|
|
|
|
include("../inc/inc.ClassUI.php");
|
2013-07-21 09:53:28 +00:00
|
|
|
include("../inc/inc.ClassController.php");
|
2011-02-08 08:58:36 +00:00
|
|
|
include("../inc/inc.Authentication.php");
|
2013-07-21 09:53:28 +00:00
|
|
|
|
|
|
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
|
|
|
$controller = Controller::factory($tmp[1]);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (isset($_GET["version"])) {
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// document download
|
2011-02-08 08:58:36 +00:00
|
|
|
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
$documentid = $_GET["documentid"];
|
2010-11-12 22:47:41 +00:00
|
|
|
$document = $dms->getDocument($documentid);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
|
|
|
|
|
|
|
}
|
|
|
|
$folder = $document->getFolder();
|
2010-12-22 08:50:57 +00:00
|
|
|
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if ($document->getAccessMode($user) < M_READ) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_numeric($_GET["version"]) || intval($_GET["version"])<1) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
|
|
|
}
|
|
|
|
$version = $_GET["version"];
|
2010-10-29 13:19:51 +00:00
|
|
|
$content = $document->getContentByVersion($version);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (!is_object($content)) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
|
|
|
}
|
|
|
|
|
2013-07-21 09:53:28 +00:00
|
|
|
$controller->setParam('content', $content);
|
|
|
|
$controller->setParam('type', 'version');
|
|
|
|
$controller->run();
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
} elseif (isset($_GET["file"])) {
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// file download
|
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
$documentid = $_GET["documentid"];
|
2010-11-12 22:47:41 +00:00
|
|
|
$document = $dms->getDocument($documentid);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
|
|
|
|
|
|
|
}
|
|
|
|
$folder = $document->getFolder();
|
2010-12-22 08:50:57 +00:00
|
|
|
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if ($document->getAccessMode($user) < M_READ) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_numeric($_GET["file"]) || intval($_GET["file"])<1) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_file_id"));
|
|
|
|
}
|
|
|
|
$fileid = $_GET["file"];
|
2010-11-12 22:47:41 +00:00
|
|
|
$file = $document->getDocumentFile($fileid);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (!is_object($file)) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_file_id"));
|
|
|
|
}
|
|
|
|
|
2015-06-08 19:59:56 +00:00
|
|
|
$controller->setParam('file', $file);
|
|
|
|
$controller->setParam('type', 'file');
|
|
|
|
$controller->run();
|
2011-02-08 08:58:36 +00:00
|
|
|
} elseif (isset($_GET["arkname"])) {
|
2014-03-21 07:09:07 +00:00
|
|
|
$filename = basename($_GET["arkname"]);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// backup download
|
|
|
|
|
|
|
|
if (!$user->isAdmin()) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-02-08 08:58:36 +00:00
|
|
|
|
2014-03-21 07:09:07 +00:00
|
|
|
if (!isset($filename) || !file_exists($settings->_contentDir.$filename) ) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
header('Content-Description: File Transfer');
|
2014-03-21 07:09:07 +00:00
|
|
|
//header("Content-Type: application/force-download; name=\"" . $filename . "\"");
|
2010-10-29 13:19:51 +00:00
|
|
|
//header("Content-Type: application/octet-stream");
|
|
|
|
header("Content-Type: application/zip");
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Content-Transfer-Encoding: binary");
|
2014-03-21 07:09:07 +00:00
|
|
|
header("Content-Length: " . filesize($settings->_contentDir . $filename ));
|
|
|
|
header("Content-Disposition: attachment; filename=\"" .$filename . "\"");
|
2011-02-08 08:58:36 +00:00
|
|
|
// header("Expires: 0");
|
|
|
|
//header("Content-Type: " . $content->getMimeType());
|
|
|
|
//header("Cache-Control: no-cache, must-revalidate");
|
2010-10-29 13:19:51 +00:00
|
|
|
// header("Cache-Control: must-revalidate");
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Cache-Control: public");
|
2010-10-29 13:19:51 +00:00
|
|
|
//header("Pragma: no-cache");
|
|
|
|
|
2014-01-10 07:21:04 +00:00
|
|
|
ob_clean();
|
2014-03-21 07:09:07 +00:00
|
|
|
readfile($settings->_contentDir .$filename );
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
} elseif (isset($_GET["logname"])) {
|
2014-03-21 07:09:07 +00:00
|
|
|
$filename = basename($_GET["logname"]);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// log download
|
|
|
|
|
|
|
|
if (!$user->isAdmin()) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-02-08 08:58:36 +00:00
|
|
|
|
2014-03-21 07:09:07 +00:00
|
|
|
if (!isset($filename) || !file_exists($settings->_contentDir.$filename) ) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
|
|
|
|
2014-03-21 07:09:07 +00:00
|
|
|
header("Content-Type: text/plain; name=\"" . $filename . "\"");
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Content-Transfer-Encoding: binary");
|
2014-03-21 07:09:07 +00:00
|
|
|
header("Content-Length: " . filesize($settings->_contentDir . $filename ));
|
|
|
|
header("Content-Disposition: attachment; filename=\"" .$filename . "\"");
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Cache-Control: must-revalidate");
|
2014-01-10 07:21:04 +00:00
|
|
|
|
|
|
|
ob_clean();
|
2014-03-21 07:09:07 +00:00
|
|
|
readfile($settings->_contentDir .$filename );
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
} elseif (isset($_GET["vfile"])) {
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// versioning info download
|
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
$documentid = $_GET["documentid"];
|
2010-11-18 13:53:26 +00:00
|
|
|
$document = $dms->getDocument($documentid);
|
2011-02-08 08:58:36 +00:00
|
|
|
|
|
|
|
if (!is_object($document)) {
|
|
|
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update infos
|
|
|
|
createVersionigFile($document);
|
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Content-Type: text/plain; name=\"" . $settings->_versioningFileName . "\"");
|
|
|
|
//header("Content-Type: application/force-download; name=\"" . $settings->_versioningFileName . "\"");
|
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
header("Content-Length: " . filesize($dms->contentDir.$document->getDir().$settings->_versioningFileName )."\"");
|
|
|
|
header("Content-Disposition: attachment; filename=\"". $settings->_versioningFileName . "\"");
|
|
|
|
//header("Expires: 0");
|
|
|
|
//header("Content-Type: " . $content->getMimeType());
|
|
|
|
//header("Cache-Control: no-cache, must-revalidate");
|
|
|
|
header("Cache-Control: must-revalidate");
|
2010-10-29 13:19:51 +00:00
|
|
|
//header("Pragma: no-cache");
|
|
|
|
|
2014-01-10 07:21:04 +00:00
|
|
|
ob_clean();
|
2011-02-08 08:58:36 +00:00
|
|
|
readfile($dms->contentDir . $document->getDir() .$settings->_versioningFileName);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
} elseif (isset($_GET["dumpname"])) {
|
2014-03-21 07:09:07 +00:00
|
|
|
$filename = basename($_GET["dumpname"]);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
// dump file download
|
|
|
|
|
|
|
|
if (!$user->isAdmin()) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-02-08 08:58:36 +00:00
|
|
|
|
2014-03-21 07:09:07 +00:00
|
|
|
if (!isset($filename) || !file_exists($settings->_contentDir.$filename) ) {
|
2011-02-08 08:58:36 +00:00
|
|
|
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
|
|
|
|
2014-03-21 07:09:07 +00:00
|
|
|
header("Content-Type: application/zip; name=\"" . $filename . "\"");
|
|
|
|
//header("Content-Type: application/force-download; name=\"" . $filename . "\"");
|
2011-02-08 08:58:36 +00:00
|
|
|
header("Content-Transfer-Encoding: binary");
|
2014-03-21 07:09:07 +00:00
|
|
|
header("Content-Length: " . filesize($settings->_contentDir . $filename ));
|
|
|
|
header("Content-Disposition: attachment; filename=\"" .$filename . "\"");
|
2011-02-08 08:58:36 +00:00
|
|
|
//header("Expires: 0");
|
|
|
|
//header("Content-Type: " . $content->getMimeType());
|
|
|
|
//header("Cache-Control: no-cache, must-revalidate");
|
|
|
|
header("Cache-Control: must-revalidate");
|
2010-10-29 13:19:51 +00:00
|
|
|
//header("Pragma: no-cache");
|
|
|
|
|
2014-01-10 07:21:04 +00:00
|
|
|
ob_clean();
|
2014-03-21 07:09:07 +00:00
|
|
|
readfile($settings->_contentDir .$filename );
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 08:58:36 +00:00
|
|
|
add_log_line();
|
|
|
|
exit();
|