- 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
This commit is contained in:
Taylor Courage 2025-03-05 21:08:39 -05:00
parent 6329d96331
commit b6c2f08731
23 changed files with 750 additions and 146 deletions

View File

@ -17,7 +17,7 @@
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "<p>Connected successfully</p>"; echo "<p>Connected successfully</p>";

View File

@ -17,7 +17,7 @@
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

View File

@ -4,7 +4,7 @@ session_start();
include("../db_config.php"); // Include database stuff include("../db_config.php"); // Include database stuff
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -53,6 +53,7 @@ try { // Try opening the SQL database connection
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>

View File

@ -4,7 +4,7 @@ session_start();
include("../db_config.php"); // Include database stuff include("../db_config.php"); // Include database stuff
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -40,7 +40,7 @@ try { // Try opening the SQL database connection
$userList[] = $result["winner4"]; $userList[] = $result["winner4"];
} }
// Make sure we only have each name once
$userList = array_unique($userList); $userList = array_unique($userList);
// Sort the array to alphabetical order // Sort the array to alphabetical order
sort($userList); sort($userList);

View File

@ -2,8 +2,8 @@
// DB LOGIN DETAILS HERE // DB LOGIN DETAILS HERE
$servername = "127.0.0.1"; $servername = "127.0.0.1";
$username = "USERNAME"; $dbUsername = "USERNAME";
$password = "PASSWORD"; $dbPassword = "PASSWORD";
$dbName = "DBNAME"; $dbName = "DBNAME";
//////////////////////////// DEVELOPER /////////////////////////////// //////////////////////////// DEVELOPER ///////////////////////////////
@ -29,9 +29,6 @@ $gameDataTableName = "games"; // table containing replay data
$tournamentDataTableName = "tournaments"; // tournament data table $tournamentDataTableName = "tournaments"; // tournament data table
$adminUserTableName = "safeadmins"; $adminUserTableName = "safeadmins";
$passwordLength = 8; // default minimum random password length
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -53,8 +50,10 @@ isAdmin BOOL,
username VARCHAR(30) NOT NULL, username VARCHAR(30) NOT NULL,
password VARCHAR(255), password VARCHAR(255),
discord VARCHAR(50), discord VARCHAR(50),
discordLink VARCHAR(150),
twitch VARCHAR(50), twitch VARCHAR(50),
youtube VARCHAR(50), youtube VARCHAR(50),
youtubeLink VARCHAR(150),
userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)"; )";
@ -68,8 +67,10 @@ isAdmin BOOL,
username VARCHAR(30) NOT NULL, username VARCHAR(30) NOT NULL,
password VARCHAR(255), password VARCHAR(255),
discord VARCHAR(50), discord VARCHAR(50),
discordLink VARCHAR(150),
twitch VARCHAR(50), twitch VARCHAR(50),
youtube VARCHAR(50), youtube VARCHAR(50),
youtubeLink VARCHAR(150),
userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP, userCreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)"; )";

View File

@ -12,12 +12,13 @@
<body class="sqlOutput"> <body class="sqlOutput">
<?php <?php
function initialiseDatabase() {
// USER-DEFINED VARIABLES // USER-DEFINED VARIABLES
include("../db_config.php"); // Include database stuff include("../db_config.php"); // Include database stuff
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "<p>Connected successfully</p>"; echo "<p>Connected successfully</p>";
@ -135,6 +136,7 @@
// Tell the user we're done // Tell the user we're done
echo "<p style=\"font-weight:bold\">DONE!</p>"; echo "<p style=\"font-weight:bold\">DONE!</p>";
}
?> ?>

View File

