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 any rows exist
$count = $sqlCheckAdminTable->rowCount();
/* This if-statement controls the display of the admin page
// First we check if there's actually gonna be an admin user
// - we do this by checking the safe-admin database, because
// if there's at least one user there, they would have been
// copied into the primary user database upon initialization
//
// Then we check if the person is logged in or not - if not,
// we re-direct them to the login page, where we'll be
// brought back after logging in
//
// We are also checking if the person is an admin user -
// if they are NOT, then we show the 'not_admin' page,
// telling the user they're not allowed to view the content
*/
if ($count == 0) { // If no safe admins are found, we'll force creation of one
echo "
";
} else { // Otherwise we'll show the nav page
if (!isset($_SESSION["userID"])){
echo "
";
} else if (isset($_SESSION["userID"]) && $_SESSION["privileges"] == 1) {
echo "
";
} else {
echo "
";
}
}
?>