From b6c2f087311fe9b4990d526e7a555ddba819403f Mon Sep 17 00:00:00 2001 From: Taylor Courage Date: Wed, 5 Mar 2025 21:08:39 -0500 Subject: [PATCH] - Added a "My Account" page - Somewhat basic but works. Probably a lot of bugs still - Re-worked databases to add Discord and YouTube links as separate entries --- admin/data_management/add_game.php | 2 +- admin/data_management/add_tourney.php | 2 +- admin/data_management/game_form.php | 3 +- admin/data_management/tourney_form.php | 4 +- admin/db_config.php | 11 +- admin/db_management/initialise.php | 4 +- admin/index.php | 14 +- admin/user_management/add_safe_admin.php | 113 +++++++++---- admin/user_management/add_user.php | 86 +++++++--- admin/user_management/create_safe_admin.php | 8 +- admin/user_management/edit_user.php | 133 +++++++++++++++ admin/user_management/user_form.php | 8 +- create_account.php | 12 +- general.php | 6 +- index.php | 25 +-- login.php | 2 +- login_page.php | 4 +- scripts/user_management.js | 5 - styles/db_management.css | 13 ++ styles/primary.css | 28 +++- styles/user_management.css | 161 +++++++++++++----- user/account.php | 175 ++++++++++++++++++++ user/user.php | 77 +++++++++ 23 files changed, 750 insertions(+), 146 deletions(-) create mode 100644 admin/user_management/edit_user.php create mode 100644 user/account.php create mode 100644 user/user.php diff --git a/admin/data_management/add_game.php b/admin/data_management/add_game.php index bea9088..3443f97 100644 --- a/admin/data_management/add_game.php +++ b/admin/data_management/add_game.php @@ -17,7 +17,7 @@ try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "

Connected successfully

"; diff --git a/admin/data_management/add_tourney.php b/admin/data_management/add_tourney.php index 8399606..5a46d42 100644 --- a/admin/data_management/add_tourney.php +++ b/admin/data_management/add_tourney.php @@ -17,7 +17,7 @@ try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/admin/data_management/game_form.php b/admin/data_management/game_form.php index 8d3862e..537f64d 100644 --- a/admin/data_management/game_form.php +++ b/admin/data_management/game_form.php @@ -4,7 +4,7 @@ session_start(); include("../db_config.php"); // Include database stuff try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -53,6 +53,7 @@ try { // Try opening the SQL database connection } ?> + diff --git a/admin/data_management/tourney_form.php b/admin/data_management/tourney_form.php index 5c89ebc..5c166e1 100644 --- a/admin/data_management/tourney_form.php +++ b/admin/data_management/tourney_form.php @@ -4,7 +4,7 @@ session_start(); include("../db_config.php"); // Include database stuff try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -40,7 +40,7 @@ try { // Try opening the SQL database connection $userList[] = $result["winner4"]; } - + // Make sure we only have each name once $userList = array_unique($userList); // Sort the array to alphabetical order sort($userList); diff --git a/admin/db_config.php b/admin/db_config.php index 5422fdf..950955f 100644 --- a/admin/db_config.php +++ b/admin/db_config.php @@ -2,8 +2,8 @@ // DB LOGIN DETAILS HERE $servername = "127.0.0.1"; -$username = "USERNAME"; -$password = "PASSWORD"; +$dbUsername = "USERNAME"; +$dbPassword = "PASSWORD"; $dbName = "DBNAME"; //////////////////////////// DEVELOPER /////////////////////////////// @@ -29,9 +29,6 @@ $gameDataTableName = "games"; // table containing replay data $tournamentDataTableName = "tournaments"; // tournament data table $adminUserTableName = "safeadmins"; -$passwordLength = 8; // default minimum random password length - - //////////////////////////////////////////////////////////////////////////// @@ -53,8 +50,10 @@ isAdmin BOOL, username VARCHAR(30) NOT NULL, password VARCHAR(255), discord VARCHAR(50), +discordLink VARCHAR(150), twitch VARCHAR(50), youtube VARCHAR(50), +youtubeLink VARCHAR(150), userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )"; @@ -68,8 +67,10 @@ isAdmin BOOL, username VARCHAR(30) NOT NULL, password VARCHAR(255), discord VARCHAR(50), +discordLink VARCHAR(150), twitch VARCHAR(50), youtube VARCHAR(50), +youtubeLink VARCHAR(150), userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )"; diff --git a/admin/db_management/initialise.php b/admin/db_management/initialise.php index 84c8a34..ee57207 100644 --- a/admin/db_management/initialise.php +++ b/admin/db_management/initialise.php @@ -12,12 +12,13 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "

