X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/33bb6cfe3111b316082336edae43846aaef84f17..3e84a5debe0984bea841016ba587b109031a7816:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php index a4f9ec6..27265bd 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -20,7 +20,7 @@ */ /** - * Transform a string in a path by seperating each letters by a '/'. + * Transform a string in a path by separating each letters by a '/'. * @return path finishing with a '/' */ function s2p($s) @@ -28,7 +28,7 @@ function s2p($s) $block_size = 8; $p = ''; for ($i = 0; $i < strlen($s); $i++) { - $p .= $s{$i}; + $p .= $s[$i]; if (($i + 1) % $block_size == 0) { $p .= '/'; } @@ -68,16 +68,16 @@ function base_16_to_64($num) # Convert long hex string to bin. $size = strlen($num); for ($i = 0; $i < $size; $i++) { - $b .= $hex2bin{hexdec($num{$i})}; + $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; + $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; + $o = $m[bindec(substr($b, 0, $i + 6))] . $o; } return $o; } @@ -418,7 +418,7 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l } } - /* file informations */ + /* file information */ $hash = jirafeau_hash_file($file_hash_method, $file['tmp_name']); $name = str_replace(NL, '', trim($file['name'])); $mime_type = $file['type']; @@ -509,10 +509,15 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $ip, $crypt, $l function jirafeau_is_viewable($mime) { if (!empty($mime)) { - /* Actually, verify if mime-type is an image or a text. */ - $viewable = array('image', 'text', 'video', 'audio'); + $viewable = array('image', 'video', 'audio'); $decomposed = explode('/', $mime); - return in_array($decomposed[0], $viewable); + if (in_array($decomposed[0], $viewable) && strpos($mime, 'image/svg+xml') === false) { + return true; + } + $viewable = array('text/plain'); + if (in_array($mime, $viewable)) { + return true; + } } return false; } @@ -588,8 +593,8 @@ function check_errors($cfg) } /** - * Read link informations - * @return array containing informations. + * Read link information + * @return array containing information. */ function jirafeau_get_link($hash) { @@ -654,7 +659,7 @@ function jirafeau_admin_list($name, $file_hash, $link_hash) /* Push new found directory. */ $stack[] = $d . $node . '/'; } elseif (is_file($d . $node)) { - /* Read link informations. */ + /* Read link information. */ $l = jirafeau_get_link($node); if (!count($l)) { continue; @@ -670,7 +675,7 @@ function jirafeau_admin_list($name, $file_hash, $link_hash) if (!empty($link_hash) && $link_hash != $node) { continue; } - /* Print link informations. */ + /* Print link information. */ echo '