]>
git.p6c8.net - jirafeau_mojo42.git/blob - install.php
6dbefb586e84463791d48a3b37db69f1ba82d7ef
3 * Jirafeau, your web file repository
4 * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
5 * Copyright (C) 2015 Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 define('JIRAFEAU_ROOT', dirname(__FILE__
) . '/');
22 define('JIRAFEAU_CFG', JIRAFEAU_ROOT
. 'lib/config.local.php');
23 define('JIRAFEAU_VAR_RAND_LENGTH', 15);
25 require(JIRAFEAU_ROOT
. 'lib/settings.php');
26 require(JIRAFEAU_ROOT
. 'lib/functions.php');
27 require(JIRAFEAU_ROOT
. 'lib/lang.php');
33 // Is the installation process done already?
34 // Then there is nothing to do here → redirect to the main page.
35 if ($cfg['installation_done'] === true) {
36 header('Location: index.php');
41 * Prepare installation process
44 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
46 // does the local configuration file exist?
47 if (!file_exists(JIRAFEAU_CFG
)) {
48 // show an error if it is not possible to create the file
49 if (!@touch
(JIRAFEAU_CFG
)) {
50 jirafeau_fatal_error(t('CONF_SOLUTION'));
54 // is the local configuration writable?
55 if (!is_writable(JIRAFEAU_CFG
) && !@chmod
(JIRAFEAU_CFG
, '0666')) {
56 jirafeau_fatal_error(t('CONF_SOLUTION_2'));
60 * Run trough each installation step
63 if (isset($_POST['step']) && isset($_POST['next'])) {
64 switch ($_POST['step']) {
66 if (strlen($_POST['admin_password'])) {
67 $cfg['admin_password'] = hash('sha256', $_POST['admin_password']);
69 $cfg['admin_password'] = '';
71 jirafeau_export_cfg($cfg);
75 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
76 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
77 jirafeau_export_cfg($cfg);
81 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
82 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
83 jirafeau_export_cfg($cfg);
89 if (isset($_POST['next'])) {
90 $current = $_POST['step'] +
1;
91 } elseif (isset($_POST['previous'])) {
92 $current = $_POST['step'] - 1;
93 } elseif (isset($_POST['retry'])) {
94 $current = $_POST['step'];
100 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
101 ' %d ' . t('OUT_OF') . ' %d', 1, 3);
102 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
103 "hidden" name
= "jirafeau" value
=
104 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
105 "step" value
= "1" /><fieldset
> <legend
><?php
107 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
108 "2"><?php
echo t('ADMIN_INTERFACE_INFO');
109 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "select_password"
110 ><?php
echo t('ADMIN_PSW') . ':';
112 <td
class = "field"><input type
= "password" name
= "admin_password"
113 id
= "admin_password" size
= "40" autocomplete
= "new-password"/></td
>
117 <td
class = "nav next">
118 <input type
= "submit"
119 class = "navleft" name
= "previous" value
= "<?php
120 echo t('PREV_STEP'); ?>" />
121 <input type
= "submit" name
= "next" value
=
122 "<?php echo t('NEXT_STEP'); ?>" /></td
> </tr
> </table
>
123 </fieldset
> </form
> </div
> <?php
127 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
128 ' %d ' . t('OUT_OF') . ' %d', 2, 3);
129 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
130 "hidden" name
= "jirafeau" value
=
131 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
133 "2" /><fieldset
> <legend
><?php
echo t('INFO');
134 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
135 "2"><?php
echo t('BASE_ADDR_INFO');
136 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_web_root"
137 ><?php
echo t('BASE_ADDR') . ':';
139 <td
class = "field"><input type
= "text" name
= "web_root"
140 id
= "input_web_root" value
= "<?php
141 echo(empty($cfg['web_root']) ? jirafeau_default_web_root() : $cfg['web_root']);
142 ?>" size
= "40" /></td
>
143 </tr
> <tr
> <td
class = "info" colspan
= "2"><?php
144 echo t('DATA_DIR_EXPLAINATION');
145 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_var_root"
146 ><?php
echo t('DATA_DIR') . ':';
148 <td
class = "field"><input type
= "text" name
= "var_root"
149 id
= "input_var_root" value
= "<?php
150 if (empty($cfg['var_root'])) {
151 $alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
152 'abcdefghijklmnopqrstuvwxyz' . '0123456789';
153 $len_alphanum = strlen($alphanum);
155 for ($i = 0; $i <JIRAFEAU_VAR_RAND_LENGTH; $i++) {
156 $var .= substr($alphanum, mt_rand(0, $len_alphanum - 1), 1);
158 echo JIRAFEAU_ROOT . $var . '/';
160 echo $cfg['var_root'];
162 ?>" size
= "40" /></td
>
163 </tr
> <tr
> <td colspan
= "2"><input type
= "submit"
164 class = "navleft" name
= "previous" value
= "<?php
165 echo t('PREV_STEP'); ?>" />
166 <input type
= "submit" class = "navright" name
= "next" value
=
167 "<?php echo t('NEXT_STEP'); ?>" />
168 </td
> </tr
> </table
> </fieldset
>
173 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
174 ' %d ' . t('OUT_OF') . ' %d', 3, 3);
175 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
176 "hidden" name
= "jirafeau" value
=
177 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
179 "3" /><fieldset
> <legend
><?php
echo t('FINALIZATION');
180 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
181 "2"><?php
echo t('SETTING_UP');
182 ?
></td
> </tr
> <tr
> <td
class = "nav previous"><input type
=
183 "submit" name
= "previous" value
= " <?php echo t('PREV_STEP');
184 ?>" /></td
> <td
></td
> </tr
>
185 </table
> </fieldset
> </form
> </div
>
187 $err = jirafeau_check_var_dir($cfg['var_root']);
188 if ($err['has_error']) {
189 echo '<div class="error"><p>'.$err['why'].'<br />'.NL
; ?
><form method
="post"> <input type
= "hidden" name
= "jirafeau" value
=
190 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
191 "step" value
= "3" /><input type
= "submit" name
=
193 "<?php echo t('RETRY_STEP'); ?>" /></form
>
194 <?php
echo '</p></div>';
196 $cfg['installation_done'] = true;
197 jirafeau_export_cfg($cfg);
198 echo '<div class="message"><p>' .
199 t('JI_FONCTIONAL') . ':' .
200 '<br /><a href="./">' .
201 $cfg['web_root'].'</a></p></div>';
206 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
patrick-canterino.de