]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - plugins/file_auth/file_auth.php
Make new settings-in-config work for file-based db as well.
[irc/unrealircd/unrealircd-webpanel.git] / plugins / file_auth / file_auth.php
index 8446c84656333d759a181adc04ac0caa6b8edbc4..eea39bce273e749810e0154518e64fb43ccc5bd6 100644 (file)
@@ -189,7 +189,7 @@ class file_auth
        {
                GLOBAL $db;
                /* Refuse to write empty db (or nearly empty) */
-               if (empty($db) || empty($db["users"]) && !$force)
+               if (empty($db) || (empty($db["users"]) && empty($db["settings"])) && !$force)
                        return;
 
                $db_filename = UPATH.'/data/database.php';
@@ -349,3 +349,24 @@ class file_auth
                file_auth::write_db(true);
        }
 }
+
+class DbSettings {
+       public static function get()
+       {
+               GLOBAL $db;
+
+               if (!isset($db) || empty($db))
+                       file_auth::read_db();
+
+               return $db["settings"];
+       }
+       public static function set($key, $val) : bool
+       {
+               GLOBAL $db;
+
+               file_auth::read_db();
+               $db["settings"][$key] = $val;
+               file_auth::write_db();
+               return true;
+       }
+}