]>
git.agnieray.net Git - galette.git/blob - galette/webroot/installer.php
a91aa37afa2d5b6f9f55b00e04f8bfe3f42e1702
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Main Galette initialisation
10 * Copyright © 2013-2014 The Galette Team
12 * This file is part of Galette (http://galette.eu).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette 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.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since Available since 0.8
37 use Galette\Core\Install
as GaletteInstall
;
38 use Galette\Core\Db
as GaletteDb
;
41 use Analog\Handler\LevelName
;
43 //set a flag saying we work from installer
44 //that way, in galette.inc.php, we'll only include relevant parts
46 define('GALETTE_ROOT', __DIR__
. '/../');
47 define('GALETTE_MODE', 'INSTALL');
50 require_once GALETTE_ROOT
. '/vendor/autoload.php';
51 require_once GALETTE_ROOT
. 'config/versions.inc.php';
53 if (version_compare(PHP_VERSION
, GALETTE_PHP_MIN
, '<') ||
!extension_loaded('intl')) {
54 header('location: compat_test.php');
58 //specific logfile for installer
59 $logfile = 'galette_install';
60 define('GALETTE_BASE_PATH', '../');
61 define('GALETTE_THEME_DIR', './themes/default/');
63 $needs_update = false;
64 require_once '../includes/galette.inc.php';
67 $session_name = 'galette_install_' . str_replace('.', '_', GALETTE_VERSION
);
68 $session = &$_SESSION['galette'][$session_name];
70 // don't display installer if not necessary
71 $install_in_progress = isset($session[md5(GALETTE_ROOT
)]);
72 $force_installer = defined('FORCE_INSTALLER') && FORCE_INSTALLER
;
73 if (!$install_in_progress && !$force_installer && $installed && !$needs_update) {
74 http_response_code(404);
78 $app = new \Galette\Core\
SlimApp();
79 require_once '../includes/dependencies.php';
81 if (isset($_POST['abort_btn'])) {
82 if (isset($session[md5(GALETTE_ROOT
)])) {
83 unset($session[md5(GALETTE_ROOT
)]);
85 header('location: ' . GALETTE_BASE_PATH
);
89 if (isset($session[md5(GALETTE_ROOT
)]) && !isset($_GET['raz'])) {
90 $install = unserialize($session[md5(GALETTE_ROOT
)]);
92 $install = new GaletteInstall();
95 $error_detected = array();
97 if ($install->isStepPassed(GaletteInstall
::STEP_TYPE
)) {
98 define('GALETTE_LOGGER_CHECKED', true);
100 $log_path = GALETTE_LOGS_PATH
. $logfile . '.log';
101 $galette_run_log = LevelName
::init(Handler\File
::init($log_path));
102 Analog
::handler($galette_run_log);
105 if (isset($_POST['stepback_btn'])) {
106 $install->atPreviousStep();
107 } elseif (isset($_POST['install_permsok']) && $_POST['install_permsok'] == 1) {
108 $install->atTypeStep();
109 } elseif (isset($_POST['install_type'])) {
110 $install->setMode($_POST['install_type']);
111 $install->atDbStep();
112 } elseif (isset($_POST['install_dbtype'])) {
113 $install->setDbType($_POST['install_dbtype'], $error_detected);
115 if (empty($_POST['install_dbhost'])) {
116 $error_detected[] = _T("No host");
118 if (empty($_POST['install_dbport'])) {
119 $error_detected[] = _T("No port");
121 if (empty($_POST['install_dbuser'])) {
122 $error_detected[] = _T("No user name");
124 if (empty($_POST['install_dbpass'])) {
125 $error_detected[] = _T("No password");
127 if (empty($_POST['install_dbname'])) {
128 $error_detected[] = _T("No database name");
131 if (count($error_detected) == 0) {
133 $_POST['install_dbhost'],
134 $_POST['install_dbport'],
135 $_POST['install_dbname'],
136 $_POST['install_dbuser'],
137 $_POST['install_dbpass']
139 $install->setTablesPrefix(
140 $_POST['install_dbprefix']
142 $install->atDbCheckStep();
144 } elseif (isset($_POST['install_dbperms_ok'])) {
145 if ($install->isInstall()) {
146 $install->atDbInstallStep();
147 } elseif ($install->isUpgrade()) {
148 $install->atVersionSelection();
150 } elseif (isset($_POST['previous_version'])) {
151 $install->setInstalledVersion($_POST['previous_version']);
152 $install->atDbUpgradeStep();
153 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isInstall()) {
154 $install->atAdminStep();
155 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isUpgrade()) {
156 $install->atGaletteInitStep();
157 } elseif (isset($_POST['install_adminlogin'])
158 && isset($_POST['install_adminpass'])
159 && $install->isInstall()
161 if ($_POST['install_adminlogin'] == '') {
162 $error_detected[] = _T("No user name");
164 if (strpos($_POST['install_adminlogin'], '@') != false) {
165 $error_detected[] = _T("The username cannot contain the @ character");
167 if ($_POST['install_adminpass'] == '') {
168 $error_detected[] = _T("No password");
170 if (!isset($_POST['install_passwdverified'])
172 $_POST['install_adminpass'],
173 $_POST['install_adminpass_verif']
176 $error_detected[] = _T("Passwords mismatch");
178 if (count($error_detected) == 0) {
179 $install->setAdminInfos(
180 $_POST['install_adminlogin'],
181 $_POST['install_adminpass']
183 $install->atGaletteInitStep();
185 } elseif (isset($_POST['install_prefs_ok'])) {
186 $install->atEndStep();
189 if (!$install->isEndStep()
190 && ($install->postCheckDb() ||
$install->isDbCheckStep())
192 //while before check db, connection is not checked
193 $zdb = new GaletteDb(array(
194 'TYPE_DB' => $install->getDbType(),
195 'HOST_DB' => $install->getDbHost(),
196 'PORT_DB' => $install->getDbPort(),
197 'USER_DB' => $install->getDbUser(),
198 'PWD_DB' => $install->getDbPass(),
199 'NAME_DB' => $install->getDbName()
203 header('Content-Type: text/html; charset=UTF-8');
206 <html lang
="<?php echo $i18n->getAbbrev(); ?>">
208 <title
><?php
echo _T("Galette Installation") . ' - ' . $install->getStepTitle(); ?
></title
>
209 <meta charset
="UTF-8"/>
210 <link rel
="stylesheet" type
="text/css" href
="./assets/css/galette-main.bundle.min.css" />
211 <link rel
="stylesheet" type
="text/css" href
="./themes/default/install.css"/>
212 <script type
="text/javascript" src
="./assets/js/galette-main.bundle.min.js"></script
>
213 <link rel
="shortcut icon" href
="./themes/default/images/favicon.png" />
219 <?php
echo _T("Galette installation") . ' - ' . $install->getStepTitle(); ?
>
221 <nav id
="plang_selector" class="onhover">
222 <a href
="#plang_selector" class="tooltip" aria
-expanded
="false" aria
-controls
="lang_selector" title
="<?php echo _T("Change language
"); ?>">
223 <i
class="fas fa-language"></i
>
224 <?php
echo $i18n->getName(); ?
>
226 <ul id
="lang_selector">
228 foreach ($i18n->getList() as $langue) {
230 <li
<?php
if ($i18n->getAbbrev() == $langue->getAbbrev()) { echo ' selected="selected"'; } ?
>>
231 <a href
="?ui_pref_lang=<?php echo $langue->getID(); ?>" lang
="<?php echo $langue->getAbbrev(); ?>"><?php
echo $langue->getName(); ?
></a
>
240 if (count($error_detected) > 0) {
243 <h1
><?php
echo _T("- ERROR -"); ?
></h1
>
246 foreach ($error_detected as $error) {
248 <li
><?php
echo $error; ?
></li
>
259 if ($install->isCheckStep()) {
260 include_once __DIR__
. '/../install/steps/check.php';
261 } elseif ($install->isTypeStep()) {
262 include_once __DIR__
. '/../install/steps/type.php';
263 } elseif ($install->isDbStep()) {
264 include_once __DIR__
. '/../install/steps/db.php';
265 } elseif ($install->isDbCheckStep()) {
266 include_once __DIR__
. '/../install/steps/db_checks.php';
267 } elseif ($install->isVersionSelectionStep()) {
268 include_once __DIR__
. '/../install/steps/db_select_version.php';
269 } elseif ($install->isDbinstallStep() ||
$install->isDbUpgradeStep()) {
270 include_once __DIR__
. '/../install/steps/db_install.php';
271 } elseif ($install->isAdminStep()) {
272 include_once __DIR__
. '/../install/steps/admin.php';
273 } elseif ($install->isGaletteInitStep()) {
274 include_once __DIR__
. '/../install/steps/galette.php';
275 } elseif ($install->isEndStep()) {
276 include_once __DIR__
. '/../install/steps/end.php';
281 <p
><?php
echo _T("Steps:"); ?
></p
>
283 <li
<?php
if ($install->isCheckStep()) echo ' class="current"'; ?
>><?php
echo _T("Checks"); ?
> - </li
>
284 <li
<?php
if ($install->isTypeStep()) echo ' class="current"'; ?
>><?php
echo _T("Installation mode"); ?
> - </li
>
285 <li
<?php
if ($install->isDbStep()) echo ' class="current"'; ?
>><?php
echo _T("Database"); ?
> - </li
>
286 <li
<?php
if ($install->isDbCheckStep()) echo ' class="current"'; ?
>><?php
echo _T("Database access/permissions"); ?
> - </li
>
288 if ($install->isUpgrade()) {
290 <li
<?php
if ($install->isVersionSelectionStep()) echo ' class="current"'; ?
>><?php
echo _T("Version selection"); ?
> - </li
>
291 <li
<?php
if ($install->isDbUpgradeStep()) echo ' class="current"'; ?
>><?php
echo _T("Database upgrade"); ?
> - </li
>
295 <li
<?php
if ($install->isDbinstallStep()) echo ' class="current"'; ?
>><?php
echo _T("Database installation"); ?
> - </li
>
299 if (!$install->isUpgrade()) {
301 <li
<?php
if ($install->isAdminStep()) echo ' class="current"'; ?
>><?php
echo _T("Admin parameters"); ?
> - </li
>
305 <li
<?php
if ($install->isGaletteInitStep()) echo ' class="current"'; ?
>><?php
echo _T("Galette initialisation"); ?
> - </li
>
306 <li
<?php
if ($install->isEndStep()) echo ' class="current"'; ?
>><?php
echo _T("End!"); ?
></li
>
310 <a id
="copyright" href
="http://galette.eu/">Galette
<?php
echo GALETTE_VERSION
; ?
></a
>
314 if (!$install->isEndStep()) {
315 $session[md5(GALETTE_ROOT
)] = serialize($install);
318 if (isset($profiler)) {