Connected successfully

"; @@ -135,6 +136,7 @@ // Tell the user we're done echo "

DONE!

"; +} ?> diff --git a/admin/index.php b/admin/index.php index 3162969..fa197c8 100644 --- a/admin/index.php +++ b/admin/index.php @@ -30,19 +30,19 @@ session_start(); include ("db_config.php"); try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + // Check if the admin table exists + $sqlCheckAdminTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'"); + + // Run the query + $sqlCheckAdminTable->execute(); + } catch (PDOException $e) { // failed connection echo "SQL connection failed: " . $e->getMessage(); } - // Check if the admin table exists - $sqlCheckAdminTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'"); - - // Run the query - $sqlCheckAdminTable->execute(); - //Check if any rows exist $count = $sqlCheckAdminTable->rowCount(); diff --git a/admin/user_management/add_safe_admin.php b/admin/user_management/add_safe_admin.php index b47a773..66a27e8 100644 --- a/admin/user_management/add_safe_admin.php +++ b/admin/user_management/add_safe_admin.php @@ -5,6 +5,7 @@ + no title @@ -13,63 +14,115 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Check if the users table exists already - $sqlCheckUserTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'"); + $sqlCheckAdminUserTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'"); // Run the query - $sqlCheckUserTable->execute(); + $sqlCheckAdminUserTable->execute(); //Check if any rows exist - if not, create the table - $count = $sqlCheckUserTable->rowCount(); + $adminCount = $sqlCheckAdminUserTable->rowCount(); - if ($count == 0) { - echo "

Admins table not found! Probably initial setup. Creating...

"; + if ($adminCount == 0) { + echo "

Admins table not found! This is probably initial setup.

Creating safe admins table...

"; try { $conn->query($sqlCreateAdminTable); 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(); } } - // Variables for the various input fields - $username = $_POST["username"]; - $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security - $discord = $_POST["discord"]; - $twitch = $_POST["twitch"]; - $youtube = $_POST["youtube"]; + // Variables for the various input fields + $username = $_POST["username"]; + $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security + $twitch = $_POST["twitch"]; + $discord = $_POST["discord"]; + $discordLink = $_POST["discordLink"]; + $youtube = $_POST["youtube"]; + $youtubeLink = $_POST["youtubeLink"]; - // Gotta check and make sure the user we're creating is an admin - $isAdmin = 0; + // Gotta check and make sure the user we're creating is an admin + $isAdmin = 0; - if (filter_has_var(INPUT_POST, "isAdmin")) { - $isAdmin = 1; - } + if (filter_has_var(INPUT_POST, "isAdmin")) { + $isAdmin = 1; + } - // Prepare the query - $insert = $conn->prepare("INSERT INTO " . $adminUserTableName . " (username, password, discord, twitch, youtube, isAdmin) VALUES (:username, :password, :discord, :twitch, :youtube, :isAdmin)"); + // Prepare the query + $insert = $conn->prepare("INSERT INTO " . $adminUserTableName . " (username, password, discord, discordLink, twitch, youtube, youtubeLink, isAdmin) VALUES (:username, :password, :discord, :discordLink, :twitch, :youtube, :youtubeLink, :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); + // Bind parameters to the query + $insert->bindParam(":username", $username); + $insert->bindParam(":password", $password); + $insert->bindParam(":discord", $discord); + $insert->bindParam(":discordLink", $discordLink); + $insert->bindParam(":twitch", $twitch); + $insert->bindParam(":youtube", $youtube); + $insert->bindParam(":youtubeLink", $youtubeLink); + $insert->bindParam(":isAdmin", $isAdmin); - // Execute - $insert->execute(); - echo "Safe Admin created successfully!"; + // Execute + $insert->execute(); + + // Check if users table exists, if not run the initialize script, otherwise just make the user + + $sqlCheckUserTable = $conn->prepare("SHOW TABLES LIKE " . $userTableName); + + // Run the query, if the table doesn't exist, initialize the database first + if ($sqlCheckUserTable !== false && $sqlCheckUserTable->rowCount() > 0) { + echo "

