]> git.p6c8.net - jirafeau_mojo42.git/blobdiff - lib/functions.php
Closes #6 can use several upload passwords in options
[jirafeau_mojo42.git] / lib / functions.php
index 76ae4b0189a0937754f97e8a043c6bb9978c80db..1e5b08355b53da1ad4be8f2cb43ec29dedbca602 100644 (file)
@@ -1385,4 +1385,28 @@ jirafeau_decrypt_file ($fp_src, $fp_dst, $k)
     return true;
 }
 
     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;
+}
+

patrick-canterino.de