TYPO3 CMS  TYPO3_6-2
ToolController.php
Go to the documentation of this file.
1 <?php
3 
18 
26 
30  protected $authenticationActions = array(
31  'welcome',
32  'importantActions',
33  'systemEnvironment',
34  'configuration',
35  'folderStructure',
36  'testSetup',
37  'upgradeWizard',
38  'allConfiguration',
39  'cleanUp',
40  'loadExtensions',
41  );
42 
48  public function execute() {
49  $this->loadBaseExtensions();
50  $this->initializeObjectManager();
51 
52  // Warning: Order of these methods is security relevant and interferes with different access
53  // conditions (new/existing installation). See the single method comments for details.
54  $this->outputInstallToolNotEnabledMessageIfNeeded();
55  $this->outputInstallToolPasswordNotSetMessageIfNeeded();
56  $this->initializeSession();
57  $this->checkSessionToken();
58  $this->checkSessionLifetime();
59  $this->logoutIfRequested();
60  $this->loginIfRequested();
63  $this->dispatchAuthenticationActions();
64  }
65 
71  protected function logoutIfRequested() {
72  $action = $this->getAction();
73  if ($action === 'logout') {
76  }
77 
80  'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection'
81  );
82  $formProtection->clean();
83  $this->session->destroySession();
84  $this->redirect();
85  }
86  }
87 
96  register_shutdown_function(function() {
97  $error = error_get_last();
98  if ($error !== NULL) {
99  $errorType = $error["type"];
100 
101  if ($errorType & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)) {
102  $getPostValues = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('install');
103 
104  $parameters = array();
105 
106  // Add context parameter in case this script was called within backend scope
107  $context = 'install[context]=standalone';
108  if (isset($getPostValues['context']) && $getPostValues['context'] === 'backend') {
109  $context = 'install[context]=backend';
110  }
111  $parameters[] = $context;
112 
113  // Add controller parameter
114  $parameters[] = 'install[controller]=tool';
115 
116  // Add action if specified
117  $parameters[] = 'install[action]=loadExtensions';
118 
119  // Add error to display a message what triggered the check
120  $errorEncoded = json_encode($error);
121  $parameters[] = 'install[lastError]=' . rawurlencode($errorEncoded);
122  // We do not use GeneralUtility here to be sure that hash generation works even if that class might not exist any more.
123  $parameters[] = 'install[lastErrorHash]=' . hash_hmac('sha1', $errorEncoded, $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'InstallToolError');
124 
125  $redirectLocation = 'Install.php?' . implode('&', $parameters);
126 
127  if (!headers_sent()) {
129  $redirectLocation,
130  \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303
131  );
132  } else {
133  echo '
134 <p><strong>
135  The system detected a fatal error during script execution.
136  Please use the <a href="' . $redirectLocation . '">extension check tool</a> to find incompatible extensions.
137 </strong></p>';
138  }
139  }
140  }
141  });
142  }
143 
149  protected function getLastError() {
150  $getVars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('install');
151  $lastError = array();
152  if (isset($getVars['lastError']) && isset($getVars['lastErrorHash']) && !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
153  $calculatedHash = hash_hmac('sha1', $getVars['lastError'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'InstallToolError');
154  if ($calculatedHash === $getVars['lastErrorHash']) {
155  $lastError = json_decode($getVars['lastError'], TRUE);
156  }
157  }
158  return $lastError;
159  }
160 
167  protected function dispatchAuthenticationActions() {
168  $action = $this->getAction();
169  if ($action === '') {
170  $action = 'welcome';
171  }
172  $this->validateAuthenticationAction($action);
173  $actionClass = ucfirst($action);
175  $toolAction = $this->objectManager->get('TYPO3\\CMS\\Install\\Controller\\Action\\Tool\\' . $actionClass);
176  if (!($toolAction instanceof Action\ActionInterface)) {
177  throw new Exception(
178  $action . ' does not implement ActionInterface',
179  1369474309
180  );
181  }
182  $toolAction->setController('tool');
183  $toolAction->setAction($action);
184  $toolAction->setToken($this->generateTokenForAction($action));
185  $toolAction->setPostValues($this->getPostValues());
186  $toolAction->setLastError($this->getLastError());
187  $this->output($toolAction->handle());
188  }
189 }
$parameters
Definition: FileDumpEID.php:15
if(!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE' E_USER_ERROR
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]