[!!!][SECURITY] Allow first install only with FIRST_INSTALL file
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DefaultConfiguration.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Set production defaults
29 */
30 class DefaultConfiguration extends AbstractStepAction {
31
32 /**
33 * Set defaults of auto configuration, mark installation as completed
34 *
35 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
36 */
37 public function execute() {
38 /** @var \TYPO3\CMS\Install\Configuration\FeatureManager $featureManager */
39 $featureManager = $this->objectManager->get('TYPO3\\CMS\\Install\\Configuration\\FeatureManager');
40 // Get best matching configuration presets
41 $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
42
43 // let the admin user redirect to the distributions page on first login
44 if (isset($this->postValues['values']['loaddistributions'])) {
45
46 // update the admin backend user to show the distribution management on login
47 $adminUserFirstLogin = array('startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List');
48 $this->getDatabaseConnection()->exec_UPDATEquery(
49 'be_users',
50 'admin=1',
51 array('uc' => serialize($adminUserFirstLogin))
52 );
53 }
54
55 // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
56 $configurationValues['SYS/isInitialInstallationInProgress'] = FALSE;
57
58 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
59 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
60 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
61
62 /** @var \TYPO3\CMS\Install\Service\SessionService $session */
63 $session = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SessionService');
64 $session->destroySession();
65
66 /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
67 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get(
68 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection'
69 );
70 $formProtection->clean();
71
72 // @TODO: This and similar code in ToolController should be moved to enable install file service
73 $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
74 if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
75 unlink($enableInstallToolFile);
76 }
77
78 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('../../../index.php', \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
79 }
80
81 /**
82 * Step needs to be executed if 'isInitialInstallationInProgress' is set to TRUE in LocalConfiguration
83 *
84 * @return boolean
85 */
86 public function needsExecution() {
87 $result = FALSE;
88 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'])
89 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'] === TRUE
90 ) {
91 $result = TRUE;
92 }
93 return $result;
94 }
95
96 /**
97 * Executes the step
98 *
99 * @return string Rendered content
100 */
101 protected function executeAction() {
102 return $this->view->render();
103 }
104 }