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__