raise permission level by one

fix sql columns
This commit is contained in:
Bruno Rybársky 2024-02-01 10:50:07 +01:00
parent f442a8f34b
commit cbcbb9f4b0
9 changed files with 16 additions and 15 deletions

@ -10,13 +10,14 @@ function isLoggedIn(): bool
function setDefaultSessionData(): void function setDefaultSessionData(): void
{ {
global $routerConfig;
$_SESSION["ID"] = 0; $_SESSION["ID"] = 0;
$_SESSION["first_name"] = ""; $_SESSION["first_name"] = "";
$_SESSION["last_name"] = ""; $_SESSION["last_name"] = "";
$_SESSION["nickname"] = ""; $_SESSION["nickname"] = "";
$_SESSION["email"] = ""; $_SESSION["email"] = "";
$_SESSION["mcnick"] = ""; $_SESSION["mcnick"] = "";
$_SESSION["privilegelevel"] = 0; $_SESSION["privilegelevel"] = $routerConfig["logged_out_permission_level"];
} }
function generateActivationToken(): string function generateActivationToken(): string
@ -202,7 +203,7 @@ function addActivationCodes($count): array
$activationCodes = []; $activationCodes = [];
if (is_numeric($count) && $count > 0 && $_SESSION["privilegelevel"] >= $routerConfig["user_admin_permission_level"]) { if (is_numeric($count) && $count > 0 && $_SESSION["privilegelevel"] >= $routerConfig["user_admin_permission_level"]) {
$stmt = $mysqli->prepare("UPDATE Users SET ActivationCode = ?, CreatedAt = NOW(), CreatedBy = ? WHERE ID = ?"); $stmt = $mysqli->prepare("UPDATE Users SET ActivationToken = ?, CreatedAt = NOW(), CreatedBy = ? WHERE ID = ?");
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$activationCode = generateActivationToken(); $activationCode = generateActivationToken();
@ -251,7 +252,7 @@ function listActivationCodes(): array
if ($_SESSION["privilegelevel"] >= $routerConfig["user_admin_permission_level"]) { if ($_SESSION["privilegelevel"] >= $routerConfig["user_admin_permission_level"]) {
$activationCodes = []; $activationCodes = [];
$result = $mysqli->query("SELECT Code, CreatedAt, CreatedBy FROM Users"); $result = $mysqli->query("SELECT ActivationToken, CreatedAt, CreatedBy FROM Users");
// Check if the query executed successfully // Check if the query executed successfully
if ($result) { if ($result) {

@ -15,15 +15,15 @@
$routerConfig["protocol"] = "https://"; $routerConfig["protocol"] = "https://";
$routerConfig["logged_out_permission_level"] = 0; $routerConfig["logged_out_permission_level"] = 1;
$routerConfig["logged_in_default_permission_level"] = 1; $routerConfig["logged_in_default_permission_level"] = 2;
$routerConfig["verified_permission_level"] = 2; $routerConfig["verified_permission_level"] = 3;
$routerConfig["trustworthy_permission_level"] = 3; $routerConfig["trustworthy_permission_level"] = 4;
$routerConfig["moderator_permission_level"] = 4; $routerConfig["moderator_permission_level"] = 5;
$routerConfig["user_admin_permission_level"] = 254; $routerConfig["user_admin_permission_level"] = 254;

@ -4,7 +4,7 @@ require_once "lib/router.php";
function get_parameters():array function get_parameters():array
{ {
return ["minimal_permission_level" => 0, "secret" => "no", "page_title" => "Domov"]; return ["minimal_permission_level" => 1, "secret" => "no", "page_title" => "Domov"];
} }
function render(): string function render(): string

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

@ -1,4 +1,4 @@
<page minimal_permission_level="0" secret="no" page_title="Memečká"></page> <page minimal_permission_level="1" secret="no" page_title="Memečká"></page>
<header> <header>
<h1 class="title">Adlerka Memes</h1> <h1 class="title">Adlerka Memes</h1>
<p>Skoro ako <a href="https://reddit.com/r/adlerka" target="_blank">r/adlerka</a> - ale lepšie.</p> <p>Skoro ako <a href="https://reddit.com/r/adlerka" target="_blank">r/adlerka</a> - ale lepšie.</p>

@ -1,2 +1,2 @@
<page minimal_permission_level="0" secret="no" page_title="Memečká info"></page> <page minimal_permission_level="1" secret="no" page_title="Memečká info"></page>
<h1>Vitaj na oficiálnej stránke Memeov o AdlerkaSMP</h1> <h1>Vitaj na oficiálnej stránke Memeov o AdlerkaSMP</h1>

@ -1,4 +1,4 @@
<page minimal_permission_level="1" secret="no" page_title="Zošit"></page> <page minimal_permission_level="2" secret="no" page_title="Zošit"></page>
<header> <header>
<h1 class="title">Adlerka Zošit</h1> <h1 class="title">Adlerka Zošit</h1>
<hr> <hr>

@ -1,4 +1,4 @@
<page minimal_permission_level="0" secret="no" page_title="Domov"></page> <page minimal_permission_level="1" secret="no" page_title="Domov"></page>
<header> <header>
<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>

@ -1,2 +1,2 @@
<page minimal_permission_level="0" secret="no" page_title="AdlerkaSMP info"></page> <page minimal_permission_level="1" secret="no" page_title="AdlerkaSMP info"></page>
<h1>Vitaj na oficiálnej stránke Informácii o AdlerkaSMP</h1> <h1>Vitaj na oficiálnej stránke Informácii o AdlerkaSMP</h1>