-/**
- * Prepend used functions
- **/
-
-function
-jirafeau_quoted ($str)
-{
- return QUOTE . str_replace (QUOTE, "\'", $str) . QUOTE;
-}
-
-function
-jirafeau_export_cfg ($cfg)
-{
- $handle = fopen (JIRAFEAU_CFG, 'w');
- fwrite ($handle, '<?php' . NL);
- fwrite ($handle,
- '/* ' .
- t ('This file was generated by the install process. ' .
- 'You can edit it. Please see config.original.php to understand the ' .
- 'configuration items.') . ' */' . NL);
- foreach ($cfg as $key => $item)
- {
- fwrite ($handle, '$cfg[' . jirafeau_quoted ($key) . '] = ');
- if (is_bool ($item))
- fwrite ($handle, ($item ? 'true' : 'false'));
- else if (is_string ($item))
- fwrite ($handle, jirafeau_quoted ($item));
- else if (is_int ($item))
- fwrite ($handle, $item);
- else if (is_array ($item))
- fwrite ($handle, str_replace(array("\n", "\r"), "",
- var_export ($item, true)));
- else
- fwrite ($handle, 'null');
- fwrite ($handle, ';'.NL);
- }
- /* No newline at the end of the file to be able to send headers. */
- fwrite ($handle, '?>');
- fclose ($handle);
-}
-
-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('The following directory could not be created') . ':';
- $mkdir_str2 = t('You should create this directory manually.');
- $write_str1 = t('The following directory is not writable') . ':';
- $write_str2 = t('You should give the write permission to the web server on ' .
- 'this directory.');
- $solution_str = t('Here is a 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', 'alias') 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) == '/') ? '' : '/');
-}
-
-function
-jirafeau_fatal_error($errorText)
-{
- echo '<div class="error"><h2>Error</h2><p>' . $errorText . '</p></div>';
- require (JIRAFEAU_ROOT . 'lib/template/footer.php');
- exit;
-}