diff --git a/admin/admin_nav.php b/admin/admin_nav.php index 261799a..c139fd1 100644 --- a/admin/admin_nav.php +++ b/admin/admin_nav.php @@ -24,14 +24,14 @@
diff --git a/admin/data_management/add_game.php b/admin/data_management/add_game.php index 3dd3d59..b713471 100644 --- a/admin/data_management/add_game.php +++ b/admin/data_management/add_game.php @@ -6,7 +6,7 @@ - +
Creating trophy data table...
"; - - // Check if the replay data table exists already - $sqlCheckTrophyTable = $conn->prepare("SHOW TABLES LIKE '" . $trophyTableName . "'"); - - // Run the query - $sqlCheckTrophyTable->execute(); - - //Check if any rows exist - if not, create the table, if yes, destroy it first, then create it - $count = $sqlCheckTrophyTable->rowCount(); - - if ($count != 0) { - echo "Deleting exsiting table '" . $trophyTableName . "'...
"; - // Create the query to drop the table - $sqlDropDataTable = "DROP TABLE " . $trophyTableName; - $conn->exec($sqlDropDataTable); // drop the table - echo "Deleted!
Creating new table '" . $trophyTableName . "'...
"; - try { // Create the new table - $conn->query($sqlCreateTrophyTable); - echo "Table '" . $trophyTableName . "' successfully created (trophy data)
"; - } catch (PDOException $e) { - echo $sqlCreateTrophyTable . "Table '" . $trophyTableName . "' successfully created (trophy data)
"; - } catch (PDOException $e) { - echo $sqlCreateTrophyTable . "DONE!
"; ?> diff --git a/admin/db_management/reinitialize.php b/admin/db_management/reinitialise.php similarity index 88% rename from admin/db_management/reinitialize.php rename to admin/db_management/reinitialise.php index d0815cd..71eb4a7 100644 --- a/admin/db_management/reinitialize.php +++ b/admin/db_management/reinitialise.php @@ -6,7 +6,7 @@ - +
diff --git a/admin/user_management/add_safe_admin.php b/admin/user_management/add_safe_admin.php index 53aad43..a43abb9 100644 --- a/admin/user_management/add_safe_admin.php +++ b/admin/user_management/add_safe_admin.php @@ -5,8 +5,7 @@
- - +
@@ -20,7 +19,6 @@ $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - echo "
Connected successfully
"; // Check if the users table exists already @@ -33,9 +31,11 @@ $count = $sqlCheckUserTable->rowCount(); if ($count == 0) { + echo "
Admins table not found! Probably initial setup. Creating...
"; try { $conn->query($sqlCreateAdminTable); - echo "
Table '" . $adminUserTableName . "' successfully created (user data)
"; + echo "
Table '" . $adminUserTableName . "' successfully created (safe admins)
"; + echo "
After we finish creating your user, you will need to use the \"Initialize Databases\" option in the admin panel before you can begin to use your server
";
} catch (PDOException $e) {
echo $sqlCreateUserTable . "
" . $e->getMessage();
}
@@ -49,38 +49,27 @@
$twitch = $_POST["twitch"];
$youtube = $_POST["youtube"];
+ // Gotta check and make sure the user we're creating is an admin
$isAdmin = 0;
if (filter_has_var(INPUT_POST, "isAdmin")) {
$isAdmin = 1;
}
- echo "
";
- echo $username . "
";
- echo $password . "
";
- echo $discord . "
";
- echo $twitch . "
";
- echo $youtube . "
";
-
- echo $isAdmin . "
";
-
+ // Prepare the query
$insert = $conn->prepare("INSERT INTO " . $adminUserTableName . " (username, password, discord, twitch, youtube, isAdmin) VALUES (:username, :password, :discord, :twitch, :youtube, :isAdmin)");
-
+ // Bind parameters to the query
$insert->bindParam(":username", $username);
$insert->bindParam(":password", $password);
$insert->bindParam(":discord", $discord);
$insert->bindParam(":twitch", $twitch);
$insert->bindParam(":youtube", $youtube);
-
$insert->bindParam(":isAdmin", $isAdmin);
+ // Execute
$insert->execute();
- echo "New records created successfully?";
-
-
-
-
+ echo "Safe Admin created successfully!";
} catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage();
diff --git a/admin/user_management/add_user.php b/admin/user_management/add_user.php
index 52544de..09684e5 100644
--- a/admin/user_management/add_user.php
+++ b/admin/user_management/add_user.php
@@ -44,7 +44,6 @@
$insert->bindParam(":isAdmin", $isAdmin);
-
$insert->execute();
if ($isAdmin == 1) {
echo "New admin user \"" . $username . "\" created successfully";
@@ -52,10 +51,6 @@
echo "New user \"" . $username . "\" created successfully";
}
-
-
-
-
} catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage();
}
diff --git a/admin/user_management/create_safe_admin.php b/admin/user_management/create_safe_admin.php
index aa0bd1e..a8e38f1 100644
--- a/admin/user_management/create_safe_admin.php
+++ b/admin/user_management/create_safe_admin.php
@@ -6,9 +6,9 @@
-
+
-
+
@@ -20,33 +20,19 @@