2013-07-25 12:35:19 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2015-06-25 12:43:55 +03:00
|
|
|
* @author Andreas Fischer <bantu@owncloud.com>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2018-03-22 15:19:29 +03:00
|
|
|
\OC_JSON::checkAppEnabled('files_versions');
|
|
|
|
\OC_JSON::checkLoggedIn();
|
2013-07-25 12:35:19 +04:00
|
|
|
|
|
|
|
$file = $_GET['file'];
|
|
|
|
$revision=(int)$_GET['revision'];
|
|
|
|
|
2016-12-06 00:15:59 +03:00
|
|
|
try {
|
|
|
|
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file);
|
|
|
|
} catch(\OCP\Files\NotFoundException $e) {
|
2018-06-26 11:32:50 +03:00
|
|
|
http_response_code(404);
|
2016-12-06 00:15:59 +03:00
|
|
|
$tmpl = new OCP\Template('', '404', 'guest');
|
|
|
|
$tmpl->assign('file', '');
|
|
|
|
$tmpl->printPage();
|
|
|
|
exit();
|
|
|
|
}
|
2013-07-25 12:35:19 +04:00
|
|
|
|
|
|
|
$versionName = '/'.$uid.'/files_versions/'.$filename.'.v'.$revision;
|
|
|
|
|
|
|
|
$view = new OC\Files\View('/');
|
|
|
|
|
2015-12-18 15:42:59 +03:00
|
|
|
$ftype = \OC::$server->getMimeTypeDetector()->getSecureMimeType($view->getMimeType('/'.$uid.'/files/'.$filename));
|
2013-07-25 12:35:19 +04:00
|
|
|
|
|
|
|
header('Content-Type:'.$ftype);
|
2018-03-21 16:17:12 +03:00
|
|
|
\OC_Response::setContentDispositionHeader(basename($filename), 'attachment');
|
2018-01-22 17:35:35 +03:00
|
|
|
header('Pragma: public');// enable caching in IE
|
|
|
|
header('Expires: 0');
|
|
|
|
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
2018-03-21 16:17:12 +03:00
|
|
|
\OC_Response::setContentLengthHeader($view->filesize($versionName));
|
2013-07-25 12:35:19 +04:00
|
|
|
|
|
|
|
OC_Util::obEnd();
|
|
|
|
|
|
|
|
$view->readfile($versionName);
|