]>
git.agnieray.net Git - galette.git/blob - galette/webroot/installer.php
3c08a77212a116af8be2f74ba71cb151acc32740
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', '../');
62 require_once '../includes/galette.inc.php';
65 $session_name = 'galette_install_' . str_replace('.', '_', GALETTE_VERSION
);
66 $session = &$_SESSION['galette'][$session_name];
68 $gapp = new \Galette\Core\
SlimApp();
69 $app = $gapp->getApp();
70 require_once '../includes/dependencies.php';
72 if (isset($_POST['abort_btn'])) {
73 if (isset($session[md5(GALETTE_ROOT
)])) {
74 unset($session[md5(GALETTE_ROOT
)]);
76 header('location: ' . GALETTE_BASE_PATH
);
80 if (isset($session[md5(GALETTE_ROOT
)]) && !isset($_GET['raz'])) {
81 $install = unserialize($session[md5(GALETTE_ROOT
)]);
83 $install = new GaletteInstall();
86 $error_detected = array();
89 * Initialize database constants to connect
91 * @param Install $install Installer
95 function initDbConstants($install)
97 define('TYPE_DB', $install->getDbType());
98 define('PREFIX_DB', $install->getTablesPrefix());
99 define('USER_DB', $install->getDbUser());
100 define('PWD_DB', $install->getDbPass());
101 define('HOST_DB', $install->getDbHost());
102 define('PORT_DB', $install->getDbPort());
103 define('NAME_DB', $install->getDbName());
106 if ($install->isStepPassed(GaletteInstall
::STEP_TYPE
)) {
107 define('GALETTE_LOGGER_CHECKED', true);
109 $log_path = GALETTE_LOGS_PATH
. $logfile . '.log';
110 $galette_run_log = LevelName
::init(Handler\File
::init($log_path));
111 Analog
::handler($galette_run_log);
114 if (isset($_POST['stepback_btn'])) {
115 $install->atPreviousStep();
116 } elseif (isset($_POST['install_permsok']) && $_POST['install_permsok'] == 1) {
117 $install->atTypeStep();
118 } elseif (isset($_POST['install_type'])) {
119 $install->setMode($_POST['install_type']);
120 $install->atDbStep();
121 } elseif (isset($_POST['install_dbtype'])) {
122 $install->setDbType($_POST['install_dbtype'], $error_detected);
124 if (empty($_POST['install_dbhost'])) {
125 $error_detected[] = _T("No host");
127 if (empty($_POST['install_dbport'])) {
128 $error_detected[] = _T("No port");
130 if (empty($_POST['install_dbuser'])) {
131 $error_detected[] = _T("No user name");
133 if (empty($_POST['install_dbpass'])) {
134 $error_detected[] = _T("No password");
136 if (empty($_POST['install_dbname'])) {
137 $error_detected[] = _T("No database name");
140 if (count($error_detected) == 0) {
142 $_POST['install_dbhost'],
143 $_POST['install_dbport'],
144 $_POST['install_dbname'],
145 $_POST['install_dbuser'],
146 $_POST['install_dbpass']
148 $install->setTablesPrefix(
149 $_POST['install_dbprefix']
151 $install->atDbCheckStep();
153 } elseif (isset($_POST['install_dbperms_ok'])) {
154 if ($install->isInstall()) {
155 $install->atDbInstallStep();
156 } elseif ($install->isUpgrade()) {
157 $install->atVersionSelection();
159 } elseif (isset($_POST['previous_version'])) {
160 $install->setInstalledVersion($_POST['previous_version']);
161 $install->atDbUpgradeStep();
162 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isInstall()) {
163 $install->atAdminStep();
164 } elseif (isset($_POST['install_dbwrite_ok']) && $install->isUpgrade()) {
165 $install->atGaletteInitStep();
166 } elseif (isset($_POST['install_adminlogin'])
167 && isset($_POST['install_adminpass'])
168 && $install->isInstall()
170 if ($_POST['install_adminlogin'] == '') {
171 $error_detected[] = _T("No user name");
173 if (strpos($_POST['install_adminlogin'], '@') != false) {
174 $error_detected[] = _T("The username cannot contain the @ character");
176 if ($_POST['install_adminpass'] == '') {
177 $error_detected[] = _T("No password");
179 if (!isset($_POST['install_passwdverified'])
181 $_POST['install_adminpass'],
182 $_POST['install_adminpass_verif']
185 $error_detected[] = _T("Passwords mismatch");
187 if (count($error_detected) == 0) {
188 $install->setAdminInfos(
189 $_POST['install_adminlogin'],
190 $_POST['install_adminpass']
192 $install->atGaletteInitStep();
194 } elseif (isset($_POST['install_prefs_ok'])) {
195 $install->atEndStep();
198 if (!$install->isEndStep()
199 && ($install->postCheckDb() ||
$install->isDbCheckStep())
201 //if we have passed database configuration, define required constants
202 initDbConstants($install);
204 if ($install->postCheckDb()) {
205 //while before check db, connection is not checked
206 $zdb = new GaletteDb();
210 header('Content-Type: text/html; charset=UTF-8');
213 <html lang
="<?php echo $i18n->getAbbrev(); ?>">
215 <title
><?php
echo _T("Galette Installation") . ' - ' . $install->getStepTitle(); ?
></title
>
216 <meta charset
="UTF-8"/>
217 <meta name
="viewport" content
="width=device-width" />
218 <link rel
="stylesheet" type
="text/css" href
="./themes/default/ui/semantic.min.css" />
219 <link rel
="shortcut icon" href
="./themes/default/images/favicon.png" />
220 <script type
="text/javascript" src
="./assets/js/jquery.min.js"></script
>
222 <body
class="pushable">
223 <header id
="top-navbar" class="ui fixed menu bgcolor">
224 <div
class="ui container">
225 <div
class="header item">
226 <span
><?php
echo _T("Galette installation") ?
></span
>
228 <div
class="language ui dropdown right item">
229 <i
class="icon language" aria
-hidden
="true"></i
>
230 <span
><?php
echo $i18n->getAbbrev(); ?
></span
>
231 <i
class="icon dropdown" aria
-hidden
="true"></i
>
234 foreach ($i18n->getList() as $langue) {
236 <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
>
245 <div id
="main" class="ui container">
246 <div
class="ui basic segment">
247 <div
class="ui basic center aligned fitted segment">
248 <img
class="icon" alt
="[ Galette ]" src
="./themes/default/images/galette.png"/>
250 <h1
class="ui block center aligned header">
251 <?php
echo $install->getStepTitle(); ?
>
254 if (count($error_detected) > 0) {
256 <div id
="errorbox" class="ui red message">
257 <h1
><?php
echo _T("- ERROR -"); ?
></h1
>
260 foreach ($error_detected as $error) {
262 <li
><?php
echo $error; ?
></li
>
272 if ($install->isCheckStep()) {
273 include_once __DIR__
. '/../install/steps/check.php';
274 } elseif ($install->isTypeStep()) {
275 include_once __DIR__
. '/../install/steps/type.php';
276 } elseif ($install->isDbStep()) {
277 include_once __DIR__
. '/../install/steps/db.php';
278 } elseif ($install->isDbCheckStep()) {
279 include_once __DIR__
. '/../install/steps/db_checks.php';
280 } elseif ($install->isVersionSelectionStep()) {
281 include_once __DIR__
. '/../install/steps/db_select_version.php';
282 } elseif ($install->isDbinstallStep() ||
$install->isDbUpgradeStep()) {
283 include_once __DIR__
. '/../install/steps/db_install.php';
284 } elseif ($install->isAdminStep()) {
285 include_once __DIR__
. '/../install/steps/admin.php';
286 } elseif ($install->isGaletteInitStep()) {
287 include_once __DIR__
. '/../install/steps/galette.php';
288 } elseif ($install->isEndStep()) {
289 include_once __DIR__
. '/../install/steps/end.php';
292 <div
class="ui tablet stackable mini eight steps">
293 <div
class="step<?php if ($install->isCheckStep()) echo ' active'; ?>">
294 <i
class="tasks icon"></i
>
295 <div
class="content">
296 <div
class="title"><?php
echo _T("Checks"); ?
></div
>
299 <div
class="step<?php if ($install->isTypeStep()) echo ' active'; ?>">
300 <i
class="question icon"></i
>
301 <div
class="content">
302 <div
class="title"><?php
echo _T("Installation mode"); ?
></div
>
305 <div
class="step<?php if ($install->isDbStep()) echo ' active'; ?>">
306 <i
class="database icon"></i
>
307 <div
class="content">
308 <div
class="title"><?php
echo _T("Database"); ?
></div
>
311 <div
class="step<?php if ($install->isDbCheckStep()) echo ' active'; ?>">
312 <i
class="key icon"></i
>
313 <div
class="content">
314 <div
class="title"><?php
echo _T("Database access/permissions"); ?
></div
>
318 if ($install->isUpgrade()) {
320 <div
class="step<?php if ($install->isVersionSelectionStep()) echo ' active'; ?>">
321 <i
class="tag icon"></i
>
322 <div
class="content">
323 <div
class="title"><?php
echo _T("Version selection"); ?
></div
>
326 <div
class="step<?php if ($install->isDbUpgradeStep()) echo ' active'; ?>">
327 <i
class="sync alt icon"></i
>
328 <div
class="content">
329 <div
class="title"><?php
echo _T("Database upgrade"); ?
></div
>
335 <div
class="step<?php if ($install->isDbinstallStep()) echo ' active'; ?>">
336 <i
class="spinner icon"></i
>
337 <div
class="content">
338 <div
class="title"><?php
echo _T("Database installation"); ?
></div
>
344 if (!$install->isUpgrade()) {
346 <div
class="step<?php if ($install->isAdminStep()) echo ' active'; ?>">
347 <i
class="user icon"></i
>
348 <div
class="content">
349 <div
class="title"><?php
echo _T("Admin parameters"); ?
></div
>
355 <div
class="step<?php if ($install->isGaletteInitStep()) echo ' active'; ?>">
356 <i
class="cogs icon"></i
>
357 <div
class="content">
358 <div
class="title"><?php
echo _T("Galette initialisation"); ?
></div
>
361 <div
class="step<?php if ($install->isEndStep()) echo ' active'; ?>">
362 <i
class="flag checkered icon"></i
>
363 <div
class="content">
364 <div
class="title"><?php
echo _T("End!"); ?
></div
>
369 <footer
class="ui basic center aligned segment">
371 <nav
class="ui horizontal bulleted link list">
372 <a href
="https://galette.eu" class="item">
373 <i
class="icon globe europe"></i
>
374 <?php
echo _T("Website"); ?
>
376 <a href
="https://doc.galette.eu" class="item">
377 <i
class="icon book"></i
>
378 <?php
echo _T("Documentation"); ?
>
380 <a href
="https://twitter.com/galette_soft" class="item">
381 <i
class="icon twitter"></i
>
384 <a href
="https://framapiaf.org/@galette" class="item">
385 <i
class="icon mastodon"></i
>
391 <nav
class="ui horizontal bulleted link list">
392 <a id
="copyright" href
="https://galette.eu/" class="item">
393 <i
class="icon cookie bite"></i
>
394 Galette
<?php
echo GALETTE_DISPLAY_VERSION
; ?
>
400 <script type
="text/javascript" src
="./assets/js/galette-main.bundle.min.js"></script
>
401 <script type
="text/javascript" src
="./themes/default/ui/semantic.min.js"></script
>
405 if (!$install->isEndStep()) {
406 $session[md5(GALETTE_ROOT
)] = serialize($install);
409 if (isset($profiler)) {