TYPO3 CMS  TYPO3_8-7
EidRequestHandler.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
25 
31 {
36  protected $bootstrap;
37 
43  public function __construct(Bootstrap $bootstrap)
44  {
45  $this->bootstrap = $bootstrap;
46  }
47 
54  public function handleRequest(ServerRequestInterface $request)
55  {
56  // Starting time tracking
57  $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']) ?: 'be_typo_user';
58 
60  $timeTracker = GeneralUtility::makeInstance(TimeTracker::class, ($request->getCookieParams()[$configuredCookieName] ? true : false));
61  $timeTracker->start();
62 
63  // Hook to preprocess the current request
64  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
65  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
66  $hookParameters = [];
67  GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
68  }
69  unset($hookFunction);
70  unset($hookParameters);
71  }
72 
73  // Remove any output produced until now
74  $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
75  return $this->dispatch($request);
76  }
77 
84  public function canHandleRequest(ServerRequestInterface $request)
85  {
86  return !empty($request->getQueryParams()['eID']) || !empty($request->getParsedBody()['eID']);
87  }
88 
95  public function getPriority()
96  {
97  return 80;
98  }
99 
107  protected function dispatch($request)
108  {
110  $response = GeneralUtility::makeInstance(Response::class);
111 
112  $eID = isset($request->getParsedBody()['eID'])
113  ? $request->getParsedBody()['eID']
114  : (isset($request->getQueryParams()['eID']) ? $request->getQueryParams()['eID'] : '');
115 
116  if (empty($eID) || !isset($GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID])) {
117  return $response->withStatus(404, 'eID not registered');
118  }
119 
120  $configuration = $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID];
121 
122  // Simple check to make sure that it's not an absolute file (to use the fallback)
123  if (strpos($configuration, '::') !== false || is_callable($configuration)) {
125  $dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
126  $request = $request->withAttribute('target', $configuration);
127  return $dispatcher->dispatch($request, $response);
128  }
129 
130  $scriptPath = GeneralUtility::getFileAbsFileName($configuration);
131  if ($scriptPath === '') {
132  throw new Exception('Registered eID has invalid script path.', 1416391467);
133  }
134  include $scriptPath;
135  return null;
136  }
137 }
handleRequest(\Psr\Http\Message\ServerRequestInterface $request)
canHandleRequest(ServerRequestInterface $request)
static callUserFunction($funcName, &$params, &$ref, $_='', $errorMode=0)
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']