Fix a bunch of stuff

This commit is contained in:
2024-02-03 16:18:48 +01:00
parent 15964cf109
commit 6ccbe82189
17 changed files with 23 additions and 55 deletions

View File

@@ -149,6 +149,7 @@ function doRegister($firstname, $lastname, $email, $password, $activation_token)
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$stmt = $mysqli->prepare("INSERT INTO Users (FirstName, LastName, Email, PasswordHash, PrivilegeLevel, isActivated, ActivationToken, RegisteredAt) VALUES (?, ?, ?, ?, ?, 1, ?, NOW())");
$privilege_level = $routerConfig["logged_in_default_permission_level"];
/** @noinspection SpellCheckingInspection */
$stmt->bind_param("ssssis", $firstname, $lastname, $email, $passwordHash, $privilege_level, $activation_token);
$stmt->execute();
if ($stmt->affected_rows > 0) {
@@ -188,6 +189,7 @@ function updateUserProfile($firstName, $lastName, $nickname, $minecraft_nickname
$userID = $_SESSION["ID"];
$stmt = $mysqli->prepare("UPDATE Users SET FirstName = ?, LastName = ?, Nickname = ?, MinecraftNick = ? WHERE ID = ?");
/** @noinspection SpellCheckingInspection */
$stmt->bind_param("ssssi", $firstName, $lastName, $nickname, $minecraft_nickname, $userID);
$stmt->execute();
@@ -206,6 +208,7 @@ function updateUserEmail($email): array
{
global $mysqli;
$status = ["Status" => "Fail"];
/** @noinspection SpellCheckingInspection */
$validmail = false;
if (isLoggedIn() && !empty($email)) {
@@ -221,9 +224,11 @@ function updateUserEmail($email): array
if ($email != $old_email) {
if (isEmailAvailable($email)) {
/** @noinspection SpellCheckingInspection */
$validmail = true;
}
} else {
/** @noinspection SpellCheckingInspection */
$validmail = true;
}

View File

@@ -3,7 +3,7 @@
{
global $routerConfig;
$routerConfig["default_page"] = "domov";
$routerConfig["default_page"] = "index";
$routerConfig["default_site"] = "home";

View File

@@ -111,45 +111,12 @@ function getPage($page_name = null): array|false|string
$page_title = $page_name;
}
$site_name = $routerRequest["subdomain"];
if(!empty($pageMetadata["parameters"]["page_style"])){
$style_location = $pageMetadata["parameters"]["page_style"];
}
else{
$style_location = "assets/styles/$site_name/$page_name.css";
}
if(file_exists($style_location)) {
$style_tag = $style_location;
}
else{
$style_tag = "";
}
if(!empty($pageMetadata["parameters"]["page_script"])){
$script_location = $pageMetadata["parameters"]["page_script"];
}
else{
$script_location = "assets/scripts/$site_name/$page_name.js";
}
if(file_exists($style_location)) {
$script_tag = $script_location;
}
else{
$script_tag = "";
}
$navpages = generateNavigation();
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
$out = $skeleton;
$out = str_replace("__TEMPLATE__NAV__", $nav, $out);
$out = str_replace("__TEMPLATE_PAGE_STYLE_TAG__", $style_tag, $out);
$out = str_replace("__TEMPLATE_PAGE_SCRIPT_TAG__", $script_tag, $out);
$out = str_replace("__TEMPLATE__PAGE__", $page, $out);
return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out);
}

View File

@@ -25,7 +25,6 @@ function initRouter(): bool
if($routerRequest["subdomain"] == $routerConfig["default_site"]){
$routerRequest["subdomain"] = "";
$needsRedirect = true;
header("redirReasonApex: yes");
}
}
@@ -35,7 +34,6 @@ function initRouter(): bool
// Page name is empty
$needsRedirect = true;
$routerRequest["page_name"] = $routerConfig["default_page"];
header("redirReasonPage: yes");
}