]>
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']) ?
152 $_SERVER['HTTP_HOST'] . str_replace(
155 $_SERVER['REQUEST_URI']
156 ) : $cfg['web_root']);
157 ?>" size
= "40" /></td
>
158 </tr
> <tr
> <td
class = "info" colspan
= "2"><?php
159 echo t('DATA_DIR_EXPLAINATION');
160 ?
></td
> </tr
> <tr
> <td
class = "label"><label
for = "input_var_root"
161 ><?php
echo t('DATA_DIR') . ':';
163 <td
class = "field"><input type
= "text" name
= "var_root"
164 id
= "input_var_root" value
= "<?php
165 if (empty($cfg['var_root'])) {
166 $alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
167 'abcdefghijklmnopqrstuvwxyz' . '0123456789';
168 $len_alphanum = strlen($alphanum);
170 for ($i = 0; $i <JIRAFEAU_VAR_RAND_LENGTH; $i++) {
171 $var .= substr($alphanum, mt_rand(0, $len_alphanum - 1), 1);
173 echo JIRAFEAU_ROOT . $var . '/';
175 echo $cfg['var_root'];
177 ?>" size
= "40" /></td
>
178 </tr
> <tr
> <td colspan
= "2"><input type
= "submit"
179 class = "navleft" name
= "previous" value
= "<?php
180 echo t('PREV_STEP'); ?>" />
181 <input type
= "submit" class = "navright" name
= "next" value
=
182 "<?php echo t('NEXT_STEP'); ?>" />
183 </td
> </tr
> </table
> </fieldset
>
188 ?
><h2
><?php
printf(t('JI_INSTALL') . ' - ' . t('STEP') .
189 ' %d ' . t('OUT_OF') . ' %d', 3, 3);
190 ?
></h2
> <div id
= "install"> <form method
="post"> <input type
=
191 "hidden" name
= "jirafeau" value
=
192 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
194 "3" /><fieldset
> <legend
><?php
echo t('FINALIZATION');
195 ?
></legend
> <table
> <tr
> <td
class = "info" colspan
=
196 "2"><?php
echo t('SETTING_UP');
197 ?
></td
> </tr
> <tr
> <td
class = "nav previous"><input type
=
198 "submit" name
= "previous" value
= " <?php echo t('PREV_STEP');
199 ?>" /></td
> <td
></td
> </tr
>
200 </table
> </fieldset
> </form
> </div
>
202 $err = jirafeau_check_var_dir($cfg['var_root']);
203 if ($err['has_error']) {
204 echo '<div class="error"><p>'.$err['why'].'<br />'.NL
; ?
><form method
="post"> <input type
= "hidden" name
= "jirafeau" value
=
205 "<?php echo JIRAFEAU_VERSION; ?>" /><input type
= "hidden" name
=
206 "step" value
= "3" /><input type
= "submit" name
=
208 "<?php echo t('RETRY_STEP'); ?>" /></form
>
209 <?php
echo '</p></div>';
211 $cfg['installation_done'] = true;
212 jirafeau_export_cfg($cfg);
213 echo '<div class="message"><p>' .
214 t('JI_FONCTIONAL') . ':' .
215 '<br /><a href="./">' .
216 $cfg['web_root'].'</a></p></div>';
221 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
patrick-canterino.de