]> git.p6c8.net - jirafeau.git/blobdiff - lib/functions.php
Closes #6 can use several upload passwords in options
[jirafeau.git] / lib / functions.php
index c613d4aa7430d80fee4ee93fd76e69f4a0bea8c6..1e5b08355b53da1ad4be8f2cb43ec29dedbca602 100644 (file)
@@ -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;
+}
+

patrick-canterino.de