Users table found

"; + + // Now add them to the regular users table as well + // Prepare the query + $insert = $conn->prepare("INSERT INTO " . $userTableName . " (username, password, discord, discordLink, twitch, youtube, youtubeLink, isAdmin) VALUES (:username, :password, :discord, :discordLink, :twitch, :youtube, :youtubeLink, :isAdmin)"); + + // Bind parameters to the query + $insert->bindParam(":username", $username); + $insert->bindParam(":password", $password); + $insert->bindParam(":discord", $discord); + $insert->bindParam(":discordLink", $discordLink); + $insert->bindParam(":twitch", $twitch); + $insert->bindParam(":youtube", $youtube); + $insert->bindParam(":youtubeLink", $youtubeLink); + $insert->bindParam(":isAdmin", $isAdmin); + + // Execute + $insert->execute(); + } else { + echo "

Users table not found! This is probably (still) initial setup. Creating...

"; + + initialiseDatabase(); + + + // Next we're going to copy any safe admins into the users table. + // This will make userlists easier to work with + //echo "

Copying users from safe admins...

"; + //$copyAdmins = $conn->prepare("INSERT INTO " . $userTableName . " SELECT * FROM " . $adminUserTableName); + + //$copyAdmins->execute(); + //echo "

Copied!

"; + } + + + if ($userCount == 0) { + } else { + } + + + + + 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 04f6698..abba567 100644 --- a/admin/user_management/add_user.php +++ b/admin/user_management/add_user.php @@ -5,6 +5,7 @@ + no title @@ -16,41 +17,76 @@ try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - // Variables for the various input fields - $username = $_POST["username"]; - $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security - $discord = $_POST["discord"]; - $twitch = $_POST["twitch"]; - $youtube = $_POST["youtube"]; + // Double-check to make sure the user isn't already in the database, i.e. if the user re-submits the form - $isAdmin = 0; + // Check if the user exists + $sqlUserCheck = $conn->prepare("SELECT username FROM " . $userTableName . ""); - if (filter_has_var(INPUT_POST, "isAdmin")) { - $isAdmin = 1; - } + // Execute SQL query + $sqlUserCheck->execute(); - $insert = $conn->prepare("INSERT INTO " . $userTableName . " (username, password, discord, twitch, youtube, isAdmin) VALUES (:username, :password, :discord, :twitch, :youtube, :isAdmin)"); + // Get results from the USERS table + $results = $sqlUserCheck->fetch(); - - $insert->bindParam(":username", $username); - $insert->bindParam(":password", $password); - $insert->bindParam(":discord", $discord); - $insert->bindParam(":twitch", $twitch); - $insert->bindParam(":youtube", $youtube); - - $insert->bindParam(":isAdmin", $isAdmin); - - $insert->execute(); - if ($isAdmin == 1) { - echo "New admin user \"" . $username . "\" created successfully"; + // Check if user exists + if (mb_strtolower($_GET["username"]) == mb_strtolower($results["username"])) { + // USER ALREADY EXISTS + echo "
"; + echo "

Fatal error

"; + echo "

Please go to the home page and try what you were doing again

"; + echo "

 