@ -30,19 +30,19 @@ session_start();
include ("db_config.php"); include ("db_config.php");
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_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 } catch (PDOException $e) { // failed connection
echo "SQL connection failed: " . $e->getMessage(); 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 //Check if any rows exist
$count = $sqlCheckAdminTable->rowCount(); $count = $sqlCheckAdminTable->rowCount();

View File

@ -5,6 +5,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/db_management.css" /> <link rel="stylesheet" href="/styles/db_management.css" />
<title>no title</title> <title>no title</title>
</head> </head>
@ -13,63 +14,115 @@
<?php <?php
// USER-DEFINED VARIABLES // USER-DEFINED VARIABLES
include("../db_config.php"); // Include database stuff include("../db_config.php"); // Include database stuff
include("../db_management/initialise.php");
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Check if the users table exists already // Check if the users table exists already
$sqlCheckUserTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'"); $sqlCheckAdminUserTable = $conn->prepare("SHOW TABLES LIKE '" . $adminUserTableName . "'");
// Run the query // Run the query
$sqlCheckUserTable->execute(); $sqlCheckAdminUserTable->execute();
//Check if any rows exist - if not, create the table //Check if any rows exist - if not, create the table
$count = $sqlCheckUserTable->rowCount(); $adminCount = $sqlCheckAdminUserTable->rowCount();
if ($count == 0) { if ($adminCount == 0) {
echo "<p>Admins table not found! Probably initial setup. Creating...</p>"; echo "<p>Admins table not found! This is probably initial setup.</p><p>Creating safe admins table...</p>";
try { try {
$conn->query($sqlCreateAdminTable); $conn->query($sqlCreateAdminTable);
echo "<p>Table '" . $adminUserTableName . "' successfully created (safe admins)</p>"; echo "<p>Table '" . $adminUserTableName . "' successfully created (safe admins)</p>";
echo "<p>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</p>";
} catch (PDOException $e) { } catch (PDOException $e) {
echo $sqlCreateUserTable . "<br>" . $e->getMessage(); echo $sqlCreateUserTable . "<br>" . $e->getMessage();
} }
} }
// Variables for the various input fields // Variables for the various input fields
$username = $_POST["username"]; $username = $_POST["username"];
$password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security
$discord = $_POST["discord"]; $twitch = $_POST["twitch"];
$twitch = $_POST["twitch"]; $discord = $_POST["discord"];
$youtube = $_POST["youtube"]; $discordLink = $_POST["discordLink"];
$youtube = $_POST["youtube"];
$youtubeLink = $_POST["youtubeLink"];
// Gotta check and make sure the user we're creating is an admin // Gotta check and make sure the user we're creating is an admin
$isAdmin = 0; $isAdmin = 0;
if (filter_has_var(INPUT_POST, "isAdmin")) { if (filter_has_var(INPUT_POST, "isAdmin")) {
$isAdmin = 1; $isAdmin = 1;
} }
// Prepare the query // Prepare the query
$insert = $conn->prepare("INSERT INTO " . $adminUserTableName . " (username, password, discord, twitch, youtube, isAdmin) VALUES (:username, :password, :discord, :twitch, :youtube, :isAdmin)"); $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 // Bind parameters to the query
$insert->bindParam(":username", $username); $insert->bindParam(":username", $username);
$insert->bindParam(":password", $password); $insert->bindParam(":password", $password);
$insert->bindParam(":discord", $discord); $insert->bindParam(":discord", $discord);
$insert->bindParam(":twitch", $twitch); $insert->bindParam(":discordLink", $discordLink);
$insert->bindParam(":youtube", $youtube); $insert->bindParam(":twitch", $twitch);
$insert->bindParam(":isAdmin", $isAdmin); $insert->bindParam(":youtube", $youtube);
$insert->bindParam(":youtubeLink", $youtubeLink);
$insert->bindParam(":isAdmin", $isAdmin);
// Execute // Execute
$insert->execute(); $insert->execute();
echo "Safe Admin created successfully!";
// 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 "<p>Users table found</p>";
// 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 "<p>Users table not found! This is probably (still) initial setup. Creating...</p>";
initialiseDatabase();
// Next we're going to copy any safe admins into the users table.
// This will make userlists easier to work with
//echo "<p>Copying users from safe admins...</p>";
//$copyAdmins = $conn->prepare("INSERT INTO " . $userTableName . " SELECT * FROM " . $adminUserTableName);
//$copyAdmins->execute();
//echo "<p>Copied!</p>";
}
if ($userCount == 0) {
} else {
}
echo "Safe Admin created successfully!";
} catch (PDOException $e) { // failed connection } catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage(); echo "Connection failed: " . $e->getMessage();

View File

@ -5,6 +5,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/db_management.css" /> <link rel="stylesheet" href="/styles/db_management.css" />
<title>no title</title> <title>no title</title>
</head> </head>
@ -16,41 +17,76 @@
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Variables for the various input fields // Double-check to make sure the user isn't already in the database, i.e. if the user re-submits the form
$username = $_POST["username"];
$password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security
$discord = $_POST["discord"];
$twitch = $_POST["twitch"];
$youtube = $_POST["youtube"];
$isAdmin = 0; // Check if the user exists
$sqlUserCheck = $conn->prepare("SELECT username FROM " . $userTableName . "");
if (filter_has_var(INPUT_POST, "isAdmin")) { // Execute SQL query
$isAdmin = 1; $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();
// Check if user exists
$insert->bindParam(":username", $username); if (mb_strtolower($_GET["username"]) == mb_strtolower($results["username"])) {
$insert->bindParam(":password", $password); // USER ALREADY EXISTS
$insert->bindParam(":discord", $discord); echo "<div class=userMessage>";
$insert->bindParam(":twitch", $twitch); echo "<p>Fatal error</p>";
$insert->bindParam(":youtube", $youtube); echo "<p>Please go to the home page and try what you were doing again</p>";
echo "<p>&nbsp;</p>";
$insert->bindParam(":isAdmin", $isAdmin); echo "<a href=\"/\" class=\"subNavLink\">HOME</a>";
echo "</div>";
$insert->execute();
if ($isAdmin == 1) {
echo "New admin user \"" . $username . "\" created successfully";
} else { } 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 "<div class=userMessage>";
echo "<p>Account created! You may sign in now.</p>";
echo "<p>&nbsp;</p>";
echo "<a href=\"/\" class=\"subNavLink\">HOME</a>";
echo "<a href=\"/login_page.php\" target=\"dataFrame\" class=\"subNavLink\">SIGN IN</a>";
echo "<p>&nbsp;</p>";
echo "</div>";
}
} }
} catch (PDOException $e) { // failed connection } catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage(); echo "Connection failed: " . $e->getMessage();
} }

