[TASK] Replace confirm for delete record in PageModule
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Resources / PHP / FileDumpEID.php
1 <?php
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15 $parameters = array('eID' => 'dumpFile');
16 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t')) {
17 $parameters['t'] = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t');
18 }
19 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('f')) {
20 $parameters['f'] = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('f');
21 }
22 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('p')) {
23 $parameters['p'] = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('p');
24 }
25
26 if (\TYPO3\CMS\Core\Utility\GeneralUtility::hmac(implode('|', $parameters), 'resourceStorageDumpFile') === \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('token')) {
27 if (isset($parameters['f'])) {
28 $file = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($parameters['f']);
29 if ($file->isDeleted() || $file->isMissing()) {
30 $file = NULL;
31 }
32 } else {
33 $file = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ProcessedFileRepository::class)->findByUid($parameters['p']);
34 if ($file->isDeleted()) {
35 $file = NULL;
36 }
37 }
38
39 if ($file === NULL) {
40 \TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit(\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_404);
41 }
42
43 // Hook: allow some other process to do some security/access checks. Hook should issue 403 if access is rejected
44 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'])) {
45 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'] as $classRef) {
46 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
47 if (!$hookObject instanceof \TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface) {
48 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Resource\\FileDumpEIDHookInterface', 1394442417);
49 }
50 $hookObject->checkFileAccess($file);
51 }
52 }
53 $file->getStorage()->dumpFileContents($file);
54 } else {
55 \TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit(\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_403);
56 }