91f7f98b4c7ab89697004104b886d1021b0d98e2
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Start / Install.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the text file GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Entry point to the install tool and step installer.
30 *
31 * There are two main controllers: "step" and "tool".
32 * The step controller is always called first, and redirects to the tool controller
33 * if the basic core functionality is given (instance configuration exists, database
34 * connection works, ...)
35 * The tool controller is the main "install tool" with all the main functionality.
36 *
37 * The step controller handles the basic installation.
38 * During first installation it creates the basic file and folder structure, the
39 * configuration files, the database connection and a basic configuration. Those steps
40 * are cycled through and if some step returns TRUE on "needsExecution", an input
41 * form of this step is rendered.
42 * After initial installation, the step installer is still called if the install
43 * tool is accessed, so it will automatically come up if some basic configuration fails.
44 * If everything is ok, the step installer will redirect to the main install tool.
45 * The step installer also has some "silent" update scripts, for example it migrates
46 * a localconf.php to LocalConfiguration if needed.
47 *
48 * This ensures as soon as the tool controller is called, the basic configuration is ok.
49 *
50 * Whenever the bootstrap or other core elements figure the installation
51 * needs an update that is handled within the step controller, it should just
52 * redirect to the entry script and let the step controller do necessary work.
53 *
54 * The step installer initiates browser redirects if steps were executed. This simplifies
55 * internal logic by separating the different bootstrap states needed during installation
56 * from each other.
57 *
58 * There is also a backend module controller, that basically only shows a screen
59 * with the "enable install tool" button and then redirects to the entry script. Other
60 * than that, it does not interfere with step or tool controller and just sets a
61 * context GET parameter to indicate that the install tool is called within backend context.
62 *
63 * To coordinate different tasks within step and install controller and actions, several
64 * GET or POST parameters are used, all prefixed with "install".
65 * Parameters allowed as GET and POST are preserved during redirects, POST parameters are
66 * thrown away between redirects (HTTP status code 303).
67 *
68 * The following main GET and POST parameters are used:
69 * - GET/POST "install[context]" Preserved
70 * Either empty, 'standalone' or 'backend', fallback to 'standalone'. Set to 'backend'
71 * if install tool is called form the backend main module (BackendModuleController). This
72 * changes the view a bit and shows the doc header in the install tool, changes background
73 * color and such.
74 *
75 * - GET/POST "install[controller]" Preserved
76 * Either empty, 'step' or 'tool', fallback to 'step'. This coordinates whether the step
77 * or tool controller is called. This parameter is never set externally, so the step
78 * controller is always called first. It itself sets the type to 'tool' and redirects to
79 * the tool controller if needed.
80 * This means you could (but shouldn't) directly call the tool controller, but it
81 * will still require a login and session, then.
82 *
83 * - GET/POST "install[action]" Preserved
84 * Determine step and tool controller main action sanitized by step / tool controller and
85 * only executed if user is logged in. Form protection API relies on this.
86 *
87 * - GET/POST "install[redirectCount]"
88 * The install tool initiates redirects to itself if configuration parameters were changed.
89 * This may lead to infinite redirect loops under rare circumstances. This parameter is
90 * incremented for each redirect to break a loop after some iterations.
91 *
92 * - POST "install[set]"
93 * Contains keys to determine which sub-action of the action is requested,
94 * eg. "change install tool password" in "important actions". Set to 'execute' if some
95 * step should be executed.
96 *
97 * - POST "install[values]"
98 * Data values for a specific "install[set]" action
99 *
100 * - POST "install[token]"
101 * A session and instance specific token created from the instance specific
102 * encryptionKey (taken care of in an early point in the step controller). This hash
103 * is used as form protection against CSRF for all POST data. Both the step and tool
104 * controller will logout a user if the token check fails. The only exception to this
105 * handling is the very first installation step where no session and no encryption key
106 * can exist yet.
107 */
108
109 define('TYPO3_MODE', 'BE');
110 define('TYPO3_enterInstallScript', '1');
111
112 // Bootstrap bare minimum: class loader, LocalConfiguration, but no extensions and such
113 require __DIR__ . '/../../core/Classes/Core/Bootstrap.php';
114 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
115 ->baseSetup('typo3/sysext/install/Start/')
116 ->startOutputBuffering()
117 ->loadConfigurationAndInitialize(FALSE, 'TYPO3\\CMS\\Core\\Package\\FailsafePackageManager');
118
119 // Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
120 $getPost = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('install');
121 $controllerClassName = 'TYPO3\\CMS\\Install\\Controller\\StepController';
122 if (isset($getPost['controller'])) {
123 switch ($getPost['controller']) {
124 case 'tool':
125 $controllerClassName = 'TYPO3\\CMS\\Install\\Controller\\ToolController';
126 break;
127 case 'ajax':
128 $controllerClassName = 'TYPO3\\CMS\\Install\\Controller\\AjaxController';
129 break;
130 }
131 }
132 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($controllerClassName)->execute();