X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/794c20eff72e03a6af2fbdebb091560ed8b6f296..6c49ea194c030a04ce8b303aae2a51dce01c7382:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php index 76ae4b0..1e5b083 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1385,4 +1385,28 @@ jirafeau_decrypt_file ($fp_src, $fp_dst, $k) return true; } -?> +/** + * Check if Jirafeau is password protected for visitors. + * @return true if Jirafeau is password protected, false otherwise. + */ +function jirafeau_has_upload_password ($cfg) +{ + return count ($cfg['upload_password']) > 0; +} + +/** + * Challenge password for a visitor. + * @param $password password to be challenged + * @return true if password is valid, false otherwise. + */ +function jirafeau_challenge_upload_password ($cfg, $password) +{ + if (!jirafeau_has_upload_password($cfg)) + return false; + forEach ($cfg['upload_password'] as $p) + if ($password == $p) + return true; + error_log("password not found $password"); + return false; +} +