/**
  * @test
  * @deprecated since 6.2. Test can be removed if injectInstallTool method is dropped
  */
 public function createValidationErrorMessageAddsErrorMessage()
 {
     $installTool = $this->getMock('stdClass', array('addErrorMessage'), array(), '', FALSE);
     $installTool->expects($this->once())->method('addErrorMessage')->with('Validating the security token of this form has failed. ' . 'Please reload the form and submit it again.');
     $this->fixture->injectInstallTool($installTool);
     $this->fixture->_call('createValidationErrorMessage');
 }
Пример #2
0
    /**
     * Constructor
     *
     * @return void
     * @todo Define visibility
     */
    public function __construct()
    {
        parent::__construct();
        if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
            $this->outputErrorAndExit('Install Tool deactivated.<br />
				You must enable it by setting a password in typo3conf/LocalConfiguration.php. If you insert the value below at array position \'EXT\' \'installToolPassword\', the password will be \'joh316\':<br /><br />
				\'bacb98acf97e0b6112b1d1b650b84971\'', 'Fatal error');
        }
        if ($this->sendNoCacheHeaders) {
            header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
            header('Expires: 0');
            header('Cache-Control: no-cache, must-revalidate');
            header('Pragma: no-cache');
        }
        // ****************************
        // Initializing incoming vars.
        // ****************************
        $this->INSTALL = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('TYPO3_INSTALL');
        $this->mode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mode');
        if ($this->mode !== '123') {
            $this->mode = '';
        }
        if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('step') === 'go') {
            $this->step = 'go';
        } else {
            $this->step = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('step'));
        }
        // Let DBAL decide whether to load itself
        $dbalLoaderFile = $this->backPath . 'sysext/dbal/class.tx_dbal_autoloader.php';
        if (@is_file($dbalLoaderFile)) {
            include $dbalLoaderFile;
        }
        if ($this->mode === '123') {
            // Check for mandatory PHP modules
            $missingPhpModules = $this->getMissingPhpModules();
            if (count($missingPhpModules) > 0) {
                throw new \RuntimeException('TYPO3 Installation Error: The following PHP module(s) is/are missing: <em>' . implode(', ', $missingPhpModules) . '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.', 1294587482);
            }
            // Load saltedpasswords if possible
            $saltedpasswordsLoaderFile = $this->backPath . 'sysext/saltedpasswords/classes/class.tx_saltedpasswords_autoloader.php';
            if (@is_file($saltedpasswordsLoaderFile)) {
                include $saltedpasswordsLoaderFile;
            }
        }
        $this->redirect_url = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('redirect_url'));
        $this->INSTALL['type'] = '';
        if ($_GET['TYPO3_INSTALL']['type']) {
            $allowedTypes = array('config', 'database', 'update', 'images', 'extConfig', 'cleanup', 'phpinfo', 'typo3conf_edit', 'about', 'logout');
            if (in_array($_GET['TYPO3_INSTALL']['type'], $allowedTypes)) {
                $this->INSTALL['type'] = $_GET['TYPO3_INSTALL']['type'];
            }
        }
        if ($this->step == 4) {
            $this->INSTALL['type'] = 'database';
        }
        // Hook to raise the counter for the total steps in the 1-2-3 installer
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'] as $classData) {
                $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
                $this->totalSteps += (int) $hookObject->executeAdditionalSteps($this);
            }
        }
        if ($this->mode == '123') {
            $tempItems = $this->menuitems;
            $this->menuitems = array('config' => $tempItems['config'], 'database' => $tempItems['database']);
            if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
                $this->INSTALL['type'] = 'config';
            }
        } else {
            if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
                $this->INSTALL['type'] = 'about';
            }
        }
        $this->action = $this->scriptSelf . '?TYPO3_INSTALL[type]=' . $this->INSTALL['type'] . ($this->mode ? '&mode=' . $this->mode : '') . ($this->step ? '&step=' . $this->step : '');
        $this->typo3temp_path = PATH_site . 'typo3temp/';
        if (!is_dir($this->typo3temp_path) || !is_writeable($this->typo3temp_path)) {
            $this->outputErrorAndExit('Install Tool needs to write to typo3temp/. Make sure this directory is writeable by your webserver: ' . htmlspecialchars($this->typo3temp_path), 'Fatal error');
        }
        try {
            $this->session = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_install_session');
        } catch (\Exception $exception) {
            $this->outputErrorAndExit($exception->getMessage());
        }
        // *******************
        // Check authorization
        // *******************
        if (!$this->session->hasSession()) {
            $this->session->startSession();
        }
        if ($this->session->isAuthorized() || $this->checkPassword()) {
            $this->passwordOK = 1;
            $this->session->refreshSession();
            $enableInstallToolFile = PATH_typo3conf . 'ENABLE_INSTALL_TOOL';
            if (is_file($enableInstallToolFile)) {
                // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
                @touch($enableInstallToolFile);
            }
            if ($this->redirect_url) {
                \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->redirect_url);
            }
            $this->formProtection = \t3lib_formProtection_Factory::get('TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection');
            $this->formProtection->injectInstallTool($this);
        } else {
            $this->loginForm();
        }
    }