X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/a23a86c48b1675e131fe80e7a332b46422ebf846..18c82ef56dce9c9eb30b0f2318024d320d878a47:/lib/functions.php?ds=inline diff --git a/lib/functions.php b/lib/functions.php index 10fc0ab..898b6fc 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -39,15 +39,34 @@ function base_16_to_64 ($num) { $m = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'; + $hex2bin = ['0000', # 0 + '0001', # 1 + '0010', # 2 + '0011', # 3 + '0100', # 4 + '0101', # 5 + '0110', # 6 + '0111', # 7 + '1000', # 8 + '1001', # 9 + '1010', # a + '1011', # b + '1100', # c + '1101', # d + '1110', # e + '1111']; # f $o = ''; $b = ''; $i = 0; + # Convert long hex string to bin. $size = strlen ($num); for ($i = 0; $i < $size; $i++) - $b .= base_convert ($num{$i}, 16, 2); - $size = strlen ($b); + $b .= $hex2bin{hexdec ($num{$i})}; + # Convert long bin to base 64. + $size *= 4; for ($i = $size - 6; $i >= 0; $i -= 6) $o = $m{bindec (substr ($b, $i, 6))} . $o; + # Some few bits remaining ? if ($i < 0 && $i > -6) $o = $m{bindec (substr ($b, 0, $i + 6))} . $o; return $o; @@ -432,6 +451,32 @@ show_errors () } } +function check_errors () +{ + if (file_exists (JIRAFEAU_ROOT . 'install.php') + && !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php')) + { + header('Location: install.php'); + exit; + } + + /* check if the destination dirs are writable */ + $writable = is_writable (VAR_FILES) && is_writable (VAR_LINKS); + + /* Checking for errors. */ + if (!is_writable (VAR_FILES)) + add_error (t('The file directory is not writable!'), VAR_FILES); + + if (!is_writable (VAR_LINKS)) + add_error (t('The link directory is not writable!'), VAR_LINKS); + + /* Check if the install.php script is still in the directory. */ + if (file_exists (JIRAFEAU_ROOT . 'install.php')) + add_error (t('Installer script still present'), + t('Please make sure to delete the installer script ' . + '"install.php" before continuing.')); +} + /** * Read link informations * @return array containing informations.