X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/d8192d6d361c2d707bac679facce23c7167cb93b..6c49ea194c030a04ce8b303aae2a51dce01c7382:/lib/functions.php diff --git a/lib/functions.php b/lib/functions.php old mode 100755 new mode 100644 index c613d4a..1e5b083 --- a/lib/functions.php +++ b/lib/functions.php @@ -555,6 +555,8 @@ jirafeau_get_link ($hash) $out['link_code'] = trim ($c[9]); if (trim ($c[10]) == 'C') $out['crypted'] = true; + else + $out['crypted'] = false; return $out; } @@ -1383,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; +} +