From d5bc8931eb62fde3b331f49ce250e2c565cb199a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 17:52:20 +0100 Subject: [PATCH 01/28] Fix user list --- assets/script.js | 2 +- lib/account.php | 7 ++----- lib/newsarticle.php | 5 ++--- templates/newsArticle.html | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/assets/script.js b/assets/script.js index aa6df08..f06dbc7 100644 --- a/assets/script.js +++ b/assets/script.js @@ -193,7 +193,7 @@ async function renderarticles(){ ); let articleout = ""; - for (const article of articles) { + for (const article of articles.Articles) { articleout += template.replace("__TEMPLATE_ARTICLE_TITLE__", article.Title).replace("__TEMPLATE_ARTICLE_AUTHOR__", article.WrittenByName).replace("__TEMPLATE_ARTICLE_DATE__", article.WrittenAt).replace("__TEMPLATE_ARTICLE_BODY__", article.Body) } document.getElementById("articleslist").innerHTML = articleout; diff --git a/lib/account.php b/lib/account.php index 8a3ee77..ddfd5e3 100644 --- a/lib/account.php +++ b/lib/account.php @@ -89,11 +89,10 @@ function verifyPassword($userID, $password): bool function UpdateSession(): void { global $mysqli; - $stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, Email, MinecraftNick, PrivilegeLevel, LastLoginAt, LoginCount, ClassID, FavoriteColor FROM Users WHERE ID = ? AND isActivated = 1"); + $stmt = $mysqli->prepare("SELECT FirstName, LastName, Nickname, Email, MinecraftNick, PrivilegeLevel, LastLoginAt, LoginCount, ClassID, FavoriteColor FROM Users WHERE ID = ? AND isActivated = 1"); $stmt->bind_param("i", $_SESSION["ID"]); $stmt->execute(); - $id = 0; $first_name = ""; $last_name = ""; $nickname = ""; @@ -104,11 +103,9 @@ function UpdateSession(): void $favorite_color = 0; $lastLoginAt = null; $loginCount = 0; - $stmt->bind_result($id, $first_name, $last_name, $nickname, $email, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount, $class_id, $favorite_color); + $stmt->bind_result($first_name, $last_name, $nickname, $email, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount, $class_id, $favorite_color); $stmt->fetch(); $stmt->close(); - - $_SESSION["id"] = $id; $_SESSION["first_name"] = $first_name; $_SESSION["last_name"] = $last_name; $_SESSION["nickname"] = $nickname; diff --git a/lib/newsarticle.php b/lib/newsarticle.php index 08d02c5..99e003f 100644 --- a/lib/newsarticle.php +++ b/lib/newsarticle.php @@ -8,8 +8,7 @@ function getNewsArticles() :array $articles = []; if (isLoggedIn()) { - $stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID; "); - + $stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID;"); $id = 0; $writtenAt = ""; $writtenBy = 0; @@ -50,7 +49,7 @@ function addNewsArticle($title="Nazov", $body="Obsah") :array $output = ["Status" => "Fail"]; // Default Status is "Fail" if (isLoggedIn()) { $query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList) VALUES (?, ?, ?, 0);"); - $query->bind_param("iss", $_SESSION["id"], htmlspecialchars($title), htmlspecialchars($body)); + $query->bind_param("iss", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body)); $query->execute(); if ($query->affected_rows > 0) { $output["Status"] = "Success"; diff --git a/templates/newsArticle.html b/templates/newsArticle.html index c6b009b..cc2b921 100644 --- a/templates/newsArticle.html +++ b/templates/newsArticle.html @@ -1,6 +1,5 @@

__TEMPLATE_ARTICLE_TITLE__

-

__TEMPLATE_ARTICLE_AUTHOR__

__TEMPLATE_ARTICLE_DATE__


From 0ac17350d6eb33a06a1dcb61928f159df3ab26b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 17:54:46 +0100 Subject: [PATCH 02/28] Fix user list --- assets/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/script.js b/assets/script.js index f06dbc7..71318ae 100644 --- a/assets/script.js +++ b/assets/script.js @@ -181,7 +181,7 @@ async function togglearticlecreate(){ } async function renderarticles(){ - let template = document.querySelector('template[data-template-name="article"]').content.toString(); + let template = document.querySelector('template[data-template-name="article"]').innerHTML; let articles = await doAction( "/newsarticle", { From ec9b4aa51bf8e9ee93cc7bb4bc845d6fffaf8a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:00:30 +0100 Subject: [PATCH 03/28] Fix articles --- pages/news/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/news/index.php b/pages/news/index.php index 164b122..ec4b164 100644 --- a/pages/news/index.php +++ b/pages/news/index.php @@ -15,13 +15,14 @@ if($articles_tmp['Status'] == "Success"){ } $articleTemplate = file_get_contents($routerConfig["template_dir"] . "newsArticle.html"); +$output = str_replace("__TEMPLATE_FOR_ARTICLE_CONTENT__", $articleTemplate, $output); foreach ($articles as $article){ $articleTitle = htmlspecialchars($article["Title"]); $articleBody = htmlspecialchars($article["Body"]); $articleFileList = $article["FileList"]; $articleWrittenBy = $article["WrittenBy"]; $articleWrittenAt = htmlspecialchars($article["WrittenAt"]); - $articleWrittenByName = htmlspecialchars($article["Nickname"]); + $articleWrittenByName = htmlspecialchars($article["WrittenByName"]); $articleTemplate = str_replace("__TEMPLATE_ARTICLE_TITLE__", $articleTitle, $articleTemplate); $articleTemplate = str_replace("__TEMPLATE_ARTICLE_AUTHOR__", $articleWrittenByName, $articleTemplate); @@ -31,7 +32,6 @@ foreach ($articles as $article){ $articles_out .= $articleTemplate; } -$output = str_replace("__TEMPLATE_FOR_ARTICLE_CONTENT__", $articleTemplate, $output); $output = str_replace("__TEMPLATE__ARTICLES_HERE__", $articles_out, $output); return [ From 5ede5b37abc7726a458cab48a35f1f92110400f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:03:39 +0100 Subject: [PATCH 04/28] Fix articles --- templates/newsArticle.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/newsArticle.html b/templates/newsArticle.html index cc2b921..d6cd319 100644 --- a/templates/newsArticle.html +++ b/templates/newsArticle.html @@ -1,7 +1,7 @@

__TEMPLATE_ARTICLE_TITLE__

-

__TEMPLATE_ARTICLE_AUTHOR__

-

__TEMPLATE_ARTICLE_DATE__

+

__TEMPLATE_ARTICLE_AUTHOR__

+

__TEMPLATE_ARTICLE_DATE__


__TEMPLATE_ARTICLE_BODY__ From c905e929f6e3c4da7fe5e154afb831a4533e7f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:08:12 +0100 Subject: [PATCH 05/28] Fix articles --- assets/style.css | 15 +++++++++++++++ templates/newsArticle.html | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/assets/style.css b/assets/style.css index 9fb23b7..7e22470 100644 --- a/assets/style.css +++ b/assets/style.css @@ -388,4 +388,19 @@ body:has(.ye-span:hover) { .hidden { display: none !important; +} + +div#articleslist{ + width: 80vw; + left: 10vw; + position: relative; +} + +div#articleslist > article > div#articleinfo{ + display: flex; + flex-direction: row; +} + +div#articleslist>article{ + border: 4px solid var(--primary); } \ No newline at end of file diff --git a/templates/newsArticle.html b/templates/newsArticle.html index d6cd319..4aae648 100644 --- a/templates/newsArticle.html +++ b/templates/newsArticle.html @@ -1,7 +1,9 @@

__TEMPLATE_ARTICLE_TITLE__

-

__TEMPLATE_ARTICLE_AUTHOR__

-

__TEMPLATE_ARTICLE_DATE__

+
__TEMPLATE_ARTICLE_BODY__ From 37d8577629d808d5b63bf29c7981ff6fda3cab2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:16:42 +0100 Subject: [PATCH 06/28] Fix articles --- assets/script.js | 4 ++-- assets/style.css | 12 +++++++----- lib/inliner.php | 4 ++-- lib/navigation.php | 3 +++ lib/newsarticle.php | 2 +- pages/home/index.html | 1 + pages/memes/index.html | 1 + pages/notes/index.html | 1 + pages/smp/index.html | 1 + pages/smp/info.html | 1 + 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/assets/script.js b/assets/script.js index 71318ae..f2ef051 100644 --- a/assets/script.js +++ b/assets/script.js @@ -213,13 +213,13 @@ async function submitarticle(){ "Nastala chyba pri pridávaní článku", false ); - togglearticlecreate(); + await togglearticlecreate(); } async function articleInit(){ let articleContainerElement = document.getElementById("articlecreatecontainer"); articleContainerElement.addEventListener("keyup", function (ev) { - if(ev.which === 27){ + if(ev.key === "Escape"){ togglearticlecreate(); } }) diff --git a/assets/style.css b/assets/style.css index 7e22470..1b8cf18 100644 --- a/assets/style.css +++ b/assets/style.css @@ -355,14 +355,12 @@ button:hover { } header.ye-span:hover + body{ - background: url('/assets/images/ye.jpg') !important; - background-repeat: repeat !important; + background: url('/assets/images/ye.jpg') repeat !important; background-size: 10% !important; } body:has(.ye-span:hover) { - background: url('/assets/images/ye.jpg') !important; - background-repeat: repeat !important; + background: url('/assets/images/ye.jpg') repeat !important; background-size: 10% !important; } @@ -396,7 +394,11 @@ div#articleslist{ position: relative; } -div#articleslist > article > div#articleinfo{ +div#articleslist > article > div.articleinfo > *{ + width: fit-content; +} + +div#articleslist > article > div.articleinfo{ display: flex; flex-direction: row; } diff --git a/lib/inliner.php b/lib/inliner.php index 4761191..04fc11a 100644 --- a/lib/inliner.php +++ b/lib/inliner.php @@ -27,7 +27,7 @@ function inlineLocalStylesFromHref($inputString): string // Minify the CSS content $cssContent = minifyCss($cssContent); - return ""; + return ""; }, $inputString); } @@ -41,7 +41,7 @@ function inlineScriptFromSrc($inputString): string // Minify the JavaScript content $jsContent = minifyJs($jsContent); - return ""; + return ""; }, $inputString); } diff --git a/lib/navigation.php b/lib/navigation.php index df9fe06..f4a7d50 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -41,6 +41,9 @@ function generateNavigation(): string $site_location = "/" . $site_dir . "/" . $routerConfig["default_page"]; + $stnm = $routerRequest["site_name"]; + + echo "a: $site_dir b: $stnm"; if ($routerRequest["site_name"] == $site_dir) { //this is the current page $site_class = "class=\"navsite_link active\""; diff --git a/lib/newsarticle.php b/lib/newsarticle.php index 99e003f..65745b3 100644 --- a/lib/newsarticle.php +++ b/lib/newsarticle.php @@ -54,7 +54,7 @@ function addNewsArticle($title="Nazov", $body="Obsah") :array if ($query->affected_rows > 0) { $output["Status"] = "Success"; } + $query->close(); } - $query->close(); return $output; } \ No newline at end of file diff --git a/pages/home/index.html b/pages/home/index.html index e5fb4fd..24dd0d9 100644 --- a/pages/home/index.html +++ b/pages/home/index.html @@ -1,3 +1,4 @@ +

Vitaj, na tejto úžasnej stránke

diff --git a/pages/memes/index.html b/pages/memes/index.html index 61637f3..7e7387b 100644 --- a/pages/memes/index.html +++ b/pages/memes/index.html @@ -1,3 +1,4 @@ +

Adlerka Memes

diff --git a/pages/notes/index.html b/pages/notes/index.html index 9e63fb2..536def0 100644 --- a/pages/notes/index.html +++ b/pages/notes/index.html @@ -1,3 +1,4 @@ +

Adlerka Zošit

diff --git a/pages/smp/index.html b/pages/smp/index.html index 030f031..b2382d4 100644 --- a/pages/smp/index.html +++ b/pages/smp/index.html @@ -1,3 +1,4 @@ +

Vitaj na oficiálnej AdlerkaSMP stránke

diff --git a/pages/smp/info.html b/pages/smp/info.html index 11686e8..e762a5e 100644 --- a/pages/smp/info.html +++ b/pages/smp/info.html @@ -1,2 +1,3 @@ +

Vitaj na oficiálnej stránke Informácii o AdlerkaSMP

\ No newline at end of file From 17d303fb3d80e450001a4de785ca84f646b07006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:17:12 +0100 Subject: [PATCH 07/28] Fix articles --- lib/navigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/navigation.php b/lib/navigation.php index f4a7d50..8479223 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -43,7 +43,7 @@ function generateNavigation(): string $stnm = $routerRequest["site_name"]; - echo "a: $site_dir b: $stnm"; + echo "a: $site_dir b: $stnm\n"; if ($routerRequest["site_name"] == $site_dir) { //this is the current page $site_class = "class=\"navsite_link active\""; From 1372041271810eb209a8e4efe2937e75a25d6d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:25:21 +0100 Subject: [PATCH 08/28] Fix articles --- assets/style.css | 18 ++++++++++++++++-- lib/navigation.php | 3 --- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/assets/style.css b/assets/style.css index 1b8cf18..1ebec09 100644 --- a/assets/style.css +++ b/assets/style.css @@ -329,11 +329,18 @@ header a, input, textarea { background-color: var(--third-bg); border: 2px solid var(--primary); - border-radius: 50px; +} + +input{ + border-radius: 25px; +} + +textarea{ + border-radius: 10px; } button { - border-radius: 50px; + border-radius: 25px; border: 2px solid var(--primary); background: var(--third-bg); color: var(--primary-text); @@ -369,6 +376,9 @@ body:has(.ye-span:hover) { border: 5px solid var(--primary); z-index: 5; margin: auto; + padding: 40px; + background-color: var(--primary-bg); + border-radius: 50px; } #articlecreatecontainer{ @@ -405,4 +415,8 @@ div#articleslist > article > div.articleinfo{ div#articleslist>article{ border: 4px solid var(--primary); +} + +a.navsite_link.active:after{ + } \ No newline at end of file diff --git a/lib/navigation.php b/lib/navigation.php index 8479223..df9fe06 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -41,9 +41,6 @@ function generateNavigation(): string $site_location = "/" . $site_dir . "/" . $routerConfig["default_page"]; - $stnm = $routerRequest["site_name"]; - - echo "a: $site_dir b: $stnm\n"; if ($routerRequest["site_name"] == $site_dir) { //this is the current page $site_class = "class=\"navsite_link active\""; From ae8621673263b1b2c35c33bf710771b8335bd39a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:26:11 +0100 Subject: [PATCH 09/28] Fix articles --- assets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/style.css b/assets/style.css index 1ebec09..28a19da 100644 --- a/assets/style.css +++ b/assets/style.css @@ -331,6 +331,10 @@ input, textarea { border: 2px solid var(--primary); } +input::placeholder, textarea::placeholder{ + color: var(--primary-text); +} + input{ border-radius: 25px; } From cb0c400f8179083a34aaa96c4507f2cb55fa4757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 22 Feb 2024 18:27:55 +0100 Subject: [PATCH 10/28] Fix articles --- assets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/style.css b/assets/style.css index 28a19da..3f65fa2 100644 --- a/assets/style.css +++ b/assets/style.css @@ -385,6 +385,10 @@ body:has(.ye-span:hover) { border-radius: 50px; } +#articlecreate > * { + margin: 10px 0; +} + #articlecreatecontainer{ display: flex; align-items: center; From d5082312658dc2722c2fac0437a073d47f2c7073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:01:13 +0100 Subject: [PATCH 11/28] Fix articles --- assets/script.js | 9 +++++++++ assets/style.css | 5 +++++ lib/config.php | 3 +++ lib/newsarticle.php | 21 ++++++++++++--------- lib/page.php | 1 + templates/newsArticles.html | 1 + 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/assets/script.js b/assets/script.js index f2ef051..b6f0baf 100644 --- a/assets/script.js +++ b/assets/script.js @@ -218,12 +218,21 @@ async function submitarticle(){ async function articleInit(){ let articleContainerElement = document.getElementById("articlecreatecontainer"); + let articleCreateOpenElement = document.getElementById("articlecreateopen"); articleContainerElement.addEventListener("keyup", function (ev) { if(ev.key === "Escape"){ togglearticlecreate(); } }) PageIntervals.push(setInterval(renderarticles, 300000)); + document.getElementById("articleprivilegeinput").setAttribute("max", UserInfo.Privileges); + if(UserInfo.Privileges < 2){ + articleContainerElement.style.display = "none"; + articleCreateOpenElement.style.display = "none"; + } + else{ + articleCreateOpenElement.style.display = "inline-block"; + } } async function onPageLoad() { diff --git a/assets/style.css b/assets/style.css index 3f65fa2..e70f766 100644 --- a/assets/style.css +++ b/assets/style.css @@ -402,6 +402,11 @@ body:has(.ye-span:hover) { backdrop-filter: blur(2px); } +div.articleinfo{ + display: flex; + flex-direction: row; +} + .hidden { display: none !important; } diff --git a/lib/config.php b/lib/config.php index e180cc2..3f8c2a6 100644 --- a/lib/config.php +++ b/lib/config.php @@ -26,6 +26,9 @@ 'default_permissions' => 255, ], + 'newsarticle' => [ + 'default_permissions' => 255, + ], 'seo' => [ 'author' => 'Tím AdlerkaTop', 'description' => 'Toto je neoficiánla študentská stránka pre Adlerku, kde môžete nájsť plno zaujímavostí.', diff --git a/lib/newsarticle.php b/lib/newsarticle.php index 65745b3..646c22b 100644 --- a/lib/newsarticle.php +++ b/lib/newsarticle.php @@ -1,5 +1,4 @@ "Fail"]; // Default Status is "Fail" $articles = []; - if (isLoggedIn()) { - $stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID;"); + $stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID WHERE NewsArticles.PrivilegeLevel <= ?;"); $id = 0; $writtenAt = ""; $writtenBy = 0; @@ -17,6 +15,7 @@ function getNewsArticles() :array $filelist = 0; $writtenByName = ""; + $stmt->bind_param("i", $_SESSION["privilege_level"]); $stmt->bind_result($id, $writtenAt, $writtenBy, $title, $body, $filelist, $writtenByName); $stmt->execute(); @@ -37,19 +36,23 @@ function getNewsArticles() :array $output["Articles"] = $articles; } - } - return $output; } -function addNewsArticle($title="Nazov", $body="Obsah") :array +function addNewsArticle($title="Nazov", $body="Obsah", $privilegeLevel=0) :array { global $mysqli; + global $routerConfig; + + + if ($privilegeLevel == 0){ + $privilegeLevel = $routerConfig['newsarticle']['default_permissions']; + } $output = ["Status" => "Fail"]; // Default Status is "Fail" - if (isLoggedIn()) { - $query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList) VALUES (?, ?, ?, 0);"); - $query->bind_param("iss", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body)); + if (isLoggedIn() && $privilegeLevel <= $_SESSION["privilege_level"]) { + $query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList, PrivilegeLevel) VALUES (?, ?, ?, 0, ?);"); + $query->bind_param("issi", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body), intval($privilegeLevel)); $query->execute(); if ($query->affected_rows > 0) { $output["Status"] = "Success"; diff --git a/lib/page.php b/lib/page.php index a9eaa3b..3c04f80 100644 --- a/lib/page.php +++ b/lib/page.php @@ -143,6 +143,7 @@ function getPage($site_name_in = null, $page_name_in = null): string "currentTitle" => $page_title, "defaultPage" => $routerConfig["default_page"], "defaultSite" => $routerConfig["default_site"], + "UserInfo_Privileges" => $_SESSION["privilege_level"], ]; if(isLoggedIn()){ $dynamic_script_data += [ diff --git a/templates/newsArticles.html b/templates/newsArticles.html index ea74d38..e300c85 100644 --- a/templates/newsArticles.html +++ b/templates/newsArticles.html @@ -17,6 +17,7 @@


+
From e5a2fe8a1b76a389d7bbe9515fdc4dc37e62341b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:01:55 +0100 Subject: [PATCH 12/28] Fix articles --- pages/news/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/news/index.php b/pages/news/index.php index ec4b164..1874828 100644 --- a/pages/news/index.php +++ b/pages/news/index.php @@ -38,7 +38,7 @@ return [ "output" => $output, "parameters" => [ - "minimal_permission_level" => 2, + "minimal_permission_level" => 1, "secret" => "no", "page_title" => "Novinky" ] From 0cc87762fcb7177929a622d98163036a095d117b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:04:04 +0100 Subject: [PATCH 13/28] Fix articles --- assets/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/script.js b/assets/script.js index b6f0baf..77e08d7 100644 --- a/assets/script.js +++ b/assets/script.js @@ -256,7 +256,7 @@ async function onPageLoad() { if (currentSite === "home" && currentPage === "account" && isLoggedIn()) { await showDashboardGreeting(); } - if (currentSite === "news" && currentPage === "index" && isLoggedIn()) { + if (currentSite === "news" && currentPage === "index") { await articleInit(); } } From 0418edfcf9cb453af343a286a9bb6bc25781460b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:04:56 +0100 Subject: [PATCH 14/28] Fix articles --- assets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/style.css b/assets/style.css index e70f766..ebfd985 100644 --- a/assets/style.css +++ b/assets/style.css @@ -389,6 +389,10 @@ body:has(.ye-span:hover) { margin: 10px 0; } +#articlecreateopen { + display: none; +} + #articlecreatecontainer{ display: flex; align-items: center; From 148254b2f85089104a4090e9c2b0c14ad0d8eb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:06:28 +0100 Subject: [PATCH 15/28] Fix articles --- assets/style.css | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/assets/style.css b/assets/style.css index ebfd985..ed361b6 100644 --- a/assets/style.css +++ b/assets/style.css @@ -406,10 +406,6 @@ body:has(.ye-span:hover) { backdrop-filter: blur(2px); } -div.articleinfo{ - display: flex; - flex-direction: row; -} .hidden { display: none !important; @@ -423,6 +419,7 @@ div#articleslist{ div#articleslist > article > div.articleinfo > *{ width: fit-content; + flex: 1; } div#articleslist > article > div.articleinfo{ From b51f3d9c6f69326246bce9d1d8f40fc605d72d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:08:58 +0100 Subject: [PATCH 16/28] Fix articles --- assets/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/style.css b/assets/style.css index ed361b6..7b04c3e 100644 --- a/assets/style.css +++ b/assets/style.css @@ -419,7 +419,6 @@ div#articleslist{ div#articleslist > article > div.articleinfo > *{ width: fit-content; - flex: 1; } div#articleslist > article > div.articleinfo{ From 7798e41e286689ecb54cb179b1f844dbac3d2df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:16:21 +0100 Subject: [PATCH 17/28] Fix page title --- assets/script.js | 3 +++ lib/page.php | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/assets/script.js b/assets/script.js index 77e08d7..978c0a9 100644 --- a/assets/script.js +++ b/assets/script.js @@ -70,6 +70,9 @@ async function handlePageResponse(data) { if (data.Navigation) { navbar.innerHTML = data.Navigation; } + if (data.Title) { + document.title = data.PageTitle; + } if (data.Page) { pageArea.innerHTML = data.Page; diff --git a/lib/page.php b/lib/page.php index 3c04f80..a2759e4 100644 --- a/lib/page.php +++ b/lib/page.php @@ -109,10 +109,18 @@ function renderPage($page_name = null, $site_name = null): array $page = ""; } + if(!empty($pageMetadata["parameters"]["page_title"])){ + $page_title = $pageMetadata["parameters"]["page_title"]; + } + else{ + $page_title = $page_name; + } + return [ "PageContent" => $page, "PageName" => $page_name, "SiteName" => $site_name, + "PageTitle" => $page_title, ]; } @@ -130,12 +138,7 @@ function getPage($site_name_in = null, $page_name_in = null): string $footer = file_get_contents($routerConfig["template_dir"] . "footer.html"); - if(!empty($pageMetadata["parameters"]["page_title"])){ - $page_title = $pageMetadata["parameters"]["page_title"]; - } - else{ - $page_title = $page_name; - } + $page_title = $page_tmp["PageTitle"]; $dynamic_style = doDynamicStyling(); $dynamic_script_data = [ "currentPage" => $page_name, From e77ecfbf932abb1f631afbdd7e0bfc1cfe125a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:17:49 +0100 Subject: [PATCH 18/28] Fix page title --- lib/page.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/page.php b/lib/page.php index a2759e4..461a95c 100644 --- a/lib/page.php +++ b/lib/page.php @@ -218,5 +218,6 @@ function getPageEndpoint($page_name, $site_name) :array "Status" => "Success", "Page" => $page_tmp["PageContent"], "PageLocation" => $page_location, + "PageTitle" => $page_tmp["PageTitle"], ]; } \ No newline at end of file From 02ecffdb7f9950e0c9cf8430034ffb7fe7e6f38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:18:31 +0100 Subject: [PATCH 19/28] Fix page title --- assets/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/script.js b/assets/script.js index 978c0a9..2d5e6d3 100644 --- a/assets/script.js +++ b/assets/script.js @@ -70,7 +70,7 @@ async function handlePageResponse(data) { if (data.Navigation) { navbar.innerHTML = data.Navigation; } - if (data.Title) { + if (data.PageTitle) { document.title = data.PageTitle; } From e08874f9d2e6d99b8195c162696898207442bd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:19:44 +0100 Subject: [PATCH 20/28] Fix page title --- templates/skeleton.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/skeleton.html b/templates/skeleton.html index daa5b57..e0abbc9 100644 --- a/templates/skeleton.html +++ b/templates/skeleton.html @@ -10,7 +10,7 @@ __TEMPLATE__DYNAMIC__STYLE__ - Adlerka __TEMPLATE_PAGE_TITLE__ + __TEMPLATE_PAGE_TITLE__ __TEMPLATE_SEO_STUFF__ From 1650e852cdb45cd70cc9fe162844acfb6bd48724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:20:10 +0100 Subject: [PATCH 21/28] Fix page title --- pages/smp/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/smp/info.html b/pages/smp/info.html index e762a5e..70bee00 100644 --- a/pages/smp/info.html +++ b/pages/smp/info.html @@ -1,3 +1,3 @@ - +

Vitaj na oficiálnej stránke Informácii o AdlerkaSMP

\ No newline at end of file From 21e78d3ceb9fadcbc9ce7dc91837fb6decb27f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 09:23:09 +0100 Subject: [PATCH 22/28] Fix page title --- lib/config.php | 1 + lib/page.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/config.php b/lib/config.php index 3f8c2a6..0f49b25 100644 --- a/lib/config.php +++ b/lib/config.php @@ -12,6 +12,7 @@ 'endpoint_dir' => 'endpoints/', 'page_dir' => 'pages/', 'protocol' => 'https://', + 'site_prefix' => 'Adlerka', 'permissions' => [ 'logged_out' => 1, 'logged_in_default' => 2, diff --git a/lib/page.php b/lib/page.php index 461a95c..5de3bb8 100644 --- a/lib/page.php +++ b/lib/page.php @@ -40,6 +40,10 @@ function renderPage($page_name = null, $site_name = null): array $site_name = $routerRequest["site_name"]; } + $site_title = str_replace("_", " ", $site_name); + + $site_title = ucfirst($site_title); + if(!$page_name){ $page_name = $routerRequest["page_name"]; } @@ -110,7 +114,7 @@ function renderPage($page_name = null, $site_name = null): array } if(!empty($pageMetadata["parameters"]["page_title"])){ - $page_title = $pageMetadata["parameters"]["page_title"]; + $page_title = $routerConfig['site_prefix'] . " " . $site_title . " " . $pageMetadata["parameters"]["page_title"]; } else{ $page_title = $page_name; From 4f5732ad838828ed4d50d087a8c3fa7a91b6b311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 10:04:16 +0100 Subject: [PATCH 23/28] Fix page title --- lib/page.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/page.php b/lib/page.php index 5de3bb8..db2c600 100644 --- a/lib/page.php +++ b/lib/page.php @@ -114,12 +114,14 @@ function renderPage($page_name = null, $site_name = null): array } if(!empty($pageMetadata["parameters"]["page_title"])){ - $page_title = $routerConfig['site_prefix'] . " " . $site_title . " " . $pageMetadata["parameters"]["page_title"]; + $page_title = $pageMetadata["parameters"]["page_title"]; } else{ $page_title = $page_name; } + $page_title = $routerConfig['site_prefix'] . " " . $site_title . " " . $page_title; + return [ "PageContent" => $page, "PageName" => $page_name, From 4d829d6b76ccaaf42eb3b75d8c9be936b718c16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 10:06:58 +0100 Subject: [PATCH 24/28] Fix navigation --- lib/navigation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/navigation.php b/lib/navigation.php index df9fe06..cdcb0a1 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -7,6 +7,7 @@ function getDynamicMetadata($file): array{ function getDynamicPermission($metadata): int { global $routerConfig; + print_r($metadata); $params = $metadata["parameters"]; try { $permission_level = $params["minimal_permission_level"]; From 178e1e7e19cac8db227af20297dc85a1a7d6b4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 10:08:47 +0100 Subject: [PATCH 25/28] Fix navigation --- lib/navigation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/navigation.php b/lib/navigation.php index cdcb0a1..4e85a19 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -2,6 +2,7 @@ function getDynamicMetadata($file): array{ + echo $file; return include($file); } From 201a728e7dea63b7b589870e9c394a60474e2741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 10:10:08 +0100 Subject: [PATCH 26/28] Fix navigation --- lib/navigation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index 4e85a19..d4d85eb 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -2,13 +2,11 @@ function getDynamicMetadata($file): array{ - echo $file; return include($file); } function getDynamicPermission($metadata): int { global $routerConfig; - print_r($metadata); $params = $metadata["parameters"]; try { $permission_level = $params["minimal_permission_level"]; @@ -84,6 +82,8 @@ function generateNavigation(): string } elseif($page_file_tmp[1] == "php"){ $pageMetadata = getDynamicMetadata($page_file_path); + echo $page_file_path; + print_r($pageMetadata); $page_required_permission = getDynamicPermission($pageMetadata); if(!empty($pageMetadata["parameters"]["page_title"])){ From b386ff5fbd2f37d268061566f18be561f24e8b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sat, 24 Feb 2024 10:11:18 +0100 Subject: [PATCH 27/28] Fix navigation --- lib/navigation.php | 2 -- lib/sitemap.php | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index d4d85eb..df9fe06 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -82,8 +82,6 @@ function generateNavigation(): string } elseif($page_file_tmp[1] == "php"){ $pageMetadata = getDynamicMetadata($page_file_path); - echo $page_file_path; - print_r($pageMetadata); $page_required_permission = getDynamicPermission($pageMetadata); if(!empty($pageMetadata["parameters"]["page_title"])){ diff --git a/lib/sitemap.php b/lib/sitemap.php index 7523edb..967be22 100644 --- a/lib/sitemap.php +++ b/lib/sitemap.php @@ -35,7 +35,8 @@ function generateSitemap(): void{ $page_required_permission = $routerConfig["page"]["default_permissions"]; } } elseif ($page_file_tmp[1] == "php") { - $page_required_permission = getDynamicPermission($page_file_path); + $pageMetadata = getDynamicMetadata($page_file_path); + $page_required_permission = getDynamicPermission($pageMetadata); } else { $page_required_permission = $routerConfig["page"]["default_permissions"]; } From cda602f0aef05712df303074eaf6a7eadece4c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sun, 25 Feb 2024 20:34:29 +0100 Subject: [PATCH 28/28] Fix article --- lib/newsarticle.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/newsarticle.php b/lib/newsarticle.php index 646c22b..0f80108 100644 --- a/lib/newsarticle.php +++ b/lib/newsarticle.php @@ -52,7 +52,8 @@ function addNewsArticle($title="Nazov", $body="Obsah", $privilegeLevel=0) :array $output = ["Status" => "Fail"]; // Default Status is "Fail" if (isLoggedIn() && $privilegeLevel <= $_SESSION["privilege_level"]) { $query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList, PrivilegeLevel) VALUES (?, ?, ?, 0, ?);"); - $query->bind_param("issi", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body), intval($privilegeLevel)); + $minpriv = intval($privilegeLevel); + $query->bind_param("issi", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body), $minpriv); $query->execute(); if ($query->affected_rows > 0) { $output["Status"] = "Success";