X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/4a704a2317082462f221a2a721ab8bab864c461e..689557880514b74d0e21a56b40fe16a78f3b1a65:/install.php?ds=sidebyside diff --git a/install.php b/install.php index b6b322d..6dbefb5 100644 --- a/install.php +++ b/install.php @@ -26,73 +26,6 @@ require(JIRAFEAU_ROOT . 'lib/settings.php'); require(JIRAFEAU_ROOT . 'lib/functions.php'); require(JIRAFEAU_ROOT . 'lib/lang.php'); -function jirafeau_export_cfg($cfg) -{ - $content = '<?php' . NL; - $content .= '/* This file was generated by the install process. ' . - 'You can edit it. Please see config.original.php to understand the ' . - 'configuration items. */' . NL; - $content .= '$cfg = ' . var_export($cfg, true) . ';'; - - $fileWrite = file_put_contents(JIRAFEAU_CFG, $content); - - if (false === $fileWrite) { - jirafeau_fatal_error(t('Can not write local configuration file')); - } -} - -function jirafeau_mkdir($path) -{ - return !(!file_exists($path) && !@mkdir($path, 0755)); -} - -/** - * Returns true whether the path is writable or we manage to make it - * so, which essentially is the same thing. - * @param $path is the file or directory to be tested. - * @return true if $path is writable. - */ -function jirafeau_is_writable($path) -{ - /* "@" gets rid of error messages. */ - return is_writable($path) || @chmod($path, 0777); -} - -function jirafeau_check_var_dir($path) -{ - $mkdir_str1 = t('CANNOT_CREATE_DIR') . ':'; - $mkdir_str2 = t('MANUAL_CREATE'); - $write_str1 = t('DIR_NOT_W') . ':'; - $write_str2 = t('You should give the write permission to the web server on ' . - 'this directory.'); - $solution_str = t('HERE_SOLUTION') . ':'; - - if (!jirafeau_mkdir($path) || !jirafeau_is_writable($path)) { - return array('has_error' => true, - 'why' => $mkdir_str1 . '<br /><code>' . - $path . '</code><br />' . $solution_str . - '<br />' . $mkdir_str2); - } - - foreach (array('files', 'links', 'async') as $subdir) { - $subpath = $path.$subdir; - - if (!jirafeau_mkdir($subpath) || !jirafeau_is_writable($subpath)) { - return array('has_error' => true, - 'why' => $mkdir_str1 . '<br /><code>' . - $subpath . '</code><br />' . $solution_str . - '<br />' . $mkdir_str2); - } - } - - return array('has_error' => false, 'why' => ''); -} - -function jirafeau_add_ending_slash($path) -{ - return $path . ((substr($path, -1) == '/') ? '' : '/'); -} - /** * Check installation **/ @@ -114,23 +47,13 @@ require(JIRAFEAU_ROOT . 'lib/template/header.php'); if (!file_exists(JIRAFEAU_CFG)) { // show an error if it is not possible to create the file if (!@touch(JIRAFEAU_CFG)) { - jirafeau_fatal_error( - t('The local configuration file could not be created. Create a ' . - '<code>lib/config.local.php</code> file and give the write ' . - 'permission to the web server (preferred solution), or give the ' . - 'write permission to the web server on the <code>lib</code> ' . - 'directory.') - ); + jirafeau_fatal_error(t('CONF_SOLUTION')); } } // is the local configuration writable? if (!is_writable(JIRAFEAU_CFG) && !@chmod(JIRAFEAU_CFG, '0666')) { - jirafeau_fatal_error( - t('The local configuration is not writable by the web server. ' . - 'Give the write permission to the web server on the ' . - '<code>lib/config.local.php</code> file.') - ); + jirafeau_fatal_error(t('CONF_SOLUTION_2')); } /** @@ -187,7 +110,7 @@ default: ><?php echo t('ADMIN_PSW') . ':'; ?></label></td> <td class = "field"><input type = "password" name = "admin_password" - id = "admin_password" size = "40" /></td> + id = "admin_password" size = "40" autocomplete = "new-password"/></td> </tr> <tr class = "nav"> <td></td> @@ -215,12 +138,7 @@ case 2: ?></label></td> <td class = "field"><input type = "text" name = "web_root" id = "input_web_root" value = "<?php - echo(empty($cfg['web_root']) ? - $_SERVER['HTTP_HOST'] . str_replace( - basename(__FILE__), - '', - $_SERVER['REQUEST_URI'] - ) : $cfg['web_root']); + echo(empty($cfg['web_root']) ? jirafeau_default_web_root() : $cfg['web_root']); ?>" size = "40" /></td> </tr> <tr> <td class = "info" colspan = "2"><?php echo t('DATA_DIR_EXPLAINATION');