2025-03-01 16:02:45 -05:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
?>
|
|
|
|
|
2025-03-01 07:43:59 -05:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
2025-03-01 16:02:45 -05:00
|
|
|
<link rel="stylesheet" href="../styles/primary.css" />
|
2025-03-01 07:43:59 -05:00
|
|
|
<link rel="stylesheet" href="../styles/admin.css" />
|
|
|
|
<link rel="stylesheet" href="../styles/admin_nav.css" />
|
|
|
|
<script src="../scripts/trojan.js"></script>
|
|
|
|
<title>ADMIN PANEL - Trojan's Trophy Room</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body id="body">
|
2025-03-01 16:02:45 -05:00
|
|
|
<script>getURL();</script>
|
2025-03-01 07:43:59 -05:00
|
|
|
<div id="contentFrame">
|
|
|
|
<h1>Trojan's Trophy Room</h1>
|
|
|
|
<h2 id="adminHeader">ADMIN PANEL</h2>
|
2025-03-01 09:58:27 -05:00
|
|
|
|
|
|
|
<?php
|
|
|
|
/* This little bit of code is going to check whether or not we have
|
|
|
|
at least one "safe admin" user - this is someone who isn't gonna be
|
|
|
|
deleted by the (re)initialization script, a 'master administrator'
|
|
|
|
for the program if you like.
|
|
|
|
*/
|
|
|
|
|
|
|
|
include ("db_config.php");
|
|
|
|
|
|
|
|
try { // Try opening the SQL database connection
|
|
|
|
$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);
|
|
|
|
} 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();
|
|
|
|
|
|
|
|
$count = 1;
|
|
|
|
|
|
|
|
// EVENTUALLY WE NEED TO MAKE SURE THE PERSON LOGGED IN IS AN ADMIN
|
|
|
|
|
|
|
|
|
|
|
|
if ($count == 0) { // If no safe admins are found, we'll force creation of one
|
|
|
|
echo "<iframe src=\"user_management/create_safe_admin.php\" name=\"dataFrame\" class=\"dataFrame\" id=\"dataFrame\" onload=\"resizeIframe(this);\"></iframe>";
|
|
|
|
} else { // Otherwise we'll show the nav page
|
2025-03-01 16:02:45 -05:00
|
|
|
if (!isset($_SESSION["userID"])){
|
|
|
|
echo "<iframe src=\"../login_page.php?redirect=admin\" name=\"dataFrame\" class=\"dataFrame\" id=\"dataFrame\" onload=\"resizeIframe(this);\"></iframe>";
|
|
|
|
} else if (isset($_SESSION["userID"]) && $_SESSION["isAdmin"] == 1) {
|
|
|
|
echo "<iframe src=\"admin_nav.php\" name=\"dataFrame\" class=\"dataFrame\" id=\"dataFrame\" onload=\"resizeIframe(this);\"></iframe>";
|
|
|
|
} else {
|
2025-03-01 16:26:23 -05:00
|
|
|
echo "<iframe src=\"not_admin.php\" name=\"dataFrame\" class=\"dataFrame\" id=\"dataFrame\" onload=\"resizeIframe(this);\"></iframe>";
|
2025-03-01 16:02:45 -05:00
|
|
|
}
|
2025-03-01 09:58:27 -05:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
2025-03-01 07:43:59 -05:00
|
|
|
<div id="subNav">
|
2025-03-01 16:26:23 -05:00
|
|
|
<?php
|
|
|
|
if (isset($_SESSION["isAdmin"]) && $_SESSION["isAdmin"] == 1) {
|
|
|
|
echo "<a href=\"./\" class=\"navLink\" id=\"adminHomeButton\">ADMIN HOME</a>";
|
|
|
|
}
|
|
|
|
?>
|
2025-03-01 07:43:59 -05:00
|
|
|
<a href="../" class="navLink" id="mainHomeButton">MAIN HOME</a>
|
2025-03-01 16:02:45 -05:00
|
|
|
<p class="newLine"></p>
|
|
|
|
<?php
|
|
|
|
if (isset($_SESSION["userID"])){
|
|
|
|
echo "<a href=\"../logout.php?redirect=admin\" class=\"navLink\" id=\"logoutButton\">LOGOUT</a>";
|
|
|
|
}
|
|
|
|
?>
|
2025-03-01 07:43:59 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|