X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/0d312b3c20fc8d17a4808442c49b72a499d0dc76..1a41ef82ac7e1a30134e471f73e9a8d0e204f2a6:/lib/functions.php?ds=sidebyside diff --git a/lib/functions.php b/lib/functions.php index 01d0638..df207da 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -25,9 +25,16 @@ */ 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 .= '/'; + } + } + if (strlen($s) % $block_size != 0) { + $p .= '/'; } return $p; } @@ -498,16 +505,13 @@ function check_errors($cfg) 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); + add_error(t('FILE_DIR_W'), VAR_FILES); } if (!is_writable(VAR_LINKS)) { - add_error(t('The link directory is not writable!'), VAR_LINKS); + add_error(t('LINK_DIR_W'), VAR_LINKS); } if (!is_writable(VAR_ASYNC)) { @@ -1111,6 +1115,21 @@ function jirafeau_challenge_upload ($cfg, $ip, $password) return true; } + // Allow if ip is in array (no password) + foreach ($cfg['upload_ip_nopassword'] as $i) { + if ($i == $ip) { + return true; + } + // CIDR test for IPv4 only. + if (strpos ($i, '/') !== false) + { + list ($subnet, $mask) = explode('/', $i); + if ((ip2long ($ip) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet)) { + return true; + } + } + } + // Allow if ip is in array foreach ($cfg['upload_ip'] as $i) { if ($i == $ip) {