"; + echo "HOME"; + echo "
"; } else { - echo "New user \"" . $username . "\" created successfully"; + // USER DOES NOT EXIST + // Variables for the various input fields + $username = $_POST["username"]; + $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security + $discord = $_POST["discord"]; + $discordLink = $_POST["discordLink"]; + $twitch = $_POST["twitch"]; + $youtube = $_POST["youtube"]; + $youtubeLink = $_POST["youtubeLink"]; + + $isAdmin = 0; + + if (filter_has_var(INPUT_POST, "isAdmin")) { + $isAdmin = 1; + } + + $insert = $conn->prepare("INSERT INTO " . $userTableName . " (username, password, discord, discordLink, twitch, youtube, youtubeLink, isAdmin) VALUES (:username, :password, :discord, :discordLink, :twitch, :youtube, :youtubeLink, :isAdmin)"); + + + $insert->bindParam(":username", $username); + $insert->bindParam(":password", $password); + $insert->bindParam(":discord", $discord); + $insert->bindParam(":discordLink", $discordLink); + $insert->bindParam(":twitch", $twitch); + $insert->bindParam(":youtube", $youtube); + $insert->bindParam(":youtubeLink", $youtubeLink); + + $insert->bindParam(":isAdmin", $isAdmin); + + $insert->execute(); + if ($isAdmin == 1) { + echo "New admin user \"" . $username . "\" created successfully"; + } else { + echo "
"; + echo "

Account created! You may sign in now.

"; + echo "

 

"; + echo "HOME"; + echo "SIGN IN"; + echo "

 

"; + echo "
"; + } + } + } 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 5bab0d0..638c2eb 100644 --- a/admin/user_management/create_safe_admin.php +++ b/admin/user_management/create_safe_admin.php @@ -4,10 +4,10 @@ + - ADMIN CREATION FORM @@ -24,15 +24,19 @@ - + + + + +
diff --git a/admin/user_management/edit_user.php b/admin/user_management/edit_user.php new file mode 100644 index 0000000..316026f --- /dev/null +++ b/admin/user_management/edit_user.php @@ -0,0 +1,133 @@ + + + + + + + + + + + no title + + + + setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + + // Grab session username to make sure we're updating the person logged in + $username = $_SESSION["username"]; + + + // Grab the existing data, so we can only update the things that got updated + $sqlGetUserInfo = $conn->prepare("SELECT * FROM " . $userTableName . " WHERE username=\"" . $username . "\""); + $sqlGetUserInfo->execute(); + + $userInfo = $sqlGetUserInfo->fetch(); // fetch row + + // These IF blocks check if the data entered is different from the data already in the DB + // If the information is the same then we copy the stuff over, otherwise write it + + if ($_POST["twitch"] != $userInfo["twitch"] && $_POST["twitch"] != "") { + $twitch = $_POST["twitch"]; + } else { + $twitch = $userInfo["twitch"]; + } + echo $twitch; + echo "

"; + + if ($_POST["youtube"] != $userInfo["youtube"] && $_POST["youtube"] != "") { + $youtube = $_POST["youtube"]; + } else { + $youtube = $userInfo["youtube"]; + } + echo $youtube; + echo "

"; + + if ($_POST["youtubeLink"] != $userInfo["youtubeLink"] && $_POST["youtubeLink"] != "") { + $youtubeLink = $_POST["youtubeLink"]; + } else { + $youtubeLink = $userInfo["youtubeLink"]; + } + echo $youtubeLink; + echo "

"; + + if ($_POST["discord"] != $userInfo["discord"] && $_POST["discord"] != "") { + $discord = $_POST["discord"]; + } else { + $discord = $userInfo["discord"]; + } + echo $discord; + echo "

"; + + if ($_POST["discordLink"] != $userInfo["discordLink"] && $_POST["discordLink"] != "") { + $discordLink = $_POST["discordLink"]; + } else { + $discordLink = $userInfo["discordLink"]; + } + echo $discordLink; + echo "

"; + + + + // Prepare the command + $update = $conn->prepare("UPDATE " . $userTableName . " SET + twitch = :twitch, + youtube = :youtube, + youtubeLink = :youtubeLink, + discord = :discord, + discordLink = :discordLink + WHERE username = :username + "); + + // Bind parameters to query + $update->bindParam(":username", $username); + $update->bindParam(":twitch", $twitch); + $update->bindParam(":youtube", $youtube); + $update->bindParam(":youtubeLink", $youtubeLink); + $update->bindParam(":discord", $discord); + $update->bindParam(":discordLink", $discordLink); + + $update->execute(); // Execute query + + + // Function from StackOverflow used to get the base URL, to which we append + // the redirect (where the user came from) + function url(){ + return sprintf( + "%s://%s/user/%s", + isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', + $_SERVER['SERVER_NAME'], + $_SESSION["username"] + ); + } + + $address = url(); + + // Redirect user back to their page + echo ""; + + echo "

