Ejemplo n.º 1
0
    /**
     * Calling function that checks system, IM, GD, dirs, database
     * and lets you alter localconf.php
     *
     * This method is called from init.php to start the Install Tool.
     *
     * @return void
     * @todo Define visibility
     */
    public function init()
    {
        // Must be called after inclusion of init.php (or from init.php)
        if (!defined('PATH_typo3')) {
            die;
        }
        if (!$this->passwordOK) {
            die;
        }
        // Setting stuff...
        $this->check_mail();
        $this->setupGeneral();
        $this->generateConfigForm();
        if (count($this->messages)) {
            \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->messages);
        }
        if ($this->step) {
            $this->output($this->outputWrapper($this->stepOutput()));
        } else {
            // Menu...
            switch ($this->INSTALL['type']) {
                case 'images':
                    $this->checkIM = 1;
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheImageProcessing();
                    break;
                case 'database':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheDatabase();
                    break;
                case 'update':
                    $this->checkDatabase();
                    $this->silent = 0;
                    $this->updateWizard();
                    break;
                case 'config':
                    $this->silent = 0;
                    $this->checkIM = 1;
                    $this->message('About configuration', 'How to configure TYPO3', $this->generallyAboutConfiguration());
                    $isPhpCgi = PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi';
                    $this->message('System Information', 'Your system has the following configuration', '
							<dl id="systemInformation">
								<dt>OS detected:</dt>
								<dd>' . (TYPO3_OS == 'WIN' ? 'WIN' : 'UNIX') . '</dd>
								<dt>CGI detected:</dt>
								<dd>' . ($isPhpCgi ? 'YES' : 'NO') . '</dd>
								<dt>PATH_thisScript:</dt>
								<dd>' . PATH_thisScript . '</dd>
							</dl>
						');
                    $this->checkTheConfig();
                    $ext = 'Write configuration';
                    if ($this->fatalError) {
                        if ($this->config_array['no_database'] || !$this->config_array['mysqlConnect']) {
                            $this->message($ext, 'Database not configured yet!', '
								<p>
									You need to specify database username,
									password and host as one of the first things.
									<br />
									Next you\'ll have to select a database to
									use with TYPO3.
								</p>
								<p>
									Use the form below.
								</p>
							', 2);
                        } else {
                            $this->message($ext, 'Fatal error encountered!', '
								<p>
									Somewhere above a fatal configuration
									problem is encountered.
									Please make sure that you\'ve fixed this
									error before you submit the configuration.
									TYPO3 will not run if this problem is not
									fixed!
									<br />
									You should also check all warnings that may
									appear.
								</p>
							', 2);
                        }
                    } elseif ($this->mode == '123') {
                        if (!$this->fatalError) {
                            $this->message($ext, 'Basic configuration completed', '
								<p>
									You have no fatal errors in your basic
									configuration.
									You may have warnings though. Please pay
									attention to them!
									However you may continue and install the
									database.
								</p>
								<p>
									<strong>
										<span style="color:#f00;">Step 2: </span>
									</strong>
									<a href="' . $this->scriptSelf . '?TYPO3_INSTALL[type]=database' . ($this->mode ? '&mode=' . rawurlencode($this->mode) : '') . '">Click here to install the database.</a>
								</p>
							', -1, 1);
                        }
                    }
                    $this->message($ext, 'Very Important: Changing Image Processing settings', '
						<p>
							When you change the settings for Image Processing
							you <em>must</em> take into account
							that <em>old images</em> may still be in typo3temp/
							folder and prevent new files from being generated!
							<br />
							This is especially important to know, if you\'re
							trying to set up image processing for the very first
							time.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Very Important: Changing Encryption Key setting', '
						<p>
							When you change the setting for the Encryption Key
							you <em>must</em> take into account that a change to
							this value might invalidate temporary information,
							URLs etc.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Update configuration', '
						<p>
							This form updates the configuration with the
							suggested values you see below. The values are based
							on the analysis above.
							<br />
							You can change the values in case you have
							alternatives to the suggested defaults.
							<br />
							By this final step you will configure TYPO3 for
							immediate use provided that you have no fatal errors
							left above.
						</p>' . $this->setupGeneral('get_form') . '
					', 0, 1);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
                case 'extConfig':
                    $this->silent = 0;
                    $this->generateConfigForm('get_form');
                    // Get the template file
                    $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'InitExtConfig.html');
                    // Get the template part from the file
                    $template = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
                    // Define the markers content
                    $markers = array('action' => $this->action, 'content' => $this->printAll(), 'write' => 'Write configuration', 'notice' => 'NOTICE:', 'explanation' => '
							By clicking this button, the configuration is updated
							with new values for the parameters listed above!
						');
                    // Fill the markers in the template
                    $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', TRUE, FALSE);
                    // Send content to the page wrapper function
                    $this->output($this->outputWrapper($content));
                    break;
                case 'cleanup':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->cleanupManager();
                    break;
                case 'phpinfo':
                    $this->silent = 0;
                    $this->phpinformation();
                    break;
                case 'typo3conf_edit':
                    $this->silent = 0;
                    $this->typo3conf_edit();
                    break;
                case 'logout':
                    $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
                    if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
                        unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                    }
                    $this->formProtection->clean();
                    $this->session->destroySession();
                    \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->scriptSelf);
                    break;
                case 'about':
                default:
                    $this->silent = 0;
                    $this->message('About', 'Warning - very important!', $this->securityRisk() . $this->alterPasswordForm(), 2);
                    $this->message('About', 'Using this script', '
						<p>
							Installing TYPO3 has always been a hot topic on the
							mailing list and forums. Therefore we\'ve developed
							this tool which will help you through configuration
							and testing.
							<br />
							There are three primary steps for you to take:
						</p>
						<p>
							<strong>1: Basic Configuration</strong>
							<br />
							In this step your PHP-configuration is checked. If
							there are any settings that will prevent TYPO3 from
							running correctly you\'ll get warnings and errors
							with a description of the problem.
							<br />
							You\'ll have to enter a database username, password
							and hostname. Then you can choose to create a new
							database or select an existing one.
							<br />
							Finally the image processing settings are entered
							and verified and you can choose to let the script
							update the configuration with the suggested settings.
						</p>
						<p>
							<strong>2: Database Analyser</strong>
							<br />
							In this step you can either install a new database
							or update the database from any previous TYPO3
							version.
							<br />
							You can also get an overview of extra/missing
							fields/tables in the database compared to a raw
							sql-file.
							<br />
							The database is also verified against your
							\'tables.php\' configuration ($TCA) and you can
							even see suggestions to entries in $TCA or new
							fields in the database.
						</p>
						<p>
							<strong>3: Upgrade Wizard</strong>
							<br />
							Here you will find update methods taking care of
							changes to the TYPO3 core which are not backwards
							compatible.
							<br />
							It is recommended to run this wizard after every
							update to make sure everything will still work
							flawlessly.
						</p>
						<p>
							<strong>4: Image Processing</strong>
							<br />
							This step is a visual guide to verify your
							configuration of the image processing software.
							<br />
							You\'ll be presented to a list of images that should
							all match in pairs. If some irregularity appears,
							you\'ll get a warning. Thus you\'re able to track an
							error before you\'ll discover it on your website.
						</p>
						<p>
							<strong>5: All Configuration</strong>
							<br />
							This gives you access to any of the configuration
							options in the TYPO3_CONF_VARS array. Every option
							is also presented with a comment explaining what it
							does.
						</p>
						<p>
							<strong>6: Cleanup</strong>
							<br />
							Here you can clean up the temporary files in typo3temp/
							folder and the tables used for caching of data in
							your database.
						</p>
					');
                    $this->message('About', 'Why is this script stand-alone?', '
						<p>
							You would think that this script should rather be a
							module in the backend and access-controlled to only
							admin-users from the database. But that\'s not how
							it works.
							<br />
							The reason is, that this script must not be
							depending on the success of the configuration of
							TYPO3 and whether or not there is a working database
							behind. Therefore the script is invoked from the
							backend init.php file, which allows access if the
							constant \'TYPO3_enterInstallScript\' has been
							defined and is not FALSE. That is and should be the
							case <em>only</em> when calling the script
							\'typo3/install/index.php\' - this script!
						</p>
					');
                    $headCode = 'Header legend';
                    $this->message($headCode, 'Notice!', '
						<p>
							Indicates that something is important to be aware
							of.
							<br />
							This does <em>not</em> indicate an error.
						</p>
					', 1);
                    $this->message($headCode, 'Just information', '
						<p>
							This is a simple message with some information about
							something.
						</p>
					');
                    $this->message($headCode, 'Check was successful', '
						<p>
							Indicates that something was checked and returned an
							expected result.
						</p>
					', -1);
                    $this->message($headCode, 'Warning!', '
						<p>
							Indicates that something may very well cause trouble
							and you should definitely look into it before
							proceeding.
							<br />
							This indicates a <em>potential</em> error.
						</p>
					', 2);
                    $this->message($headCode, 'Error!', '
						<p>
							Indicates that something is definitely wrong and
							that TYPO3 will most likely not perform as expected
							if this problem is not solved.
							<br />
							This indicates an actual error.
						</p>
					', 3);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
            }
        }
    }