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