43 protected function isInstallToolAvailable() {
45 $installToolEnableService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\EnableFileService');
46 if ($installToolEnableService->isFirstInstallAllowed()) {
49 return $installToolEnableService->checkInstallToolEnableFile();
61 protected function outputInstallToolNotEnabledMessageIfNeeded() {
62 if (!$this->isInstallToolAvailable()) {
65 $action = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Controller\\Action\\Common\\AccessNotAllowedAction');
66 $action->setAction(
'accessNotAllowed');
69 $action = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Controller\\Action\\Common\\InstallToolDisabledAction');
70 $action->setAction(
'installToolDisabled');
72 $action->setController(
'common');
73 $this->
output($action->handle());
83 protected function outputInstallToolPasswordNotSetMessageIfNeeded() {
84 if (!$this->isInitialInstallationInProgress()
85 && (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'installToolPassword']))
88 $action = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Controller\\Action\\Common\\InstallToolPasswordNotSetAction');
89 $action->setController(
'common');
90 $action->setAction(
'installToolPasswordNotSet');
91 $this->
output($action->handle());
101 protected function checkSessionToken() {
104 if (count($postValues) > 0) {
106 if (isset($postValues[
'token'])) {
109 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection' 112 if ($action ===
'') {
114 'No POST action given for token check',
118 $tokenOk = $formProtection->validateToken($postValues[
'token'],
'installTool', $action);
124 $this->handleSessionTokenCheck($tokenOk);
135 protected function handleSessionTokenCheck($tokenOk) {
137 $this->session->resetSession();
138 $this->session->startSession();
140 if ($this->isInitialInstallationInProgress()) {
144 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
145 $message->setTitle(
'Invalid form token');
146 $message->setMessage(
147 'The form protection token was invalid. You have been logged out, please log in and try again.' 149 $this->
output($this->loginForm($message));
160 if ($this->session->isExpired()) {
162 $this->session->resetSession();
163 $this->session->startSession();
165 $this->handleSessionLifeTimeExpired();
175 protected function handleSessionLifeTimeExpired() {
176 if ($this->isInitialInstallationInProgress()) {
180 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
181 $message->setTitle(
'Session expired');
182 $message->setMessage(
183 'Your Install Tool session has expired. You have been logged out, please log in and try again.' 185 $this->
output($this->loginForm($message));
195 protected function loginForm(\
TYPO3\CMS\Install\Status\StatusInterface $message = NULL) {
197 $action = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Controller\\Action\\Common\\LoginForm');
198 $action->setController(
'common');
199 $action->setAction(
'login');
200 $action->setToken($this->generateTokenForAction(
'login'));
203 $action->setMessages(array($message));
205 $content = $action->handle();
214 protected function loginIfRequested() {
217 if ($action ===
'login') {
219 $validPassword = FALSE;
220 if (isset($postValues[
'values'][
'password'])) {
221 $password = $postValues[
'values'][
'password'];
222 $installToolPassword =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'installToolPassword'];
224 if (is_object($saltFactory)) {
225 $validPassword = $saltFactory->checkPassword($password, $installToolPassword);
226 } elseif (md5($password) === $installToolPassword) {
229 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
230 $configurationManager->setLocalConfigurationValueByPath(
231 'BE/installToolPassword',
232 $saltFactory->getHashedPassword($password)
234 $validPassword = TRUE;
237 if ($validPassword) {
238 $this->session->setAuthorized();
239 $this->sendLoginSuccessfulMail();
243 $hashedPassword = $saltFactory->getHashedPassword($password);
245 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
246 $message->setTitle(
'Login failed');
247 $message->setMessage(
'Given password does not match the install tool login password. ' .
248 'Calculated hash: ' . $hashedPassword);
249 $this->sendLoginFailedMail();
250 $this->
output($this->loginForm($message));
262 if (!$this->session->isAuthorized()
263 && !$this->isInitialInstallationInProgress()
265 $this->
output($this->loginForm());
267 $this->session->refreshSession();
276 protected function sendLoginSuccessfulMail() {
277 $warningEmailAddress =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_email_addr'];
278 if ($warningEmailAddress) {
280 $mailMessage = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Mail\\MailMessage');
282 ->addTo($warningEmailAddress)
283 ->setSubject(
'Install Tool Login at \'' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
'\'')
285 ->setBody(
'There has been an Install Tool login at TYPO3 site' 286 .
' \'' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
'\'' 299 protected function sendLoginFailedMail() {
301 $warningEmailAddress =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'warning_email_addr'];
302 if ($warningEmailAddress) {
304 $mailMessage = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Mail\\MailMessage');
306 ->addTo($warningEmailAddress)
307 ->setSubject(
'Install Tool Login ATTEMPT at \'' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
'\'')
309 ->setBody(
'There has been an Install Tool login attempt at TYPO3 site' 310 .
' \'' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'] .
'\'' 312 .
' The last 5 characters of the MD5 hash of the password tried was \'' . substr(md5($formValues[
'password']), -5) .
'\'' 326 protected function generateTokenForAction($action = NULL) {
330 if ($action ===
'') {
332 'Token must have a valid action name',
338 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection' 340 return $formProtection->generateToken(
'installTool', $action);
349 protected function isInitialInstallationInProgress() {
351 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
353 $localConfigurationFileLocation = $configurationManager->getLocalConfigurationFileLocation();
354 $localConfigurationFileExists = @is_file($localConfigurationFileLocation);
356 if (!$localConfigurationFileExists
357 || !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'isInitialInstallationInProgress'])
371 protected function initializeSession() {
373 $this->session = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SessionService');
374 if (!$this->session->hasSession()) {
375 $this->session->startSession();
386 foreach ($messages as $message) {
387 $this->session->addMessage($message);
396 protected function initializeObjectManager() {
409 protected function loadBaseExtensions() {
411 require(\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'dbal') .
'ext_localconf.php');
412 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'dbal'][
'backend']
413 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
414 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'dbal'][
'options'] = array();
417 require(\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'extbase') .
'ext_localconf.php');
418 require(\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'fluid') .
'ext_localconf.php');
420 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_datamapfactory_datamap'][
'backend']
421 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
422 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_datamapfactory_datamap'][
'options'] = array();
423 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_object'][
'backend']
424 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
425 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_object'][
'options'] = array();
426 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_reflection'][
'backend']
427 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
428 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_reflection'][
'options'] = array();
429 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_typo3dbbackend_tablecolumns'][
'backend']
430 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
431 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'extbase_typo3dbbackend_tablecolumns'][
'options'] = array();
432 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'fluid_template'][
'backend']
433 =
'TYPO3\\CMS\\Core\\Cache\\Backend\\NullBackend';
434 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'fluid_template'][
'options'] = array();
438 $cacheManager->setCacheConfigurations(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations']);
447 if (\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'adodb')
448 && \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'dbal')
462 if (!in_array($action, $this->authenticationActions)) {
464 $action .
' is not a valid authentication action',
479 if (isset($formValues[
'action'])) {
480 $action = $formValues[
'action'];
483 && $action !==
'login' 484 && $action !==
'loginForm' 485 && $action !==
'logout' 486 && !in_array($action, $this->authenticationActions)
489 'Invalid action ' . $action,
504 if (!is_array($postValues)) {
505 $postValues = array();
518 protected function redirect($controller =
'', $action =
'') {
524 if (isset($getPostValues[
'redirectCount'])) {
525 $redirectCount = (int)$getPostValues[
'redirectCount'] + 1;
529 if ($redirectCount >= 10) {
532 throw new Exception\RedirectLoopException(
533 'Redirect loop aborted. If this message is shown again after a reload,' .
534 ' your setup is so weird that the install tool is unable to handle it.' .
535 ' Please make sure to remove the "install[redirectCount]" parameter from your request or' .
536 ' restart the install tool from the backend navigation.',
540 $parameters[] =
'install[redirectCount]=' . $redirectCount;
543 $context =
'install[context]=standalone';
544 if (isset($getPostValues[
'context']) && $getPostValues[
'context'] ===
'backend') {
545 $context =
'install[context]=backend';
550 $controllerParameter =
'install[controller]=step';
551 if ((isset($getPostValues[
'controller']) && $getPostValues[
'controller'] ===
'tool')
552 || $controller ===
'tool' 554 $controllerParameter =
'install[controller]=tool';
559 if (strlen($action) > 0) {
563 $redirectLocation =
'Install.php?' . implode(
'&',
$parameters);
567 \
TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303
577 protected function output($content =
'') {
578 header(
'Content-Type: text/html; charset=utf-8');
579 header(
'Cache-Control: no-cache, must-revalidate');
580 header(
'Pragma: no-cache');
593 return !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress'])
594 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress']
595 :
'no-reply@example.com';
606 return !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName'])
607 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName']
608 :
'TYPO3 CMS install tool';
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
static getIndpEnv($getEnvName)
static makeInstance($className)
outputLoginFormIfNotAuthorized()
redirect($controller='', $action='')
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
addSessionMessages(array $messages)
static isFirstInstallAllowed()
validateAuthenticationAction($action)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]