X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/d8529b7477be1783bf47d5ec9c1bfe98b0bf4f07..964faa704b2ed91aa5df77906cdb38909dff21b6:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php index 5a5316c..5c5fea7 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -2,7 +2,7 @@ /* * Jirafeau, your web file repository * Copyright (C) 2008 Julien "axolotl" BERNARD - * Copyright (C) 2015 Jerome Jutteau + * Copyright (C) 2015 Jerome Jutteau * Copyright (C) 2015 Nicola Spanti (RyDroid) * * This program is free software: you can redistribute it and/or modify @@ -321,7 +321,7 @@ function jirafeau_delete_file($hash) /** hash file's content - * @param $method hash method, see 'file_hash' option. 'md5' or 'md5_outside'. + * @param $method hash method, see 'file_hash' option. Valid methods are 'md5', 'md5_outside' or 'random' * @param $file_path file to hash * @returns hash string */ @@ -332,6 +332,8 @@ function jirafeau_hash_file($method, $file_path) return jirafeau_md5_outside($file_path); case 'md5': return md5_file($file_path); + case 'random': + return jirafeau_gen_random(32); } return md5_file($file_path); } @@ -567,6 +569,14 @@ function check_errors($cfg) if (!is_writable(VAR_ASYNC)) { add_error(t('ASYNC_DIR_W'), VAR_ASYNC); } + + if ($cfg['enable_crypt'] && $cfg['litespeed_workaround']) { + add_error(t('INCOMPATIBLE_OPTIONS_W'), 'enable_crypt=true
litespeed_workaround=true'); + } + + if ($cfg['one_time_download'] && $cfg['litespeed_workaround']) { + add_error(t('INCOMPATIBLE_OPTIONS_W'), 'one_time_download=true
litespeed_workaround=true'); + } } /** @@ -1334,3 +1344,12 @@ function jirafeau_admin_csrf_field() { return ""; } + +function jirafeau_dir_size($dir) +{ + $size = 0; + foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $entry) { + $size += is_file($entry) ? filesize($entry) : jirafeau_dir_size($entry); + } + return $size; +}