diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e750a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +secrets +secrets/ +secrets/config.php diff --git a/assets/style.css b/assets/style.css index c679745..23a88fe 100644 --- a/assets/style.css +++ b/assets/style.css @@ -11,9 +11,7 @@ } body { - background: linear-gradient(127deg, var(--secondary-bg), var(--primary-bg)); - background-repeat: no-repeat; - background-attachment: fixed; + background: linear-gradient(127deg, var(--secondary-bg), var(--primary-bg)) no-repeat fixed; background-size: cover; height: 100%; width: 100%; @@ -29,28 +27,9 @@ nav { justify-content: space-between; padding: 1.2rem 1rem; background-color: rgba(0, 0, 0, 0.2); - -webkit-box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2); - -moz-box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2); - box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2); -} - -nav #login { - color: var(--primary-text); - text-decoration: none; - background-color: #2a9dd6; - padding: 0.35rem 0.65rem; - transition: all 0.3s ease; - border-radius: 15px; -} - -nav #login:hover, nav #login.active{ - transition: all 0.3s ease; - background-color: var(--primary-hover); - color: var(--primary-text); -} - -nav #login:hover::after, nav #login.active::after { - width: 0; + -webkit-box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2); + -moz-box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2); + box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2); } ul { @@ -89,11 +68,6 @@ li a:hover::after { width: 85%; } -li a:hover, li a.active { - color: var(--primary); - transition: all 0.3s ease; -} - .wrapper-404 { text-align: center; } @@ -162,7 +136,6 @@ header hr { } .navpage_list{ - margin-top: 8px; background-color: var(--third-bg); margin-top: 10px; display: flex; @@ -183,11 +156,6 @@ header hr { transition-delay: 0s; /* Reset delay on hover */ } -a.navpage_link{ - padding: 0; - margin: 0; -} - li.navpage_item{ padding-left: 20px; padding-right: 20px; diff --git a/index.php b/index.php index bc8b76d..c10efa9 100644 --- a/index.php +++ b/index.php @@ -1,74 +1,22 @@ \ No newline at end of file diff --git a/lib/account.php b/lib/account.php new file mode 100644 index 0000000..1aee7d6 --- /dev/null +++ b/lib/account.php @@ -0,0 +1,88 @@ + 0 && !empty($_SESSION["email"]); +} + +function doLogin(){ + global $mysqli; + if(!empty($_POST["email"]) && !empty($_POST["password"])){ + $email = $_POST["email"]; + $pass = $_POST["password"]; + /* prepare statement */ + $stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, PasswordHash, MinecraftNick, isAdmin FROM Users WHERE EMAIL = ? AND isActive = 1"); + $stmt->bind_param("s", $email); + $stmt->execute(); + $idcko = 0; + $fname = ""; + $lname = ""; + $nickname = ""; + $pwdhash = ""; + $mcnick = ""; + /* bind variables to prepared statement */ + $stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, false); + + /* fetch values */ + $found = false; + if($stmt->num_rows() > 0){ + $stmt->fetch(); + if (password_verify($pass, $pwdhash)){ + $_SESSION["ID"] = $idcko; + $_SESSION["first_name"] = $fname; + $_SESSION["last_name"] = $lname; + $_SESSION["nickname"] = $nickname; + $_SESSION["email"] = $email; + $_SESSION["mcnick"] = $mcnick; + $_SESSION["isadmin"] = false; + $found = true; + } + } + $stmt->close(); + if($found){ + $status = ["status" => "success"]; + } + else{ + $status = ["status" => "fail"]; + } + echo json_encode($status); + } +} + +function doLogout(){ + if(isLoggedIn()){ + session_destroy(); + $status = ["status" => "success"]; + } + else{ + $status = ["status" => "fail"]; + } + echo json_encode($status); +} + +function doRegister(){ + $status = ["status" => "fail"]; + if (!empty($_POST["activationtoken"])){ + global $mysqli; + + $firstName = $_POST["firstname"]; + $lastName = $_POST["lastname"]; + $nickname = $_POST["nickname"]; + $email = $_POST["email"]; + $password = $_POST["password"]; + $minecraftNick = $_POST["minecraftnick"]; + $activationToken = $_POST["activationtoken"]; + if (!empty($firstName) && !empty($lastName) && !empty($nickname) && !empty($email) && !empty($password)) { + $passwordHash = password_hash($password, PASSWORD_DEFAULT); + + $stmt = $mysqli->prepare("UPDATE Users SET FirstName = ?, LastName = ?, Nickname = ?, Email = ?, PasswordHash = ?, MinecraftNick = ?, isAdmin = 0, isActivated = 1 WHERE isActivated = 0 AND ActivationToken = ?"); + $stmt->bind_param("ssssss", $firstName, $lastName, $nickname, $email, $passwordHash, $minecraftNick, $activationToken); + $stmt->execute(); + if ($stmt->affected_rows > 0) { + $status["status"] = "success"; + } + $stmt->close(); + } + } + echo json_encode($status); +} + diff --git a/lib/config.php b/lib/config.php new file mode 100644 index 0000000..9d02198 --- /dev/null +++ b/lib/config.php @@ -0,0 +1,14 @@ +$page_name"; + } + $nav_out .= ""; + } + + return $nav_out; +} + + diff --git a/lib/routing.php b/lib/routing.php new file mode 100644 index 0000000..8e836b7 --- /dev/null +++ b/lib/routing.php @@ -0,0 +1,94 @@ + 0) { + $account_template = file_get_contents($routerConfig["template_dir"] . "account.html"); + echo $account_template; + } else { + $login_template = file_get_contents($routerConfig["template_dir"] . "login.html"); + echo $login_template; + } + + return ob_get_clean(); +} \ No newline at end of file diff --git a/pages/global/login.php b/pages/global/login.php deleted file mode 100644 index dd6e9e2..0000000 --- a/pages/global/login.php +++ /dev/null @@ -1,56 +0,0 @@ -prepare("SELECT ID, PSWD, IGN, ISADMIN FROM Users where EMAIL = ?"); - $stmt->bind_param("s", $email); - $stmt->execute(); - /* bind variables to prepared statement */ - $stmt->bind_result($idcko, $hash, $ign, $isadmin); - - $found = false; - /* fetch values */ - while ($stmt->fetch()) { - if (password_verify($pass, $hash)){ - $_SESSION["ID"] = $idcko; - $_SESSION["email"] = $email; - $_SESSION["ign"] = $ign; - $_SESSION["isadmin"] = $isadmin; - $found = true; - break; - } - else{ - $_SESSION["ID"] = 0; - $_SESSION["email"] = ""; - $_SESSION["ign"] = ""; - $_SESSION["isadmin"] = 0; - $found = false; - } - break; - } - if($found){ - echo "Login successful"; - } - else{ - echo "Login failed"; - } - } -} -if ($_SESSION["ID"] > 0){ - $account_template = file_get_contents($template_dir . "account.html"); - echo $account_template; -} -else{ - $login_template = file_get_contents($template_dir . "login.html"); - echo $login_template; -} - -return ob_get_clean(); - -?> \ No newline at end of file diff --git a/templates/login.html b/templates/login.html index de16d28..535db55 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,5 +1,7 @@
- - +
+
+
+
\ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 75684ab..2d9ce7c 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -1,5 +1,5 @@