From: Matthieu Schneider Date: Tue, 31 Oct 2017 13:43:37 +0000 (+0300) Subject: [FEATURE] Add check ip_nopassword in challenge_upload function X-Git-Tag: 4.0.0~20 X-Git-Url: https://git.p6c8.net/jirafeau.git/commitdiff_plain/f07477cb289eb839af7255b25188765d5e49ad94?ds=inline [FEATURE] Add check ip_nopassword in challenge_upload function --- diff --git a/lib/functions.php b/lib/functions.php index cf6b913..2817aa1 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1108,6 +1108,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) {