X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/b44a2e97126df168caf012ccd71e88d1878cad94..aec8a198a162933a5907f7ae598493611b206228:/plugins/sql_auth/sql_auth.php diff --git a/plugins/sql_auth/sql_auth.php b/plugins/sql_auth/sql_auth.php index 83b1e6f..62d59bd 100644 --- a/plugins/sql_auth/sql_auth.php +++ b/plugins/sql_auth/sql_auth.php @@ -1,6 +1,8 @@ id) // doesn't exist, add it with full privileges + { + create_new_user(["user_name" => SQL_DEFAULT_USER['username'], "user_pass" => SQL_DEFAULT_USER['password']]); + } + } } public static function add_navbar(&$pages) { session_start(); - $query = "SELECT * FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_TYPE = 'BASE TABLE' - AND TABLE_NAME = '".SQL_PREFIX."users'"; - - $conn = sqlnew(); - $result = $conn->query($query); - $notifs = 0; - $link = ""; - if (!$result || !$result->fetchColumn()) - { - ++$notifs; - $link = "error.php?errno=1"; - } - $label = ($notifs) ? "$notifs" : ""; - $pages["SQL Auth$label"] = "plugins/sql_auth/$link"; - if ($_SESSION['id']) + + $pages["Panel Access"] = "plugins/sql_auth/"; + if (isset($_SESSION['id'])) { $pages["Logout"] = "plugins/sql_auth/login.php?logout=true"; } @@ -40,11 +41,68 @@ class sql_auth public static function session_start($n) { - session_start(); if (!isset($_SESSION['id'])) { header("Location: ".BASE_URL."plugins/sql_auth/login.php"); } } + public static function create_tables() + { + $conn = sqlnew(); + $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "users ( + user_id int AUTO_INCREMENT NOT NULL, + user_name VARCHAR(255) NOT NULL, + user_pass VARCHAR(255) NOT NULL, + + user_fname VARCHAR(255), + user_lname VARCHAR(255), + user_bio VARCHAR(255), + created VARCHAR(255), + PRIMARY KEY (user_id) + )"); + $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "user_meta ( + meta_id int AUTO_INCREMENT NOT NULL, + user_id int NOT NULL, + meta_key VARCHAR(255) NOT NULL, + meta_value VARCHAR(255), + PRIMARY KEY (meta_id) + )"); + } + + public static function add_overview_card(&$stats) + { + $num_of_panel_admins = sqlnew()->query("SELECT COUNT(*) FROM " . SQL_PREFIX . "users")->fetchColumn(); + ?> + +