]>
git.p6c8.net - jirafeau_mojo42.git/blob - install.php
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
)) {
51 t('The local configuration file could not be created. Create a ' .
52 '<code>lib/config.local.php</code> file and give the write ' .
53 'permission to the web server (preferred solution), or give the ' .
54 'write permission to the web server on the <code>lib</code> ' .
60 // is the local configuration writable?
61 if (!is_writable(JIRAFEAU_CFG
) && !@chmod
(JIRAFEAU_CFG
, '0666')) {
63 t('The local configuration is not writable by the web server. ' .
64 'Give the write permission to the web server on the ' .
65 '<code>lib/config.local.php</code> file.')
70 * Run trough each installation step
73 if (isset($_POST['step']) && isset($_POST['next'])) {
74 switch ($_POST['step']) {
76 if (strlen($_POST['admin_password'])) {
77 $cfg['admin_password'] = hash('sha256', $_POST['admin_password']);
79 $cfg['admin_password'] = '';
81 jirafeau_export_cfg($cfg);
85 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
86 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
87 jirafeau_export_cfg($cfg);
91 $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
92 $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
93 jirafeau_export_cfg($cfg);
99 if (isset($_POST['next'])) {
100 $current = $_POST['step'] +
1;
101 } elseif (isset($_POST['previous'])) {
102 $current = $_POST['step'] - 1;
103 } elseif (isset($_POST['retry'])) {
104 $current = $_POST['step'];
110 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
111 ' %d ' . t('OUT_OF') . ' %d', 1, 3);
112 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
113 "hidden" name
= "jirafeau" value
=
114 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
115 "step" value
= "1" /><fieldset
> <legend
><?php
117 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
118 "2"><?php
echo t('ADMIN_INTERFACE_INFO');
119 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "select_password"
120 ><?php
echo t('ADMIN_PSW') . ':';
122 <td
class = "field"><input type
= "password" name
= "admin_password"
123 id
= "admin_password" size
= "40" /></td
>
127 <td
class = "nav next">
128 <input type
= "submit"
129 class = "navleft" name
= "previous" value
= "<?php
130 echo t('PREV_STEP'); ?>" />
131 <input type
= "submit" name
= "next" value
=
132 "<?php echo t('NEXT_STEP'); ?>" /></td
> </tr
> </table
>
133 </fieldset
> </form
> </div
> <?php
137 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
138 ' %d ' . t('OUT_OF') . ' %d', 2, 3);
139 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
140 "hidden" name
= "jirafeau" value
=
141 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
143 "2" /><fieldset
> <legend
><?php
echo t('INFO');
144 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
145 "2"><?php
echo t('BASE_ADDR_INFO');
146 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_web_root"
147 ><?php
echo t('BASE_ADDR') . ':';
149 <td
class = "field"><input type
= "text" name
= "web_root"
150 id
= "input_web_root" value
= "<?php
151 echo(empty($cfg['web_root']) ? jirafeau_default_web_root() : $cfg['web_root']);
152 ?>" size
= "40" /></td
>
153 </tr
> <tr
> <td
class = "info" colspan
= "2"><?php
154 echo t('DATA_DIR_EXPLAINATION');
155 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_var_root"
156 ><?php
echo t('DATA_DIR') . ':';
158 <td
class = "field"><input type
= "text" name
= "var_root"
159 id
= "input_var_root" value
= "<?php
160 if (empty($cfg['var_root'])) {
161 $alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
162 'abcdefghijklmnopqrstuvwxyz' . '0123456789';
163 $len_alphanum = strlen($alphanum);
165 for ($i = 0; $i <JIRAFEAU_VAR_RAND_LENGTH; $i++) {
166 $var .= substr($alphanum, mt_rand(0, $len_alphanum - 1), 1);
168 echo JIRAFEAU_ROOT . $var . '/';
170 echo $cfg['var_root'];
172 ?>" size
= "40" /></td
>
173 </tr
> <tr
> <td colspan
= "2"><input type
= "submit"
174 class = "navleft" name
= "previous" value
= "<?php
175 echo t('PREV_STEP'); ?>" />
176 <input type
= "submit" class = "navright" name
= "next" value
=
177 "<?php echo t('NEXT_STEP'); ?>" />
178 </td
> </tr
> </table
> </fieldset
>
183 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
184 ' %d ' . t('OUT_OF') . ' %d', 3, 3);
185 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
186 "hidden" name
= "jirafeau" value
=
187 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
189 "3" /><fieldset
> <legend
><?php
echo t('FINALIZATION');
190 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
191 "2"><?php
echo t('SETTING_UP');
192 ?
></td
> </tr
> <tr
> <td
class = "nav previous"><input type
=
193 "submit" name
= "previous" value
= " <?php echo t('PREV_STEP');
194 ?>" /></td
> <td
></td
> </tr
>
195 </table
> </fieldset
> </form
> </div
>
197 $err = jirafeau_check_var_dir($cfg['var_root']);
198 if ($err['has_error']) {
199 echo '<div class="error"><p>'.$err['why'].'<br />'.NL
; ?
><form method
="post"> <input type
= "hidden" name
= "jirafeau" value
=
200 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
201 "step" value
= "3" /><input type
= "submit" name
=
203 "<?php echo t('RETRY_STEP'); ?>" /></form
>
204 <?php
echo '</p></div>';
206 $cfg['installation_done'] = true;
207 jirafeau_export_cfg($cfg);
208 echo '<div class="message"><p>' .
209 t('JI_FONCTIONAL') . ':' .
210 '<br /><a href="./">' .
211 $cfg['web_root'].'</a></p></div>';
216 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
patrick-canterino.de