Account successfully updated

"; + echo "

You should have been redirected to your account. Here's a link:

"; + echo "

My Account

"; + + + } catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); + } + + $conn = null; + + ?> + + + + \ No newline at end of file diff --git a/admin/user_management/user_form.php b/admin/user_management/user_form.php index c4c576a..0601b54 100644 --- a/admin/user_management/user_form.php +++ b/admin/user_management/user_form.php @@ -4,10 +4,10 @@ + - USER CREATION FORM @@ -24,15 +24,19 @@ - + + + + +
diff --git a/create_account.php b/create_account.php index 162c585..59938ce 100644 --- a/create_account.php +++ b/create_account.php @@ -4,7 +4,7 @@ include("admin/db_config.php"); // Include database // This grabs the list of users to check and make sure we aren't creating duplicates try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -37,11 +37,11 @@ try { // Try opening the SQL database connection - - - + + + - + USER CREATION FORM @@ -52,7 +52,7 @@ try { // Try opening the SQL database connection

Get started on your trophy-winning journey with your very own TrojanDestinyRL account!


-
+
diff --git a/general.php b/general.php index 7a70b8f..9aff88f 100644 --- a/general.php +++ b/general.php @@ -25,15 +25,15 @@ session_start(); Open - plat 3 + plat 3 Intermediate - champ 3 + champ 3 Main - Supersonic Legend + Supersonic Legend diff --git a/index.php b/index.php index 950c473..fa8b658 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,7 @@ session_start(); - + Trojan's Trophy Room @@ -18,30 +18,31 @@ session_start();

Giveaway Disclaimer

Choose a division to see results!

 

- +

diff --git a/login.php b/login.php index fa7bdb9..45cea80 100644 --- a/login.php +++ b/login.php @@ -20,7 +20,7 @@ session_start(); include("admin/db_config.php"); // Include database stuff try { // Try opening the SQL database connection - $conn = new PDO("mysql:host=$servername; dbname=$dbName", $username, $password); + $conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/login_page.php b/login_page.php index c03509d..8303b9d 100644 --- a/login_page.php +++ b/login_page.php @@ -17,13 +17,13 @@ $redirect = $_GET["redirect"];

Sign in to continue

- +

- +

