diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bbb85b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +admin/dev_db_config.php diff --git a/admin/index.php b/admin/index.php index adda3da..a9fd501 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,9 +1,14 @@ + + + @@ -11,6 +16,7 @@ +

Trojan's Trophy Room

ADMIN PANEL

@@ -49,15 +55,26 @@ if ($count == 0) { // If no safe admins are found, we'll force creation of one echo ""; } else { // Otherwise we'll show the nav page - echo ""; + if (!isset($_SESSION["userID"])){ + echo ""; + } else if (isset($_SESSION["userID"]) && $_SESSION["isAdmin"] == 1) { + echo ""; + } else { + echo ""; + } } - ?>
diff --git a/admin/user_management/add_user.php b/admin/user_management/add_user.php index bccf432..f268137 100644 --- a/admin/user_management/add_user.php +++ b/admin/user_management/add_user.php @@ -26,7 +26,7 @@ // Variables for the various input fields $username = $_POST["username"]; $password = password_hash($_POST["password"], PASSWORD_DEFAULT); // Hash the password for security - $discord = ""; + $discord = $_POST["discord"]; $twitch = $_POST["twitch"]; $youtube = $_POST["youtube"]; @@ -36,11 +36,6 @@ $isAdmin = 1; } - echo "

Is Admin? " . $isAdmin . "

"; - - if (isset($_POST["discord"])) { - $discord = $_POST["discord"]; - } echo "
"; echo $username . "
"; diff --git a/admin/user_management/user_management.js b/admin/user_management/user_management.js index 3c0d18d..4eaf9ce 100644 --- a/admin/user_management/user_management.js +++ b/admin/user_management/user_management.js @@ -89,4 +89,14 @@ function verifyInput() { alert ("Password must have a minimum length of 6 characters."); return false; } +} + +function displayPassword() { + // This will check to see if we want the password visible, and sets it as such + console.log("loaded usermanagement"); + if (document.getElementById("showPassword").checked) { + document.getElementById("password").type = "text"; + } else if (!(document.getElementById("showPassword").checked)) { + document.getElementById("password").type = "password"; + } } \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..6e084aa --- /dev/null +++ b/index.php @@ -0,0 +1,44 @@ + + + + + + + + + + Trojan's Trophy Room + + + +
+

Trojan's Trophy Room

+

Choose a division to see results!

+ +

 

+ +

+

+ + + +
+ + + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..a7924c5 --- /dev/null +++ b/login.php @@ -0,0 +1,89 @@ + + + + + + + + + + + + + no title + + + + setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // Get username and password out of the POST data + $username = $_POST["username"]; + $password = $_POST["password"]; + + + + // THIS SHOULD BE MADE MORE EFFICIENT WITH ONLY ONE QUERY IF POSSIBLE + // Grab the password hash for the username (if available) + $sqlGetPasswordHash = $conn->prepare("SELECT password FROM " . $userTableName . " WHERE username=\"" . $username . "\""); + $sqlGetUserID = $conn->prepare("SELECT userID FROM " . $userTableName . " WHERE username=\"" . $username . "\""); + $sqlGetisAdmin = $conn->prepare("SELECT isAdmin FROM " . $userTableName . " WHERE username=\"" . $username . "\""); + + $sqlGetPasswordHash->execute(); + $sqlGetUserID->execute(); + $sqlGetisAdmin->execute(); + + + } catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); + } + + // Grab the hash from the fetched SQL data +$passwordHash = $sqlGetPasswordHash->fetchColumn(); +$userID = $sqlGetUserID->fetchColumn(); +$isAdmin = $sqlGetisAdmin->fetchColumn(); + + +// Verify that the entered password matches the hashed one +if (password_verify($password, $passwordHash)) { + echo "

Welcome $username, please wait while we redirect you...

"; + $_SESSION["userID"] = $userID; + $_SESSION["username"] = $username; + $_SESSION["isAdmin"] = $isAdmin; + // 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/%s", + isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', + $_SERVER['SERVER_NAME'], + $_GET["redirect"] + ); + } + + $address = url(); + echo "

$address

"; + + echo ""; + +} else { + echo "

Invalid credentials

"; +} + + +// Close the SQL connection + $conn = null; + + ?> + + + + \ No newline at end of file diff --git a/login_page.php b/login_page.php new file mode 100644 index 0000000..777efee --- /dev/null +++ b/login_page.php @@ -0,0 +1,39 @@ + + + + + + + + + + + ADMIN PANEL - Trojan's Trophy Room + + + +

Sign in to continue

+
+
+
+ + +

+ + +

+ + +

 

+
+
+ +
+
+
+

+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..8abc31f --- /dev/null +++ b/logout.php @@ -0,0 +1,35 @@ +window.location.href = \"" . url() . "\"; + "; + +?> \ No newline at end of file diff --git a/scripts/trojan.js b/scripts/trojan.js index 5284c8a..69f0324 100644 --- a/scripts/trojan.js +++ b/scripts/trojan.js @@ -3,4 +3,12 @@ function resizeIframe(obj) { obj.style.width = "100px"; obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px'; obj.style.width = obj.contentWindow.document.documentElement.scrollWidth + 'px'; +} + +function getURL(path) { + if (path == undefined) { + path = ""; + } + console.log(window.location.href + path); + return window.location.href + path; } \ No newline at end of file diff --git a/styles/admin.css b/styles/admin.css index 03a3dc7..94080fd 100644 --- a/styles/admin.css +++ b/styles/admin.css @@ -1,36 +1,3 @@ -#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; - height:100% -} - -#contentFrame { - display: flex; - flex-direction: column; - margin: auto; - border: 1px solid black; - border-radius: 5px; - background-color: rgba(255, 255, 255, .2); - width:80%; - max-width: 900px; - min-height: 0px; - padding-top: 20px; - padding-left: 50px; - padding-right: 50px; - padding-bottom: 40px; -} - -#contentFrame h1 { - margin: auto; - padding-bottom: 20px; -} - -#contentFrame h2,h3 { - margin: auto; - padding-bottom: 30px; -} - #adminHeader { font-size: 200%; } @@ -61,13 +28,6 @@ transform: translateY(2px); } -#subNav { - display: flex; - flex-direction: row; - gap: 1%; - justify-content: center; - gap: 2%; -} #mainHomeButton { box-shadow: 0px 2px 4px; @@ -80,4 +40,4 @@ #mainHomeButton:active { box-shadow: 0px 0px 2px; transform: translateY(2px); -} \ No newline at end of file +} diff --git a/styles/login.css b/styles/login.css new file mode 100644 index 0000000..d78589f --- /dev/null +++ b/styles/login.css @@ -0,0 +1,91 @@ +#loginBody { + width: 275px; + margin: 0; +} + +#loginNotice { + font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + text-align: center; +} + +#loginPanel { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + margin: auto; + border: 1px solid black; + border-radius: 4px; + padding: 10%; + padding-top: 8%; + padding-bottom: 12%; + width:100%; +} + +#inputArea { + justify-content: left; +} + +#loginForm { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + justify-content: center; +} + +#loginForm input { + background-color: rgba(255, 255, 255, 0.6); + border-style: 1px solid blue; +} + +#loginForm label { + font-weight: bold; +} + +#loginForm input[type="submit"] { + justify-content: center; + margin: auto; + padding: 5px 15px; + font-size: 100%; + 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; +} + +#loginForm input[type="submit"]:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} + +#loginForm input[type="submit"]:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} + +#loginForm input[type="text"] { + border-radius: 2px; + width: 75%; + padding: 7px 5%; + margin: 1% 6%; +} + +#loginForm input[type="password"] { + border-radius: 2px; + width: 75%; + padding: 7px 5%; + margin: 1% 6%; +} + +#showPasswordLabel label { + font-weight: lighter; + justify-content: flex-end; +} + +#submitButton { + display: flex; + justify-content: center; + margin:auto; + align-items: center; + +} \ No newline at end of file diff --git a/styles/primary.css b/styles/primary.css index ff5968f..d44e91b 100644 --- a/styles/primary.css +++ b/styles/primary.css @@ -26,7 +26,7 @@ padding-bottom: 20px; } -#contentFrame h3 { +#contentFrame h2,h3 { margin: auto; padding-bottom: 30px; } @@ -68,12 +68,47 @@ margin: auto; padding: 0; border: none; - border-radius: 5px; + /*border-radius: 5px; box-shadow: 0px 10px 15px; - background-color: rgba(183, 183, 255, 0.6); + background-color: rgba(183, 183, 255, 0.6);*/ max-width: 90%; } .newLine { width: 100%; } + + +#subNav { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: 2%; +} + +#logoutButton { + box-shadow: 0px 2px 4px; + font-weight: bold; +} +#logoutButton:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} +#logoutButton:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} + +#loginButton { + box-shadow: 0px 2px 4px; + font-weight: bold; +} +#loginButton:hover { + color: black; + background-color: rgba(255, 165, 0, .6); +} +#loginButton:active { + box-shadow: 0px 0px 2px; + transform: translateY(2px); +} \ No newline at end of file