View File

@ -4,10 +4,10 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/admin.css" /> <link rel="stylesheet" href="/styles/admin.css" />
<link rel="stylesheet" href="/styles/admin_nav.css" /> <link rel="stylesheet" href="/styles/admin_nav.css" />
<link rel="stylesheet" href="/styles/user_management.css" /> <link rel="stylesheet" href="/styles/user_management.css" />
<?php include ("../db_config.php");?> <!-- Our password-length variable is stored here -->
<script src="/scripts/user_management.js"></script> <script src="/scripts/user_management.js"></script>
<title>ADMIN CREATION FORM</title> <title>ADMIN CREATION FORM</title>
</head> </head>
@ -24,15 +24,19 @@
<label for="username" class="inputLabel" >Username:</label> <label for="username" class="inputLabel" >Username:</label>
<input type="text" id="username" name="username" class="newLine" maxlength="30" required/> <input type="text" id="username" name="username" class="newLine" maxlength="30" required/>
<label for="password" class="inputLabel">Password:</label> <label for="password" class="inputLabel">Password:</label>
<input type="password" id="password" name="password" required/> <input type="password" id="password" name="password" required minlength="6"/>
<input type="checkbox" id="showPassword" name="showPassword" class="passwordOptions" onclick="displayPassword()"/> <input type="checkbox" id="showPassword" name="showPassword" class="passwordOptions" onclick="displayPassword()"/>
<label for="showPassword" class="passwordOptions" id="displayPassword" class="newLine">(show)</label> <label for="showPassword" class="passwordOptions" id="displayPassword" class="newLine">(show)</label>
<label for="discord" class="newLine">Discord:</label> <label for="discord" class="newLine">Discord:</label>
<input type="text" id="discord" name="discord" class="newLine" maxlength="50"/> <input type="text" id="discord" name="discord" class="newLine" maxlength="50"/>
<label for="discord" class="newLine">Discord Link:</label>
<input type="text" id="discordLink" name="discordLink" class="newLine" maxlength="50"/>
<label for="twitch" class="newLine">Twitch:</label> <label for="twitch" class="newLine">Twitch:</label>
<input type="text" id="twitch" name="twitch" class="newLine" maxlength="50" /> <input type="text" id="twitch" name="twitch" class="newLine" maxlength="50" />
<label for="youtube" class="newLine">Youtube:</label> <label for="youtube" class="newLine">Youtube:</label>
<input type="text" id="youtube" name="youtube" class="newLine" maxlength="50" /> <input type="text" id="youtube" name="youtube" class="newLine" maxlength="50" />
<label for="youtube" class="newLine">Youtube Link:</label>
<input type="text" id="youtubeLink" name="youtubeLink" class="newLine" maxlength="50" />
</div> </div>
<hr> <hr>
<!-- THIS DIV IS FOR EXTRA SETTINGS --> <!-- THIS DIV IS FOR EXTRA SETTINGS -->

