Fix a bunch of stuff

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

@ -1,7 +1,7 @@
# Adlerka.Top # Adlerka.Top
The code for Adlerka.top The code for https://adlerka.top
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)

@ -1,3 +0,0 @@

@ -1,4 +1,6 @@
<?php <?php /** @noinspection PhpArrayIsAlwaysEmptyInspection */
/** @noinspection PhpArrayIsAlwaysEmptyInspection */
/** @noinspection PhpArrayIsAlwaysEmptyInspection */
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
require_once "secrets/config.php"; require_once "secrets/config.php";
require_once "lib/config.php"; require_once "lib/config.php";

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

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

@ -111,45 +111,12 @@ function getPage($page_name = null): array|false|string
$page_title = $page_name; $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(); $navpages = generateNavigation();
$nav = str_replace("__NAV_PAGES__", $navpages, $nav); $nav = str_replace("__NAV_PAGES__", $navpages, $nav);
$out = $skeleton; $out = $skeleton;
$out = str_replace("__TEMPLATE__NAV__", $nav, $out); $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); $out = str_replace("__TEMPLATE__PAGE__", $page, $out);
return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out); return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out);
} }

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

@ -1,6 +0,0 @@
<page minimal_permission_level="1" secret="no" page_title="Domov"></page>
<header>
<h1 class="title">Vitaj na tejto úžasnej stránke</h1>
<p>Neoficiálna študentská stránka pre adlerku</p>
<hr>
</header>

6
pages/home/index.html Normal file

@ -0,0 +1,6 @@
<page minimal_permission_level="1" secret="no" page_title="Domov"></page>
<header>
<h1 class="title">Vitaj, na tejto úžasnej stránke</h1>
<p>Neoficiálna študentská stránka pre Adlerku</p>
<hr>
</header>

@ -3,7 +3,7 @@
<h1 class="title">Vitaj na oficiálnej AdlerkaSMP stránke</h1> <h1 class="title">Vitaj na oficiálnej AdlerkaSMP stránke</h1>
<p>Najlepší <a href="https://minecraft.net" style="text-decoration: underline; color: #fff;" target="_blank">Minecraft®™</a> server na Adlerke</p> <p>Najlepší <a href="https://minecraft.net" style="text-decoration: underline; color: #fff;" target="_blank">Minecraft®™</a> server na Adlerke</p>
<hr> <hr>
<wrapper class="feature-list"> <div class="wrapper feature-list">
<h2>Čo môžeš očakávať od AdlerkaSMP:</h2> <h2>Čo môžeš očakávať od AdlerkaSMP:</h2>
<ul class="feature-list-ul"> <ul class="feature-list-ul">
@ -31,5 +31,5 @@
</ul> </ul>
</li> </li>
</ul> </ul>
</wrapper> </div>
</header> </header>

@ -2,5 +2,5 @@
<h2>TY KÁR KAM TO DEŠ</h2> <h2>TY KÁR KAM TO DEŠ</h2>
<h1 class="error-code">403</h1> <h1 class="error-code">403</h1>
<h3><i class="ri-error-warning-line"></i> Našli sme stránku ktorú hľadáš, ale nemáš práva na ňu pristupovať: <span class="error">__TEMPLATE_PAGE_TITLE__</span>. <i class="ri-error-warning-line"></i></h3> <h3><i class="ri-error-warning-line"></i> Našli sme stránku ktorú hľadáš, ale nemáš práva na ňu pristupovať: <span class="error">__TEMPLATE_PAGE_TITLE__</span>. <i class="ri-error-warning-line"></i></h3>
<a href="/domov" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a> <a href="/index" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a>
</div> </div>

@ -2,5 +2,5 @@
<h2>TY KÁR KAM TO DEŠ</h2> <h2>TY KÁR KAM TO DEŠ</h2>
<h1 class="error-code">404</h1> <h1 class="error-code">404</h1>
<h3><i class="ri-error-warning-line"></i> Nenašli sme stránku ktorú hľadáš: <span class="error">__TEMPLATE_PAGE_TITLE__</span>. <i class="ri-error-warning-line"></i></h3> <h3><i class="ri-error-warning-line"></i> Nenašli sme stránku ktorú hľadáš: <span class="error">__TEMPLATE_PAGE_TITLE__</span>. <i class="ri-error-warning-line"></i></h3>
<a href="/domov" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a> <a href="/index" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a>
</div> </div>

@ -2,5 +2,5 @@
<h2>Niekto to pobabral</h2> <h2>Niekto to pobabral</h2>
<h1 class="error-code">500</h1> <h1 class="error-code">500</h1>
<h3><i class="ri-error-warning-line"></i> Nejaký neschopný vývojár nevedel robiť túto stránku. <i class="ri-error-warning-line"></i></h3> <h3><i class="ri-error-warning-line"></i> Nejaký neschopný vývojár nevedel robiť túto stránku. <i class="ri-error-warning-line"></i></h3>
<a href="/domov" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a> <a href="/index" class="back"><i class="ri-arrow-left-line"></i> SPÄŤ DOMOV</a>
</div> </div>

@ -15,7 +15,7 @@
data.append("nickname", nickname); data.append("nickname", nickname);
data.append("email", email); data.append("email", email);
data.append("password", password); data.append("password", password);
data.append("minecraftnick", minecraftNick); data.append("minecraft_nick", minecraftNick);
data.append("activation_token", activationToken); data.append("activation_token", activationToken);
doRegister(data); doRegister(data);

@ -5,8 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.1.0/remixicon.min.css" integrity="sha512-i5VzKip7owqOGjb0YTF8MR2J9yBVO3FLHeazKzLp354XYTmKcqEU3UeFYUw82R8tV6JqxeATOfstCfpfPhbyEA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.1.0/remixicon.min.css" integrity="sha512-i5VzKip7owqOGjb0YTF8MR2J9yBVO3FLHeazKzLp354XYTmKcqEU3UeFYUw82R8tV6JqxeATOfstCfpfPhbyEA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="/assets/style.css"> <link rel="stylesheet" href="/assets/style.css">
__TEMPLATE_PAGE_STYLE_TAG__ <script src="/assets/script.js"></script>
__TEMPLATE_PAGE_SCRIPT_TAG__
<script async src="https://umami.brn.systems/script.js" data-website-id="95e93885-5c19-4cab-ba9b-2f746a316a2a"></script> <script async src="https://umami.brn.systems/script.js" data-website-id="95e93885-5c19-4cab-ba9b-2f746a316a2a"></script>
<title>Adlerka __TEMPLATE_PAGE_TITLE__</title> <title>Adlerka __TEMPLATE_PAGE_TITLE__</title>
</head> </head>