]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Setup: acctually delete SQL tables (after confirmation and filling in user info)
authorBram Matthys <redacted>
Sun, 23 Apr 2023 15:42:35 +0000 (17:42 +0200)
committerBram Matthys <redacted>
Sun, 23 Apr 2023 15:42:35 +0000 (17:42 +0200)
plugins/sql_auth/sql_auth.php
settings/install.php

index d71db17246f9b63b90b573e043f2de60f0d64817..6ab309dcdfc55e05b26b7602166dfffd48d32a89 100644 (file)
@@ -43,6 +43,17 @@ class sql_auth
                        Message::Fail("Warning: DEFAULT_USER is set in config.php. You should remove that item now, as it is only used during installation.");
        }
 
+       /**
+        * Delete all the tables (of us) in the SQLdb
+        * @return void
+        */
+       public static function delete_tables()
+       {
+               $conn = sqlnew();
+               foreach(["users","user_meta", "settings", "fail2ban"] as $table_name)
+                       $conn->query("DROP TABLE IF EXISTS " . get_config("mysql::table_prefix") . $table_name);
+       }
+
        /**
         * Create the tables we'll be using in the SQLdb
         * @return void
index 60acfe6567141216db9d06361e8817601bf41366..b96cc9a48e14db61f52490d9c2550bf6f49195ac 100644 (file)
@@ -135,8 +135,11 @@ $writable = (is_writable("../config/")) ? true: false;
                write_config_file();
 
                if ($auth_method == "sql_auth")
+               {
+                       sql_auth::delete_tables();
                        if (!sql_auth::create_tables())
                                Message::Fail("Could not create SQL tables");
+               }
 
                $user = [
                        "user_name" => $opts->account_user,