View File

@ -0,0 +1,133 @@
<?php session_start() ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/db_management.css" />
<title>no title</title>
</head>
<body class="sqlOutput">
<?php
// USER-DEFINED VARIABLES
include("../db_config.php"); // Include database stuff
try { // Try opening the SQL database connection
$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);
// 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 "<p></p>";
if ($_POST["youtube"] != $userInfo["youtube"] && $_POST["youtube"] != "") {
$youtube = $_POST["youtube"];
} else {
$youtube = $userInfo["youtube"];
}
echo $youtube;
echo "<p></p>";
if ($_POST["youtubeLink"] != $userInfo["youtubeLink"] && $_POST["youtubeLink"] != "") {
$youtubeLink = $_POST["youtubeLink"];
} else {
$youtubeLink = $userInfo["youtubeLink"];
}
echo $youtubeLink;
echo "<p></p>";
if ($_POST["discord"] != $userInfo["discord"] && $_POST["discord"] != "") {
$discord = $_POST["discord"];
} else {
$discord = $userInfo["discord"];
}
echo $discord;
echo "<p></p>";
if ($_POST["discordLink"] != $userInfo["discordLink"] && $_POST["discordLink"] != "") {
$discordLink = $_POST["discordLink"];
} else {
$discordLink = $userInfo["discordLink"];
}
echo $discordLink;
echo "<p></p>";
// 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 "<script>window.top.location.href = \"" . $address . "\";</script>";
echo "<p>Account successfully updated</p>";
echo "<p>You should have been redirected to your account. Here's a link:</p>";
echo "<p><a href=\"/user/" . $_SESSION["username"] . " \">My Account</a></p>";
} catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage();
}
$conn = null;
?>
</body>
</html>

View File

@ -4,10 +4,10 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/admin.css" /> <link rel="stylesheet" href="/styles/admin.css" />
<link rel="stylesheet" href="/styles/admin_nav.css" /> <link rel="stylesheet" href="/styles/admin_nav.css" />
<link rel="stylesheet" href="/styles/user_management.css" /> <link rel="stylesheet" href="/styles/user_management.css" />
<?php include ("../db_config.php");?> <!-- Our password-length variable is stored here -->
<script src="/scripts/user_management.js"></script> <script src="/scripts/user_management.js"></script>
<title>USER CREATION FORM</title> <title>USER CREATION FORM</title>
</head> </head>
@ -24,15 +24,19 @@
<label for="username" class="inputLabel" >Username:</label> <label for="username" class="inputLabel" >Username:</label>
<input type="text" id="username" name="username" maxlength="30" required/> <input type="text" id="username" name="username" maxlength="30" required/>
<label for="password" class="inputLabel newLine">Password:</label> <label for="password" class="inputLabel newLine">Password:</label>
<input type="password" id="password" name="password" required/> <input type="password" id="password" name="password" minlength="6" required/>
<input type="checkbox" id="showPassword" name="showPassword" class="passwordOptions" onclick="displayPassword()"/> <input type="checkbox" id="showPassword" name="showPassword" class="passwordOptions" onclick="displayPassword()"/>
<label for="showPassword" class="passwordOptions" id="displayPassword" class="newLine">(show)</label> <label for="showPassword" class="passwordOptions" id="displayPassword" class="newLine">(show)</label>
<label for="discord" class="newLine">Discord:</label> <label for="discord" class="newLine">Discord:</label>
<input type="text" id="discord" name="discord" class="newLine" maxlength="50"/> <input type="text" id="discord" name="discord" class="newLine" maxlength="50"/>
<label for="discord" class="newLine">Discord Link:</label>
<input type="text" id="discordLink" name="discordLink" class="newLine" maxlength="50"/>
<label for="twitch" class="newLine">Twitch:</label> <label for="twitch" class="newLine">Twitch:</label>
<input type="text" id="twitch" name="twitch" class="newLine" maxlength="50" /> <input type="text" id="twitch" name="twitch" class="newLine" maxlength="50" />
<label for="youtube" class="newLine">Youtube:</label> <label for="youtube" class="newLine">Youtube:</label>
<input type="text" id="youtube" name="youtube" class="newLine" maxlength="50" /> <input type="text" id="youtube" name="youtube" class="newLine" maxlength="50" />
<label for="youtube" class="newLine">Youtube Link:</label>
<input type="text" id="youtubeLink" name="youtubeLink" class="newLine" maxlength="50" />
</div> </div>
<hr> <hr>
<!-- THIS DIV IS FOR EXTRA SETTINGS --> <!-- THIS DIV IS FOR EXTRA SETTINGS -->

View File

@ -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 // This grabs the list of users to check and make sure we aren't creating duplicates
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -37,11 +37,11 @@ try { // Try opening the SQL database connection
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="styles/admin.css" /> <link rel="stylesheet" href="/styles/admin.css" />
<link rel="stylesheet" href="styles/admin_nav.css" /> <link rel="stylesheet" href="/styles/admin_nav.css" />
<link rel="stylesheet" href="styles/user_management.css" /> <link rel="stylesheet" href="/styles/user_management.css" />
<?php include ("admin/db_config.php");?> <!-- Our password-length variable is stored here --> <?php include ("admin/db_config.php");?> <!-- Our password-length variable is stored here -->
<script src="scripts/user_management.js"></script> <script src="/scripts/user_management.js"></script>
<title>USER CREATION FORM</title> <title>USER CREATION FORM</title>
<script>var userList = <?php echo json_encode($userList); ?>; // Convert array from PHP to JS</script> <script>var userList = <?php echo json_encode($userList); ?>; // Convert array from PHP to JS</script>
</head> </head>
@ -52,7 +52,7 @@ try { // Try opening the SQL database connection
<p>Get started on your trophy-winning journey with your very own TrojanDestinyRL account!</p> <p>Get started on your trophy-winning journey with your very own TrojanDestinyRL account!</p>
<hr> <hr>
<p></p> <p></p>
<form id="userForm" action="admin/user_management/add_user.php" onsubmit="return verifyInput()" method="POST" target="dataFrame" > <form id="userForm" action="/admin/user_management/add_user.php" onsubmit="return verifyInput()" method="POST" target="dataFrame" >
<!-- THIS DIV IS FOR INPUT --> <!-- THIS DIV IS FOR INPUT -->
<div id="textInputArea"> <div id="textInputArea">
<label for="username" class="inputLabel">Username:</label> <label for="username" class="inputLabel">Username:</label>

View File

@ -25,15 +25,15 @@ session_start();
</thead> </thead>
<tr> <tr>
<td class="divTableLeftColumn">Open</td> <td class="divTableLeftColumn">Open</td>
<td class="divTableRightColumn"><img src="assets/plat3.webp" title="Plat 3" alt="plat 3" width="40px"></td> <td class="divTableRightColumn"><img src="/assets/plat3.webp" title="Plat 3" alt="plat 3" width="40px"></td>
</tr> </tr>
<tr> <tr>
<td class="divTableLeftColumn">Intermediate</td> <td class="divTableLeftColumn">Intermediate</td>
<td class="divTableRightColumn"><img src="assets/champ3.webp" title="Champ 3" alt="champ 3" width="40px"></td> <td class="divTableRightColumn"><img src="/assets/champ3.webp" title="Champ 3" alt="champ 3" width="40px"></td>
</tr> </tr>
<tr> <tr>
<td class="divTableLeftColumn">Main</td> <td class="divTableLeftColumn">Main</td>
<td class="divTableRightColumn"><img src="assets/SSL.webp" title="SSL" alt="Supersonic Legend" width="40px"></td> <td class="divTableRightColumn"><img src="/assets/SSL.webp" title="SSL" alt="Supersonic Legend" width="40px"></td>
</tr> </tr>
</table> </table>

View File

@ -8,7 +8,7 @@ session_start();
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" /> <link rel="stylesheet" href="/styles/primary.css" />
<script src="scripts/tools.js"></script> <script src="/scripts/tools.js"></script>
<title>Trojan's Trophy Room</title> <title>Trojan's Trophy Room</title>
</head> </head>
@ -18,30 +18,31 @@ session_start();
<h4><a href="/giveaway" id="giveawayLink">Giveaway Disclaimer</a></h4> <h4><a href="/giveaway" id="giveawayLink">Giveaway Disclaimer</a></h4>
<h3>Choose a division to see results!</h3> <h3>Choose a division to see results!</h3>
<div class="navPanel"> <div class="navPanel">
<a href="open.html" target="dataFrame" class="navLink">OPEN</a> <a href="/open.html" target="dataFrame" class="navLink">OPEN</a>
<a href="intermediate.html" target="dataFrame" class="navLink">INTERMEDIATE</a> <a href="/intermediate.html" target="dataFrame" class="navLink">INTERMEDIATE</a>
<a href="main.html" target="dataFrame" class="navLink">MAIN</a> <a href="/main.html" target="dataFrame" class="navLink">MAIN</a>
<p class="newLine"></p> <p class="newLine"></p>
<a href="general.html" target="dataFrame" class="navLink">GENERAL (HOME)</a> <a href="/general.html" target="dataFrame" class="navLink">GENERAL (HOME)</a>
</div> </div>
<p>&nbsp;</p> <p>&nbsp;</p>
<iframe src="open.html" name="dataFrame" class="dataFrame" id="dataFrame" onload="resizeIframe(this);"></iframe> <iframe src="/open.html" name="dataFrame" class="dataFrame" id="dataFrame" onload="resizeIframe(this);"></iframe>
<p class="newLine"></p> <p class="newLine"></p>
<p class="newLine"></p> <p class="newLine"></p>
<div class="subNav"> <div class="subNav">
<?php <?php
// Is the user is logged in we'll show them a navigation bar with some fancier options // Is the user is logged in we'll show them a navigation bar with some fancier options
if (isset($_SESSION["userID"])){ if (isset($_SESSION["userID"])){
echo "<a href=\"logout.php \" class=\"subNavLink\">LOGOUT</a>"; echo "<a href=\"/user/" . $_SESSION["username"] . " \" class=\"subNavLink\">ACCOUNT</a>";
echo "<a href=\"admin/data_management/game_form.php \" target=\"dataFrame\" class=\"subNavLink\">ADD GAME DETAILS</a>"; echo "<a href=\"/logout.php \" class=\"subNavLink\">LOGOUT</a>";
echo "<a href=\"/admin/data_management/game_form.php \" target=\"dataFrame\" class=\"subNavLink\">ADD GAME DETAILS</a>";
// Anything we need to show to logged in admins will be below // Anything we need to show to logged in admins will be below
if (isset($_SESSION["isAdmin"]) && $_SESSION["isAdmin"] == 1){ if (isset($_SESSION["isAdmin"]) && $_SESSION["isAdmin"] == 1){
echo "<a href=\"admin/data_management/tourney_form.php \" target=\"dataFrame\" class=\"subNavLink\">ADD A TOURNEY</a>"; echo "<a href=\"/admin/data_management/tourney_form.php \" target=\"dataFrame\" class=\"subNavLink\">ADD A TOURNEY</a>";
echo "<a href=\"admin \" class=\"subNavLink\">ADMIN PANEL</a>"; echo "<a href=\"/admin \" class=\"subNavLink\">ADMIN PANEL</a>";
} }
} else { } else {
echo "<a href=\"login_page.php \" target=\"dataFrame\" class=\"subNavLink\">SIGN IN</a>"; echo "<a href=\"/login_page.php \" target=\"dataFrame\" class=\"subNavLink\">SIGN IN</a>";
echo "<a href=\"create_account.php \" target=\"dataFrame\" class=\"subNavLink\">CREATE AN ACCOUNT</a>"; echo "<a href=\"/create_account.php \" target=\"dataFrame\" class=\"subNavLink\">CREATE AN ACCOUNT</a>";
} }
?> ?>
</div> </div>

View File

@ -20,7 +20,7 @@ session_start();
include("admin/db_config.php"); // Include database stuff include("admin/db_config.php"); // Include database stuff
try { // Try opening the SQL database connection 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 // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

View File

@ -17,13 +17,13 @@ $redirect = $_GET["redirect"];
<body id="loginBody"> <body id="loginBody">
<h3 id="loginNotice">Sign in to continue</h3> <h3 id="loginNotice">Sign in to continue</h3>
<div id="loginPanel"> <div id="loginPanel">
<form id="loginForm" onsubmit="return verifyInput()" action="login.php?redirect=<?php echo $redirect; ?>" method="POST"> <form id="loginForm" onsubmit="return verifyInput()" action="/login.php?redirect=<?php echo $redirect; ?>" method="POST">
<div id="inputArea"> <div id="inputArea">
<label for="username">Username:</label> <label for="username">Username:</label>
<input type="text" name="username" id="username" required> <input type="text" name="username" id="username" required>
<p class="newLine"></p> <p class="newLine"></p>
<label for="password">Password:</label> <label for="password">Password:</label>
<input type="password" name="password" id="password" required> <input type="password" name="password" id="password" minlength="6" required>
<p class="newLine"></p> <p class="newLine"></p>
<label for="showPassword" id="showPasswordLabel">Show Password: &nbsp;</label> <label for="showPassword" id="showPasswordLabel">Show Password: &nbsp;</label>
<input type="checkbox" name="showPassword" id="showPassword" onchange="displayPassword();"> <input type="checkbox" name="showPassword" id="showPassword" onchange="displayPassword();">

View File

@ -32,12 +32,7 @@ function verifyInput() {
return false; return false;
} }
// Check if a password is required, if so, make sure one is entered
var password = document.forms["userForm"]["password"].value; 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 // Ensure the password (if enabled) is at least 6 characters in length
if (!(document.getElementById("none").checked) && password.length < 6) { if (!(document.getElementById("none").checked) && password.length < 6) {

View File

@ -36,3 +36,16 @@
width: 400px; width: 400px;
padding: 5px; padding: 5px;
} }
.userMessage {
text-align: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.userMessage a{
margin: 10px;
}
.subNavLink a {
margin: 10px !important;
}

View File

@ -3,7 +3,12 @@
width: 100%; 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)); background-image: linear-gradient(to right, rgba(0, 0, 255, .8), rgba(255, 165, 0, .8));
padding-top: 2%; padding-top: 2%;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 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);
}

View File

@ -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 { #userFormPanel {
width: 500px; width: 500px;
} }
@ -51,6 +16,128 @@
text-align: center; 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 { #textInputArea {
display: flex; display: flex;
@ -175,7 +262,3 @@
font-size: 90%; font-size: 90%;
} }
.newLine {
width: 100%;
}

175
user/account.php Normal file
View File

@ -0,0 +1,175 @@
<?php
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", $dbUsername, $dbPassword);
// set the PDO error mode to exception
$conn->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();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/data.css" />
<link rel="stylesheet" href="/styles/user_management.css" />
<link rel="stylesheet" href="/styles/db_management.css" />
<title>User Account Management</title>
</head>
<body id="accountDetailsBody">
<div id="accountDetailsPanel">
<h3>Info</h3>
<p class="newLine"></p>
<div class="accountDetailsLeftSide">
<p class="detailsBold">Username:</p>
<p class="detailsBold">Date Joined:</p>
<p class="detailsBold">Total trophies:</p>
<p>&nbsp;By division:</p>
<p>&nbsp;&nbsp;&nbsp;Open:</p>
<p>&nbsp;&nbsp;&nbsp;Intermediate:</p>
<p>&nbsp;&nbsp;&nbsp;Main:</p>
<p>&nbsp;</p>
</div>
<div class="accountDetailsRightSide">
<p><?php echo $username ?></p>
<p><?php echo $dateCreated->format('F j, Y'); ?></p>
<p><?php echo $totalWins; ?></p>
<p>&nbsp;</p>
<p><?php echo $openWins; ?></p>
<p><?php echo $intWins; ?></p>
<p><?php echo $mainWins; ?></p>
<p>&nbsp;</p>
</div>
</div>
<?php
if (mb_strtolower($username) == mb_strtolower($_SESSION["username"])) {
echo ("
<div id=\"accountSocialsPanel\">
<h3>Edit</h3>
<p class=\"newLine\"></p>
<div class=\"accountDetailsLeftSide\">
<p>Twitch (name):</p>
<p>YouTube (name):</p>
<p>YouTube (link):</p>
<p>Discord (name):</p>
<p>Discord (link):</p>
<p>&nbsp;</p>
<p><a href=\"/admin/user_management/change_password.php\" id=\"changePasswordButton\" class=\"disabled\">Change Password</a></p>
<p>(coming soon!)</p>
</div>
<div class=\"accountDetailsRightSide\">
<form id=\"editUserDetails\" action=\"/admin/user_management/edit_user.php\" method=\"post\">
<p><input type=\"text\" placeholder=\"" . $userDetails["twitch"] . "\" id=\"twitch\" name=\"twitch\"></p>
<p><input type=\"text\" placeholder=\"" . $userDetails["youtube"] . "\" id=\"youtube\" name=\"youtube\"></p>
<p><input type=\"text\" placeholder=\"" . $userDetails["youtubeLink"] . "\" id=\"youtubeLink\" name=\"youtubeLink\"></p>
<p><input type=\"text\" placeholder=\"" . $userDetails["discord"] . "\" id=\"discord\" name=\"discord\"></p>
<p><input type=\"text\" placeholder=\"" . $userDetails["discordLink"] . "\" id=\"discordLink\" name=\"discordLink\"></p>
<p>&nbsp;</p>
<div class=\"accountUpdateButton\">
<input type=\"submit\" id=\"submitButton\" value=\"Update\">
</div>
</form>
</div>
</div>
");
} else {
echo ("
<div id=\"accountSocialsPanel\">
<h3>Socials</h3>
<p class=\"newLine\"></p>
<div class=\"accountDetailsLeftSide\">
<p>Twitch:</p>
<p>YouTube:</p>
<p>Discord:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<div class=\"accountDetailsRightSide\">
");
if (isset($userDetails["twitch"]) && $userDetails["twitch"] != "") {
echo ("<p><a href=\"https://twitch.tv/\"" . $userDetails["twitch"] . "> " . $userDetails["twitch"] . "</a></p>");
} else {
echo ("<p>none</p>");
}
if (isset($userDetails["youtube"]) && $userDetails["youtube"] != "") {
if (isset($userDetails["youtubeLink"]) && $userDetails["youtubeLink"] != "") {
echo ("<p><a href=" . $userDetails["youtubeLink"] . "> " . $userDetails["youtube"] . "</a></p>");
} else {
echo ("<p>" . $userDetails["youtube"] . "</a></p>");
}
} else {
echo ("<p>none</p>");
}
if (isset($userDetails["discord"]) && $userDetails["discord"] != "") {
if (isset($userDetails["discordLink"]) && $userDetails["discordLink"] != "") {
echo ("<p><a href=" . $userDetails["discordLink"] . "> " . $userDetails["discord"] . "</a></p>");
} else {
echo ("<p>" . $userDetails["discord"] . "</a></p>");
}
} else {
echo ("<p>none</p>");
}
echo ("
</div>
</div>
");
}
?>
</body>
</html>

77
user/user.php Normal file
View File

@ -0,0 +1,77 @@
<?php
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", $dbUsername, $dbPassword);
// set the PDO error mode to exception
$conn->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();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="/styles/primary.css" />
<link rel="stylesheet" href="/styles/user_management.css" />
<script src="/scripts/tools.js"></script>
<title>My Account - Trojan's Trophy Room</title>
</head>
<body id="body">
<script>getURL();</script>
<div id="contentFrame">
<h1>Trojan's Trophy Room</h1>
<h2 id="adminHeader">My Account</h2>
<?php
if ($userExists) {
echo ("<iframe src=\"/user/account.php?username=" . $_GET["username"] . "\" name=\"dataFrame\" class=\"dataFrame\" id=\"dataFrame\" onload=\"resizeIframe(this);\"></iframe>");
} else {
echo "<p>USER NO EXISTS</p>";
}
?>
<div class="subNav">
<?php
if (isset($_SESSION["isAdmin"]) && $_SESSION["isAdmin"] == 1) {
echo "<a href=\"/admin/\" class=\"subNavLink\" id=\"adminHomeButton\">ADMIN PANEL</a>";
}
?>
<a href="../" class="subNavLink" id="mainHomeButton">HOME</a>
<p class="newLine"></p>
<?php
if (isset($_SESSION["userID"])){
echo "<a href=\"../logout.php?redirect=\" class=\"subNavLink\" id=\"loginButton\">LOGOUT</a>";
}
?>
</div>
</div>
</body>
</html>