-if (!file_exists (JIRAFEAU_CFG))
-{
- /* We try to create an empty one. */
- if (!@touch (JIRAFEAU_CFG))
- {
- require (JIRAFEAU_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>' .
- t('The local configuration file could not be created. Create a ' .
- '<code>lib/config.local.php</code> file and give the write ' .
- 'right to the web server (preferred solution), or give the ' .
- 'write right to the web server on the <code>lib</code> ' .
- 'directory.') .
- '</p></div>';
- require (JIRAFEAU_ROOT . 'lib/template/footer.php');
- exit;
- }
-}
-#else
-#{
-# header('Location: index.php');
-# exit;
-#}
-
-if (!is_writable (JIRAFEAU_CFG) && !@chmod (JIRAFEAU_CFG, '0666'))
-{
- require (JIRAFEAU_ROOT . 'lib/template/header.php');
- echo '<div class="error"><p>' .
- t('The local configuration is not writable by the web server. ' .
- 'Give the write right to the web server on the ' .
- '<code>lib/config.local.php</code> file.') .
- '</p></div>';
- require (JIRAFEAU_ROOT . 'lib/template/footer.php');
- exit;
-}
-
-if (isset ($_POST['step']) && isset ($_POST['next']))
-{
- switch ($_POST['step'])
- {
- case 1:
- $cfg['lang'] = $_POST['lang'];
- jirafeau_export_cfg ($cfg);
- break;
-
- case 2:
- $cfg['admin_password'] = $_POST['admin_password'];
- jirafeau_export_cfg ($cfg);
- break;
-
- case 3:
- $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']);
- $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']);
- jirafeau_export_cfg ($cfg);
- break;
-
- case 4:
- $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']);
- $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']);
- jirafeau_export_cfg ($cfg);
- break;
-
- default: break;
+/**
+ * Run trough each installation step
+ **/
+
+if (isset($_POST['step']) && isset($_POST['next'])) {
+ switch ($_POST['step']) {
+ case 1:
+ if (strlen($_POST['admin_password'])) {
+ $cfg['admin_password'] = hash('sha256', $_POST['admin_password']);
+ } else {
+ $cfg['admin_password'] = '';
+ }
+ jirafeau_export_cfg($cfg);
+ break;
+
+ case 2:
+ $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
+ $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
+ jirafeau_export_cfg($cfg);
+ break;
+
+ case 3:
+ $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']);
+ $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']);
+ jirafeau_export_cfg($cfg);
+ break;