]>
git.agnieray.net Git - galette.git/blob - galette/webroot/installer.php
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
;
42 use Galette\Core\Plugins
;
43 use Galette\Core\Preferences
;
44 use Galette\Util\Telemetry
;
46 //set a flag saying we work from installer
47 //that way, in galette.inc.php, we'll only include relevant parts
49 define('GALETTE_ROOT', __DIR__
. '/../');
50 define('GALETTE_MODE', 'INSTALL');
53 require_once GALETTE_ROOT
. '/vendor/autoload.php';
54 require_once GALETTE_ROOT
. 'config/versions.inc.php';
56 if (version_compare(PHP_VERSION
, GALETTE_PHP_MIN
, '<') ||
!extension_loaded('intl')) {
57 header('location: compat_test.php');
61 //specific logfile for installer
62 $logfile = 'galette_install';
63 define('GALETTE_BASE_PATH', '../');
65 require_once '../includes/galette.inc.php';
68 $session_name = 'galette_install_' . str_replace('.', '_', GALETTE_VERSION
);
69 $session = &$_SESSION['galette'][$session_name];
71 $gapp = new \Galette\Core\
SlimApp();
72 $app = $gapp->getApp();
73 require_once '../includes/dependencies.php';
75 if (isset($_POST['abort_btn'])) {
76 if (isset($session[md5(GALETTE_ROOT
)])) {
77 unset($session[md5(GALETTE_ROOT
)]);
79 header('location: ' . GALETTE_BASE_PATH
);
83 if (isset($session[md5(GALETTE_ROOT
)]) && !isset($_GET['raz'])) {
84 $install = unserialize($session[md5(GALETTE_ROOT
)]);
86 $install = new GaletteInstall();
89 $error_detected = array();
92 * Initialize database constants to connect
94 * @param Install $install Installer
98 function initDbConstants($install)
100 define('TYPE_DB', $install->getDbType());
101 define('PREFIX_DB', $install->getTablesPrefix());
102 define('USER_DB', $install->getDbUser());
103 define('PWD_DB', $install->getDbPass());
104 define('HOST_DB', $install->getDbHost());
105 define('PORT_DB', $install->getDbPort());
106 define('NAME_DB', $install->getDbName());
109 if ($install->isStepPassed(GaletteInstall
::STEP_TYPE
)) {
110 define('GALETTE_LOGGER_CHECKED', true);
112 $log_path = GALETTE_LOGS_PATH
. $logfile . '.log';
113 $galette_run_log = LevelName
::init(Handler\File
::init($log_path));
114 Analog
::handler($galette_run_log);
117 if (!$install->isEndStep()
118 && ($install->postCheckDb())
120 //if we have passed database configuration, define required constants
121 initDbConstants($install);
123 if ($install->postCheckDb()) {
125 $zdb = new GaletteDb();
126 } catch (Throwable
$e) {
127 if (!$install->isDbCheckStep()) {
135 if (isset($_POST['stepback_btn'])) {
136 $install->atPreviousStep();
137 } elseif (isset($_POST['install_permsok']) && $_POST['install_permsok'] == 1) {
138 $install->atTypeStep();
139 } elseif (isset($_POST['install_type'])) {
140 $install->setMode($_POST['install_type']);
141 $install->atDbStep();
142 } elseif (isset($_POST['install_dbtype'])) {
143 $install->setDbType($_POST['install_dbtype'], $error_detected);
145 if (empty($_POST['install_dbhost'])) {
146 $error_detected[] = _T("No host");
148 if (empty($_POST['install_dbport'])) {
149 $error_detected[] = _T("No port");
151 if (empty($_POST['install_dbuser'])) {
152 $error_detected[] = _T("No user name");
154 if (empty($_POST['install_dbpass'])) {
155 $error_detected[] = _T("No password");
157 if (empty($_POST['install_dbname'])) {
158 $error_detected[] = _T("No database name");
161 if (count($error_detected) == 0) {
163 $_POST['install_dbhost'],
164 $_POST['install_dbport'],
165 $_POST['install_dbname'],
166 $_POST['install_dbuser'],
167 $_POST['install_dbpass']
169 $install->setTablesPrefix(
170 $_POST['install_dbprefix']
172 $install->atDbCheckStep();
173 initDbConstants($install);
175 } elseif (isset($_POST['install_dbperms_ok'])) {
176 if ($install->isInstall()) {
177 $install->atDbInstallStep();
178 } elseif ($install->isUpgrade()) {
179 $install->atVersionSelection();
181 } elseif (isset($_POST['previous_version'])) {
182 $install->setInstalledVersion($_POST['previous_version']);
183 $install->atDbUpgradeStep();
184 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isInstall()) {
185 $install->atAdminStep();
186 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isUpgrade()) {
187 $install->atTelemetryStep();
188 } elseif (isset($_POST['install_adminlogin'])
189 && isset($_POST['install_adminpass'])
190 && $install->isInstall()
192 if ($_POST['install_adminlogin'] == '') {
193 $error_detected[] = _T("No user name");
195 if (strpos($_POST['install_adminlogin'], '@')) {
196 $error_detected[] = _T("The username cannot contain the @ character");
198 if ($_POST['install_adminpass'] == '') {
199 $error_detected[] = _T("No password");
201 if (!isset($_POST['install_passwdverified'])
203 $_POST['install_adminpass'],
204 $_POST['install_adminpass_verif']
207 $error_detected[] = _T("Passwords mismatch");
209 if (count($error_detected) == 0) {
210 $install->setAdminInfos(
211 $_POST['install_adminlogin'],
212 $_POST['install_adminpass']
214 $install->atTelemetryStep();
216 } elseif (isset($_POST['install_telemetry_ok'])) {
217 if (isset($_POST['send_telemetry'])) {
218 $preferences = new Preferences($zdb);
219 $plugins = new Plugins();
220 $telemetry = new Telemetry(
227 } catch (Throwable
$e) {
228 Analog
::log($e->getMessage(), Analog
::ERROR
);
231 $install->atGaletteInitStep();
232 } elseif (isset($_POST['install_prefs_ok'])) {
233 $install->atEndStep();
236 header('Content-Type: text/html; charset=UTF-8');
239 <html lang
="<?php echo $i18n->getAbbrev(); ?>">
241 <title
><?php
echo _T("Galette Installation") . ' - ' . $install->getStepTitle(); ?
></title
>
242 <meta charset
="UTF-8"/>
243 <meta name
="viewport" content
="width=device-width" />
244 <link rel
="stylesheet" type
="text/css" href
="./themes/default/ui/semantic.min.css" />
245 <link rel
="shortcut icon" href
="./themes/default/images/favicon.png" />
246 <script type
="text/javascript" src
="./assets/js/jquery.min.js"></script
>
248 <body
class="pushable">
249 <header id
="top-navbar" class="ui fixed menu bgcolor">
250 <div
class="ui wide container">
251 <div
class="header item">
252 <span
><?php
echo _T("Galette installation") ?
></span
>
254 <div
class="language ui dropdown right item">
255 <i
class="icon language" aria
-hidden
="true"></i
>
256 <span
><?php
echo $i18n->getAbbrev(); ?
></span
>
257 <i
class="icon dropdown" aria
-hidden
="true"></i
>
260 foreach ($i18n->getList() as $langue) {
262 <a href
="?ui_pref_lang=<?php echo $langue->getID(); ?>" lang
="<?php echo $langue->getAbbrev(); ?>" class="item"><?php
echo $langue->getName(); ?
> <span
>(<?php
echo $langue->getAbbrev(); ?
>)</span
></a
>
271 <div id
="main" class="ui wide container">
272 <div
class="ui basic segment">
273 <div
class="ui basic center aligned fitted segment">
274 <img
class="icon" alt
="[ Galette ]" src
="./themes/default/images/galette.png"/>
276 <h1
class="ui block center aligned header">
277 <?php
echo $install->getStepTitle(); ?
>
280 if (count($error_detected) > 0) {
282 <div id
="errorbox" class="ui red message">
283 <h1
><?php
echo _T("- ERROR -"); ?
></h1
>
286 foreach ($error_detected as $error) {
288 <li
><?php
echo $error; ?
></li
>
297 <div
class="ui mobile reversed stackable two column grid">
298 <div
class="four wide column">
299 <div
class="ui stackable mini vertical steps fluid">
300 <div
class="step<?php if ($install->isCheckStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_CHECK)) echo ' disabled'; ?>">
301 <i
class="tasks icon<?php if($install->isStepPassed(GaletteInstall::STEP_CHECK)) { echo ' green'; } ?>"></i
>
302 <div
class="content">
303 <div
class="title"><?php
echo _T("Checks"); ?
></div
>
306 <div
class="step<?php if ($install->isTypeStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_TYPE)) echo ' disabled'; ?>">
307 <i
class="question icon<?php if($install->isStepPassed(GaletteInstall::STEP_TYPE)) { echo ' green'; } ?>"></i
>
308 <div
class="content">
309 <div
class="title"><?php
echo _T("Installation mode"); ?
></div
>
312 <div
class="step<?php if ($install->isDbStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_DB)) echo ' disabled'; ?>">
313 <i
class="database icon<?php if($install->isStepPassed(GaletteInstall::STEP_DB)) { echo ' green'; } ?>"></i
>
314 <div
class="content">
315 <div
class="title"><?php
echo _T("Database"); ?
></div
>
318 <div
class="step<?php if ($install->isDbCheckStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_DB_CHECKS)) echo ' disabled'; ?>">
319 <i
class="key icon<?php if($install->isStepPassed(GaletteInstall::STEP_DB_CHECKS)) { echo ' green'; } ?>"></i
>
320 <div
class="content">
321 <div
class="title"><?php
echo _T("Database access and permissions"); ?
></div
>
325 if ($install->isUpgrade()) {
327 <div
class="step<?php if ($install->isVersionSelectionStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_VERSION)) echo ' disabled'; ?>">
328 <i
class="tag icon<?php if($install->isStepPassed(GaletteInstall::STEP_VERSION)) { echo ' green'; } ?>"></i
>
329 <div
class="content">
330 <div
class="title"><?php
echo _T("Version selection"); ?
></div
>
333 <div
class="step<?php if ($install->isDbUpgradeStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_DB_UPGRADE)) echo ' disabled'; ?>">
334 <i
class="sync alt icon<?php if($install->isStepPassed(GaletteInstall::STEP_DB_UPGRADE)) { echo ' green'; } ?>"></i
>
335 <div
class="content">
336 <div
class="title"><?php
echo _T("Database upgrade"); ?
></div
>
342 <div
class="step<?php if ($install->isDbinstallStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_DB_INSTALL)) echo ' disabled'; ?>">
343 <i
class="spinner icon<?php if($install->isStepPassed(GaletteInstall::STEP_DB_INSTALL)) { echo ' green'; } ?>"></i
>
344 <div
class="content">
345 <div
class="title"><?php
echo _T("Database installation"); ?
></div
>
351 if (!$install->isUpgrade()) {
353 <div
class="step<?php if ($install->isAdminStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_ADMIN)) echo ' disabled'; ?>">
354 <i
class="user icon<?php if($install->isStepPassed(GaletteInstall::STEP_ADMIN)) { echo ' green'; } ?>"></i
>
355 <div
class="content">
356 <div
class="title"><?php
echo _T("Admin parameters"); ?
></div
>
362 <div
class="step<?php if ($install->isTelemetryStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_TELEMETRY)) echo ' disabled'; ?>">
363 <i
class="chart bar icon<?php if($install->isStepPassed(GaletteInstall::STEP_TELEMETRY)) { echo ' green'; } ?>"></i
>
364 <div
class="content">
365 <div
class="title"><?php
echo _T("Telemetry"); ?
></div
>
368 <div
class="step<?php if ($install->isGaletteInitStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_GALETTE_INIT)) echo ' disabled'; ?>">
369 <i
class="cogs icon<?php if($install->isStepPassed(GaletteInstall::STEP_GALETTE_INIT)) { echo ' green'; } ?>"></i
>
370 <div
class="content">
371 <div
class="title"><?php
echo _T("Galette initialisation"); ?
></div
>
374 <div
class="step<?php if ($install->isEndStep()) echo ' active'; elseif (!$install->isStepPassed(GaletteInstall::STEP_END)) echo ' disabled'; ?>">
375 <i
class="flag checkered icon<?php if($install->isStepPassed(GaletteInstall::STEP_END)) { echo ' green'; } ?>"></i
>
376 <div
class="content">
377 <div
class="title"><?php
echo _T("End!"); ?
></div
>
382 <div
class="twelve wide column">
384 if ($install->isCheckStep()) {
385 include_once __DIR__
. '/../install/steps/check.php';
386 } elseif ($install->isTypeStep()) {
387 include_once __DIR__
. '/../install/steps/type.php';
388 } elseif ($install->isDbStep()) {
389 include_once __DIR__
. '/../install/steps/db.php';
390 } elseif ($install->isDbCheckStep()) {
391 include_once __DIR__
. '/../install/steps/db_checks.php';
392 } elseif ($install->isVersionSelectionStep()) {
393 include_once __DIR__
. '/../install/steps/db_select_version.php';
394 } elseif ($install->isDbinstallStep() ||
$install->isDbUpgradeStep()) {
395 include_once __DIR__
. '/../install/steps/db_install.php';
396 } elseif ($install->isAdminStep()) {
397 include_once __DIR__
. '/../install/steps/admin.php';
398 } elseif ($install->isTelemetryStep()) {
399 include_once __DIR__
. '/../install/steps/telemetry.php';
400 } elseif ($install->isGaletteInitStep()) {
401 include_once __DIR__
. '/../install/steps/galette.php';
402 } elseif ($install->isEndStep()) {
403 include_once __DIR__
. '/../install/steps/end.php';
409 <footer
class="ui basic center aligned segment">
411 <nav
class="ui horizontal bulleted link list">
412 <a href
="https://galette.eu" class="item">
413 <i
class="icon globe europe"></i
>
414 <?php
echo _T("Website"); ?
>
416 <a href
="https://doc.galette.eu" class="item">
417 <i
class="icon book"></i
>
418 <?php
echo _T("Documentation"); ?
>
420 <a href
="https://framapiaf.org/@galette" class="item">
421 <i
class="icon mastodon"></i
>
427 <nav
class="ui horizontal bulleted link list">
428 <a id
="copyright" href
="https://galette.eu/" class="item">
429 <i
class="icon cookie bite"></i
>
430 Galette
<?php
echo GALETTE_DISPLAY_VERSION
; ?
>
437 <script type
="text/javascript" src
="./assets/js/galette-main.bundle.min.js"></script
>
438 <script type
="text/javascript" src
="./themes/default/ui/semantic.min.js"></script
>
442 if (!$install->isEndStep()) {
443 $session[md5(GALETTE_ROOT
)] = serialize($install);
446 if (isset($profiler)) {