diff --git a/scripts/user_management.js b/scripts/user_management.js index adf0c11..c4ed69a 100644 --- a/scripts/user_management.js +++ b/scripts/user_management.js @@ -32,12 +32,7 @@ function verifyInput() { return false; } - // Check if a password is required, if so, make sure one is entered var password = document.forms["userForm"]["password"].value; - if (!(document.getElementById("none").checked) && password == "") { - alert ("Must enter a password! Or select \"None\" for no password (not available for administrator accounts)."); - return false; - } // Ensure the password (if enabled) is at least 6 characters in length if (!(document.getElementById("none").checked) && password.length < 6) { diff --git a/styles/db_management.css b/styles/db_management.css index 37315ca..65b4f5c 100644 --- a/styles/db_management.css +++ b/styles/db_management.css @@ -35,4 +35,17 @@ border-radius: 5px; width: 400px; padding: 5px; +} + +.userMessage { + text-align: center; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} + +.userMessage a{ + margin: 10px; +} + +.subNavLink a { + margin: 10px !important; } \ No newline at end of file diff --git a/styles/primary.css b/styles/primary.css index 0a5b3e4..44ad748 100644 --- a/styles/primary.css +++ b/styles/primary.css @@ -3,7 +3,12 @@ width: 100%; } -#body { +.disabled { + pointer-events: none; + cursor: default; +} + + #body { background-image: linear-gradient(to right, rgba(0, 0, 255, .8), rgba(255, 165, 0, .8)); padding-top: 2%; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; @@ -139,6 +144,27 @@ For all the things at the bottom of the page; log in/out, 'my account', etc. } +.submitButton input[type="submit"] { + margin: auto; + padding: 8px 25px; + font-size: 150%; + font-weight: bold; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background-color: rgba(255, 255, 255, 0); + border-radius: 6px; + border: 1px solid blue; + box-shadow: 0px 2px 4px; +} + +.submitButton input[type="submit"]:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} + +.submitButton input[type="submit"]:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} diff --git a/styles/user_management.css b/styles/user_management.css index c66e7c7..3a5942c 100644 --- a/styles/user_management.css +++ b/styles/user_management.css @@ -1,38 +1,3 @@ -#confirmButton { - position: relative; - flex-wrap: wrap; - display: flex; - justify-content: center; - font-weight: bold; - border: 1px solid blue; - border-radius: 3px; - box-shadow: 0px 2px 4px; - text-decoration: none; - color: black; - width: 100px; - padding: 10px; - padding-left: 30px; - padding-right: 30px; - margin: auto; -} - -#confirmButton:hover { - color: black; - background-color: rgba(255, 165, 0, .6); -} - -#confirmButton:active { - box-shadow: 0px 0px 2px; - transform: translateY(2px); -} - -.sqlOutput { - border: 1px solid black; - border-radius: 5px; - width: 400px; - padding: 5px; -} - #userFormPanel { width: 500px; } @@ -51,6 +16,128 @@ text-align: center; } +#accountDetailsBody { + width: 750px; + display: flex; + flex-direction: row; + margin-bottom: 20px; +} + + +#accountDetailsPanel { + display: flex; + flex-direction: row; + flex-wrap: wrap; + width: 45%; + border: 1px solid black; + border-radius: 3px; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + margin-right: 2%; + padding: 5px; + padding-bottom: 25px; + margin: 0 auto; +} + +#accountSocialsPanel { + display: flex; + flex-direction: row; + flex-wrap: wrap; + width: 45%; + border: 1px solid black; + border-radius: 3px; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + margin-right: 2%; + padding: 5px; + padding-bottom: 25px; + margin: 0 auto; +} + +#accountSocialsPanel p { + height: 25px; +} +#accountDetailsPanel p { + height: 25px; +} + +#accountDetailsPanel h3 { + text-align: center; +} +#accountSocialsPanel h3 { + text-align: center; +} + +.accountDetailsLeftSide { + width: 40%; + text-align: left; + padding-left: 10%; +} + +.accountDetailsRightSide { + width: 40%; + text-align: right; + padding-right: 10%; + justify-content: right; +} + +.detailsBold { + font-weight: bold; +} + +#editUserDetails input[type="text"] { + text-align: right; +} + +#editUserDetails input[type="text"]::placeholder { + text-align: right; +} + + +.accountUpdateButton input[type="submit"] { + margin: auto; + padding: 5px 10px; + font-weight: 600; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background-color: rgba(255, 255, 255, 0); + border-radius: 3px; + border: 1px solid blue; + box-shadow: 0px 2px 4px; +} + +.accountUpdateButton input[type="submit"]:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} + +.accountUpdateButton input[type="submit"]:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} + +#changePasswordButton { + margin: auto; + padding: 5px 10px; + font-weight: 600; + font-size: 75%; + text-decoration: none; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background-color: rgba(255, 255, 255, 0); + border-radius: 3px; + border: 1px solid blue; + box-shadow: 0px 2px 4px; + color: black; +} + +#changePasswordButton:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} + +#changePasswordButton:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} + + #textInputArea { display: flex; @@ -175,7 +262,3 @@ font-size: 90%; } - -.newLine { - width: 100%; -} diff --git a/user/account.php b/user/account.php new file mode 100644 index 0000000..b7d543c --- /dev/null +++ b/user/account.php @@ -0,0 +1,175 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $username = $_GET["username"]; + + $sqlGetUserDetails = $conn->prepare("SELECT * FROM " . $userTableName . " HAVING username=\"" . $username . "\""); + //$sqlGetGameDetails = $conn->prepare("SELECT"); + $sqlGetTourneyDetails = $conn->prepare("SELECT winner1,winner2,winner3,winner4,tournamentDivision FROM " . $tournamentDataTableName . " HAVING winner1=\"" . $username . "\" OR winner2=\"" . $username . "\" OR winner3=\"" . $username . "\" OR winner4=\"" . $username . "\""); + + // Execute SQL query + $sqlGetUserDetails->execute(); + $sqlGetTourneyDetails->execute(); + + // Get user creation date + $userDetails = $sqlGetUserDetails->fetch(); + $dateCreated = new DateTime($userDetails["userCreated"]); + + // Get tournament details + $tourneyDetails = $sqlGetTourneyDetails->fetchAll(PDO::FETCH_ASSOC); + + // Variables to count wins + $mainWins = 0; // main division + $intWins = 0; // intermediate division + $openWins = 0; // open division + foreach ($tourneyDetails as $tourneyResult) { + if ($tourneyResult["tournamentDivision"] == "main") { + $mainWins++; + } else if ($tourneyResult["tournamentDivision"] == "intermediate") { + $intWins++; + } else if ($tourneyResult["tournamentDivision"] == "open") { + $openWins++; + } + } + $totalWins = $mainWins + $intWins + $openWins; + + // Set the displayed username to what the user signed up with + $username = $userDetails["username"]; + + +} catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); +} +?> + + + + + + + + + + + + + + User Account Management + + + +
+

