-
-
Save anonymous/ffcce414e71e3cee06a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Netlogix\Nxsecuredownload\Service; | |
/*************************************************************** | |
* Copyright notice | |
* | |
* (c) 2015 Stephan Schuler <stephan.schuler@netlogix.de>, netlogix GmbH & Co. KG | |
* | |
* All rights reserved | |
* | |
* This script is part of the TYPO3 project. The TYPO3 project 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 3 of the License, or | |
* (at your option) any later version. | |
* | |
* The GNU General Public License can be found at | |
* http://www.gnu.org/copyleft/gpl.html. | |
* | |
* This script 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. | |
* | |
* This copyright notice MUST APPEAR in all copies of the script! | |
***************************************************************/ | |
/** | |
* | |
* @package nxsecuredownload | |
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later | |
* | |
*/ | |
class RenderingDispatcher implements \TYPO3\CMS\Core\SingletonInterface { | |
/** | |
* The type number gets set by .htaccess rewrite and is used in | |
* TypoScript as well. | |
* | |
* @var int | |
*/ | |
protected $typeNumber = 1424796397; | |
protected $requestedFilePath = '/'; | |
/** | |
* The "pre process request" mechanism determines if the current request | |
* is meant as a download link. Some $_SERVER keys need to be cleared to | |
* make RealURL not kicking in for path to id mapping and falling into a | |
* pageNotFound situation. | |
* | |
* @return void | |
*/ | |
public function preProcessRequest() { | |
if ($this->typeNumber !== (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('type')) { | |
return; | |
} | |
$this->requestedFilePath = ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); | |
$getVars = array( | |
'type' => $this->typeNumber, | |
'file' => $this->requestedFilePath, | |
); | |
\TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($getVars); | |
$_SERVER['QUERY_STRING'] = http_build_query($getVars); | |
$_SERVER['REQUEST_URI'] = '/?' . $_SERVER['QUERY_STRING']; | |
} | |
/** | |
* To speed up things a view milliseconds, the SecureDownloadController is no | |
* extbase controller. | |
* | |
* @return string | |
*/ | |
public function run() { | |
/** @var \Netlogix\Nxsecuredownload\Service\SecureDownloadService $secureDownloadService */ | |
$secureDownloadService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Netlogix\\Nxsecuredownload\\Service\\SecureDownloadService'); | |
$secureDownloadService->initializeObject(); | |
$secureDownloadService->setConsiderBackendLogin(TRUE); | |
$secureDownloadService->setAllowOverruleFeGroups(FALSE); | |
/** @var \Netlogix\Nxsecuredownload\Controller\SecureDownloadController $controller */ | |
$controller = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Netlogix\\Nxsecuredownload\\Controller\\SecureDownloadController'); | |
$controller->injectSecureDownloadService($secureDownloadService); | |
$controller->injectSettings($secureDownloadService->getSettings()); | |
$controller->downloadAction($this->requestedFilePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment