Start of tournament page

Added UID (unique ID) to game and tourney entries - this will make for fancier links
This commit is contained in:
FractalParadigm 2025-03-15 08:47:20 -04:00
parent abe6bbc740
commit 7d9db6e4e1
6 changed files with 152 additions and 2 deletions

View File

@ -2,4 +2,4 @@ RewriteEngine on
RewriteRule ^/?user/([a-zA-Z0-9\-\_]+)$ /user/user.php?username=$1 [L,NC]
RewriteRule ^/?tournament/([0-9]+)$ /tournament/tourney.php?tourneyID=$1 [L,NC]
RewriteRule ^/?tournament/([a-zA-Z0-9]+)$ /tournament/tournament.php?tournamentUID=$1 [L,NC]

View File

@ -102,10 +102,12 @@
list($urlPathBlank, $replaysPath, $ballchasingID) = explode("/", $ballchasingPath);
}
// Create a unique ID for the game
$gameUID = uniqid(rand());
// SQL Query to insert data
$insert = $conn->prepare("INSERT INTO " . $gameDataTableName . " (
gameUID,
gameName,
gameDate,
uploadedBy,
@ -128,6 +130,7 @@
ballchasingID,
notes
) VALUES (
:gameUID,
:gameName,
:gameDate,
:uploadedBy,
@ -153,6 +156,7 @@
// Assign variables to SQL command/preparation
$insert->bindValue(":gameUID", $gameUID);
$insert->bindValue(":gameName", $gameName);
$insert->bindValue(":gameDate", $gameDate);
$insert->bindValue(":uploadedBy", $uploadedBy);

View File

@ -54,8 +54,12 @@
$winningTeamName = $_POST["winningTeamName"];
$notes = $_POST["notes"];
// Create a unique ID for the tournament
$tourneyUID = uniqid(rand());
echo "<p>$tourneyName</p>";
echo "<p>$tourneyDate</p>";
echo "<p>$tourneyUID</p>";
echo "<p>$division</p>";
echo "<p>$numPlayers</p>";
echo "<p>$bestOf</p>";
@ -68,6 +72,7 @@
$insert = $conn->prepare("INSERT INTO " . $tournamentDataTableName . " (
tournamentUID,
tournamentName,
tournamentDate,
tournamentDivision,
@ -80,6 +85,7 @@
winner4,
notes
) VALUES (
:tournamentUID,
:tournamentName,
:tournamentDate,
:tournamentDivision,
@ -94,6 +100,7 @@
)");
$insert->bindValue(":tournamentUID", $tourneyUID);
$insert->bindValue(":tournamentName", $tourneyName);
$insert->bindValue(":tournamentDate", $tourneyDate);
$insert->bindValue(":tournamentDivision", $division);

View File

@ -78,6 +78,7 @@ userUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
$sqlCreateDataTable = "
CREATE TABLE " . $gameDataTableName . " (
gameID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
gameUID VARCHAR(40),
gameName VARCHAR(100),
gameDate DATE,
uploadedBy VARCHAR(30),
@ -108,6 +109,7 @@ updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
$sqlCreateTournamentTable = "
CREATE TABLE " . $tournamentDataTableName . " (
tournamentID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
tournamentUID VARCHAR(40),
tournamentName VARCHAR(150),
tournamentDate DATE,
tournamentDivision VARCHAR(20),

View File

@ -0,0 +1,13 @@
#tournamentDisplay {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
border: 1px solid black;
border-radius: 7px;
width: 80%;
margin: auto;
}
/*// MOBILE ////
///////////////*/

124
tournament/tournament.php Normal file
View File

@ -0,0 +1,124 @@
<?php
session_start();
include("../admin/db_config.php");
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);
// Get the division from the page
$tourneyUID = $_GET["tournamentUID"];
// If we want all the data, we don't need to select a division in the SQL query
$sqlGetTourneyInfo = $conn->prepare("SELECT * FROM " . $tournamentDataTableName . " WHERE tournamentUID='" . $tourneyUID . "'");
$sqlGetTourneyInfo->execute();
} catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage();
}
$tourneyResults = $sqlGetTourneyInfo->fetch(PDO::FETCH_ASSOC);
$tourneyExists = false;
if (isset($tourneyResults)) {
if (mb_strtolower($_GET["tournamentUID"]) == mb_strtolower($tourneyResults["tournamentUID"])) {
$tourneyExists = true;
}
}
?>
<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" />
<link rel="stylesheet" href="/styles/tourney_display.css" />
<script src="/scripts/tools.js"></script>
<script>//verifyPageInFrame()</script>
<title>Tournament Details</title>
</head>
<body id="body">
<script>getURL();</script>
<div id="contentFrame">
<img src="/assets/rl_logo_background.svg" alt="Rocket League logo for background" class="backgroundImage">
<div class="header">
<div id="headerLeft">
<img src="/assets/trojan_image_1.png" alt="Trojan Destiny logo" id="headerImage">
</div>
<div id="headerCentre">
<h1 id="headerText"><a href="/" class="plainLinkBlue">TrojanDestinyRL</a></h1>
<div id="youtubeImage" onclick="redirect('this', 'https://www.youtube.com/@TrojanDestinyRL')"><img src="/assets/youtube.svg" alt="youtube logo"></div>
<div id="twitchImage" onclick="redirect('this', 'https://www.twitch.tv/trojandestinyrl')"><img src="/assets/twitch.svg" alt="twitch logo"></div>
<div id="discordImage" onclick="redirect('this', 'https://discord.gg/bzU5fVxCZJ')"><img src="/assets/discord.svg" alt="discord logo"></div>
</div>
<div id="headerRight">
<img src="/assets/trojan_image_2.png" alt="Trojan Destiny logo" id="headerImage">
</div>
</div>
<p></p>
<div id="tournamentDisplay">
<?php
if ($tourneyExists) {
$tourneyName = $tourneyResults["tournamentName"];
$tourneyDate = $tourneyResults["tournamentDate"];
$division = ucfirst($tourneyResults["tournamentDivision"]);
$numPlayers = $tourneyResults["numPlayers"];
$winningTeamName = $tourneyResults["winningTeamName"];
$winner1 = $tourneyResults["winner1"];
$winner2 = $tourneyResults["winner2"];
$winner3 = $tourneyResults["winner3"];
$winner4 = $tourneyResults["winner4"];
// Format date
$tourneyDate = DateTime::createFromFormat('Y-m-d', $tourneyDate);
$tourneyDate = $tourneyDate->format('M j, Y');
echo ("THIS TOURNAMENT EXISTS - DETAILS COMING");
} else {
echo "<div class=\"noUser\">";
echo "<h2>TOURNAMENT NOT FOUND!</h2>";
echo "<p>Double-check your link.</p>";
echo "<p>Sorry!</p>";
echo "<p>&nbsp;</p>";
echo "</div>";
}
?>
</div>
<p></p>
<div class="subNav">
<?php
if (isset($_SESSION["privileges"]) && $_SESSION["privileges"] == 1) {
echo "<a href=\"/admin/\" class=\"subNavLink\" id=\"adminHomeButton\">ADMIN PANEL</a>";
}
?>
<a href="../" class="subNavLink" id="mainHomeButton">HOME</a>
<?php
// If we're showing someone other than who's logged in, offer a link to their own page
if (isset($_SESSION["userID"])){
echo "<a href=\"/user/" . $_SESSION["username"] . " \" class=\"subNavLink\">MY ACCOUNT</a>";
}
?>
<p class="newLine"></p>
<?php
// If someone is logged in, give them the opportunity to log out
if (isset($_SESSION["userID"])){
echo "<a href=\"../user/logout.php?redirect=\" class=\"subNavLink\" id=\"loginButton\">LOGOUT</a>";
} else {
echo "<a href=\"/user/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=\"/ \" class=\"subNavLink\">HOME</a>";
}
?>
</div>
</div>
</body>
</html>