Info

+

+
+

Username:

+

Date Joined:

+

Total trophies:

+

 By division:

+

   Open:

+

   Intermediate:

+

   Main:

+

 

+
+
+

+

format('F j, Y'); ?>

+

+

 

+

+

+

+

 

+
+
+ +

Edit

+

+
+

Twitch (name):

+

YouTube (name):

+

YouTube (link):

+

Discord (name):

+

Discord (link):

+

 

+

Change Password

+

(coming soon!)

+
+
+ +

+

+

+

+

+

 

+
+ +
+ +
+
+ "); + } else { + echo (" +
+

Socials

+

+
+

Twitch:

+

YouTube:

+

Discord:

+

 

+

 

+

 

+

 

+

 

+
+
+ "); + if (isset($userDetails["twitch"]) && $userDetails["twitch"] != "") { + echo ("

" . $userDetails["twitch"] . "

"); + } else { + echo ("

none

"); + } + + if (isset($userDetails["youtube"]) && $userDetails["youtube"] != "") { + if (isset($userDetails["youtubeLink"]) && $userDetails["youtubeLink"] != "") { + echo ("

" . $userDetails["youtube"] . "

"); + } else { + echo ("

" . $userDetails["youtube"] . "

"); + } + } else { + echo ("

none

"); + } + + if (isset($userDetails["discord"]) && $userDetails["discord"] != "") { + if (isset($userDetails["discordLink"]) && $userDetails["discordLink"] != "") { + echo ("

" . $userDetails["discord"] . "

"); + } else { + echo ("

" . $userDetails["discord"] . "

"); + } + } else { + echo ("

none

"); + } + + + echo (" +
+
+ "); + } + ?> + + + \ No newline at end of file diff --git a/user/user.php b/user/user.php new file mode 100644 index 0000000..691c862 --- /dev/null +++ b/user/user.php @@ -0,0 +1,77 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // Check if the user exists + $sqlGetUserList = $conn->prepare("SELECT username FROM " . $userTableName . " WHERE username=\"" . $_GET["username"] . "\""); + + + // Execute SQL query + $sqlGetUserList->execute(); + + // Get results from the USERS table + $results = $sqlGetUserList->fetch(); + + // Check if user exists + if (mb_strtolower($_GET["username"]) == mb_strtolower($results["username"])) { + $userExists = true; + } else { + $userExists = false; + + } + + +} catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); +} + +?> + + + + + + + + + + + My Account - Trojan's Trophy Room + + + + +
+

Trojan's Trophy Room

+

My Account

+ "); + } else { + echo "

USER NO EXISTS

"; + } + ?> + + +
+ + \ No newline at end of file