]>
git.p6c8.net - jirafeau_project.git/blob - install.php
3 * Jirafeau, your web file repository
4 * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
5 * Copyright (C) 2015 Jerome Jutteau <jerome@jutteau.fr>
6 * Copyright (C) 2024 Jirafeau project <https://gitlab.com/jirafeau> (see AUTHORS.md)
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 define('JIRAFEAU_ROOT', dirname(__FILE__
) . '/');
23 define('JIRAFEAU_CFG', JIRAFEAU_ROOT
. 'lib/config.local.php');
24 define('JIRAFEAU_VAR_RAND_LENGTH', 15);
26 require(JIRAFEAU_ROOT
. 'lib/settings.php');
27 require(JIRAFEAU_ROOT
. 'lib/functions.php');
28 require(JIRAFEAU_ROOT
. 'lib/lang.php');
34 // Is the installation process done already?
35 // Then there is nothing to do here → redirect to the main page.
36 if ($cfg['installation_done'] === true) {
37 header('Location: index.php');
42 * Prepare installation process
45 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
47 // does the local configuration file exist?
48 if (!file_exists(JIRAFEAU_CFG
)) {
49 // show an error if it is not possible to create the file
50 if (!@touch
(JIRAFEAU_CFG
)) {
51 jirafeau_fatal_error(t('CONF_SOLUTION'));
55 // is the local configuration writable?
56 if (!is_writable(JIRAFEAU_CFG
) && !@chmod
(JIRAFEAU_CFG
, '0666')) {
57 jirafeau_fatal_error(t('CONF_SOLUTION_2'));
61 * Run trough each installation step
64 if (isset($_POST['step']) && isset($_POST['next'])) {
65 switch ($_POST['step']) {
67 if (strlen($_POST['admin_password'])) {
68 $cfg['admin_password'] = hash('sha256', $_POST['admin_password']);
70 $cfg['admin_password'] = '';
72 jirafeau_export_cfg($cfg);
76 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
77 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
78 jirafeau_export_cfg($cfg);
82 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
83 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
84 jirafeau_export_cfg($cfg);
90 if (isset($_POST['next'])) {
91 $current = $_POST['step'] +
1;
92 } elseif (isset($_POST['previous'])) {
93 $current = $_POST['step'] - 1;
94 } elseif (isset($_POST['retry'])) {
95 $current = $_POST['step'];
101 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
102 ' %d ' . t('OUT_OF') . ' %d', 1, 3);
103 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
104 "hidden" name
= "jirafeau" value
=
105 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
106 "step" value
= "1" /><fieldset
> <legend
><?php
108 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
109 "2"><?php
echo t('ADMIN_INTERFACE_INFO');
110 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "select_password"
111 ><?php
echo t('ADMIN_PSW') . ':';
113 <td
class = "field"><input type
= "password" name
= "admin_password"
114 id
= "admin_password" size
= "40" autocomplete
= "new-password"/></td
>
118 <td
class = "nav next">
119 <input type
= "submit"
120 class = "navleft" name
= "previous" value
= "<?php
121 echo t('PREV_STEP'); ?>" />
122 <input type
= "submit" name
= "next" value
=
123 "<?php echo t('NEXT_STEP'); ?>" /></td
> </tr
> </table
>
124 </fieldset
> </form
> </div
> <?php
128 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
129 ' %d ' . t('OUT_OF') . ' %d', 2, 3);
130 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
131 "hidden" name
= "jirafeau" value
=
132 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
134 "2" /><fieldset
> <legend
><?php
echo t('INFO');
135 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
136 "2"><?php
echo t('BASE_ADDR_INFO');
137 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_web_root"
138 ><?php
echo t('BASE_ADDR') . ':';
140 <td
class = "field"><input type
= "text" name
= "web_root"
141 id
= "input_web_root" value
= "<?php
142 echo(empty($cfg['web_root']) ? jirafeau_default_web_root() : $cfg['web_root']);
143 ?>" size
= "40" /></td
>
144 </tr
> <tr
> <td
class = "info" colspan
= "2"><?php
145 echo t('DATA_DIR_EXPLAINATION');
146 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_var_root"
147 ><?php
echo t('DATA_DIR') . ':';
149 <td
class = "field"><input type
= "text" name
= "var_root"
150 id
= "input_var_root" value
= "<?php
151 if (empty($cfg['var_root'])) {
152 $alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
153 'abcdefghijklmnopqrstuvwxyz' . '0123456789';
154 $len_alphanum = strlen($alphanum);
156 for ($i = 0; $i < JIRAFEAU_VAR_RAND_LENGTH; $i++) {
157 $var .= substr($alphanum, mt_rand(0, $len_alphanum - 1), 1);
159 echo JIRAFEAU_ROOT . $var . '/';
161 echo $cfg['var_root'];
163 ?>" size
= "40" /></td
>
164 </tr
> <tr
> <td colspan
= "2"><input type
= "submit"
165 class = "navleft" name
= "previous" value
= "<?php
166 echo t('PREV_STEP'); ?>" />
167 <input type
= "submit" class = "navright" name
= "next" value
=
168 "<?php echo t('NEXT_STEP'); ?>" />
169 </td
> </tr
> </table
> </fieldset
>
174 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
175 ' %d ' . t('OUT_OF') . ' %d', 3, 3);
176 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
177 "hidden" name
= "jirafeau" value
=
178 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
180 "3" /><fieldset
> <legend
><?php
echo t('FINALIZATION');
181 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
182 "2"><?php
echo t('SETTING_UP');
183 ?
></td
> </tr
> <tr
> <td
class = "nav previous"><input type
=
184 "submit" name
= "previous" value
= " <?php echo t('PREV_STEP');
185 ?>" /></td
> <td
></td
> </tr
>
186 </table
> </fieldset
> </form
> </div
>
188 $err = jirafeau_check_var_dir($cfg['var_root']);
189 if ($err['has_error']) {
190 echo '<div class="error"><p>'.$err['why'].'<br />'.NL
; ?
><form method
="post"> <input type
= "hidden" name
= "jirafeau" value
=
191 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
192 "step" value
= "3" /><input type
= "submit" name
=
194 "<?php echo t('RETRY_STEP'); ?>" /></form
>
195 <?php
echo '</p></div>';
197 $cfg['installation_done'] = true;
198 jirafeau_export_cfg($cfg);
199 echo '<div class="message"><p>' .
200 t('JI_FONCTIONAL') . ':' .
201 '<br /><a href="./">' .
202 $cfg['web_root'].'</a></p></div>';
207 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
patrick-canterino.de