X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/2bc76d8baee16b7ba0814c12da52c665158a6d98..129402901986004b50bf8bb338f681b0a0983800:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php index f564db6..95a5595 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) @@ -229,6 +229,21 @@ function jirafeau_get_max_upload_size() return jirafeau_human_size(jirafeau_get_max_upload_size_bytes()); } +/** + * get the maximal upload size for a data chunk in async uploads + * @param max_upload_chunk_size_bytes + */ +function jirafeau_get_max_upload_chunk_size_bytes($max_upload_chunk_size_bytes = 0) +{ + if ($max_upload_chunk_size_bytes > 0) { + return min( + jirafeau_get_max_upload_size_bytes(), + $max_upload_chunk_size_bytes + ); + } + return jirafeau_get_max_upload_size_bytes(); +} + /** * gets a string explaining the error * @param $code the error code @@ -418,7 +433,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 +524,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; } @@ -559,13 +579,15 @@ function show_errors() function check_errors($cfg) { - if (file_exists(JIRAFEAU_ROOT . 'install.php') - && !($cfg['installation_done'] === true)) { - header('Location: install.php'); - exit; + if (!($cfg['installation_done'] === true)) { + if (file_exists(JIRAFEAU_ROOT . 'install.php')) { + header('Location: install.php'); + exit; + } else { + add_error(t('INSTALL_FILE_NOT_FOUND_TITLE'), t('INSTALL_FILE_NOT_FOUND_DESC')); + } } - /* Checking for errors. */ if (!is_writable(VAR_FILES)) { add_error(t('FILE_DIR_W'), VAR_FILES); } @@ -588,8 +610,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 +676,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 +692,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 '