diff --git a/README.md b/README.md index 8cb2ec7..f5e5e72 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ - Die Suchseite und Kategorieseite packen momentan alle passenden Beiträge untereinander. Später sollen zunächst 10 Ergebnisse auf einer Seite angezeigt werden. - Wenn ein Bild aus einem Beitrag entfernt wird, dann wird noch nicht die Datei im Pfad /uploads gelöscht. +- id in showArticle-controller.php und updateArticle-controller.php wird nicht als gültige numerische ID geprüft. +- sort in search-results-controller.php wird nicht gegen erlaubte Werte validiert. ## Besonderheiten des Projektes - Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden. diff --git a/includes/alertMessages.php b/includes/alertMessages.php index 87cdbfd..e6112da 100644 --- a/includes/alertMessages.php +++ b/includes/alertMessages.php @@ -63,6 +63,16 @@ Dein Beitrag wurde erfolgreich veröffentlicht!

+ +

+ Der Beitrag wurde erfolgreich bearbeitet und gespeichert. +

+ + +

+ Das Profil wurde erfolgreich bearbeitet. +

+

Das Bild konnte nicht hochgeladen werden. Bitte versuche es erneut oder verwende ein anderes Bildformat. diff --git a/php/controller/createArticle-controller.php b/php/controller/createArticle-controller.php index 2022393..a48a98a 100644 --- a/php/controller/createArticle-controller.php +++ b/php/controller/createArticle-controller.php @@ -6,6 +6,10 @@ require_once '../model/LocalArticleManager.php'; require_once '../model/ArticleManager.php'; require_once '../validator/article-validator.php'; +if (!isset($_SESSION["user"])) { + header("Location: index.php?pfad=login"); + exit(); +} if ($_SERVER["REQUEST_METHOD"] === "POST") { $_SESSION["old_title"] = $_POST["title"] ?? ''; $_SESSION["old_content"] = $_POST["content"] ?? ''; diff --git a/php/controller/deleteAccount-controller.php b/php/controller/deleteAccount-controller.php index cdf35a4..351364d 100644 --- a/php/controller/deleteAccount-controller.php +++ b/php/controller/deleteAccount-controller.php @@ -6,6 +6,11 @@ if (session_status() === PHP_SESSION_NONE) { require_once __DIR__ . "/../model/UserManager.php"; require_once __DIR__ . "/../model/ArticleManager.php"; +if (!isset($_SESSION["user"])) { + header("Location: index.php?pfad=login"); + exit(); +} + /* Deregistrierung Funktion: Entfernt User aus der Datenbank und beendet die Session diff --git a/php/controller/deleteArticle-controller.php b/php/controller/deleteArticle-controller.php index a8cda7f..ffc664d 100644 --- a/php/controller/deleteArticle-controller.php +++ b/php/controller/deleteArticle-controller.php @@ -5,6 +5,11 @@ if (session_status() === PHP_SESSION_NONE) { require_once __DIR__ . "/../model/ArticleManager.php"; +if (!isset($_SESSION["user"])) { + header("Location: index.php?pfad=login"); + exit(); +} + if ($_SERVER["REQUEST_METHOD"] === "POST") { if (isset($_SESSION["user_email"])) { diff --git a/php/controller/profile-controller.php b/php/controller/profile-controller.php index 9990fbc..3d5cc42 100644 --- a/php/controller/profile-controller.php +++ b/php/controller/profile-controller.php @@ -63,6 +63,7 @@ try { $_SESSION["user"] = $vorname . " " . $nachname; $_SESSION["user_email"] = $newEmail; + $_SESSION["message"] = "profile_updated"; header("Location: index.php?pfad=profile"); exit(); } else { diff --git a/php/controller/updateArticle-controller.php b/php/controller/updateArticle-controller.php index 6a863d1..44905db 100644 --- a/php/controller/updateArticle-controller.php +++ b/php/controller/updateArticle-controller.php @@ -8,6 +8,11 @@ require_once '../model/ArticleManager.php'; require_once '../model/Article.php'; require_once '../validator/article-validator.php'; +if (!isset($_SESSION["user"])) { + header("Location: index.php?pfad=login"); + exit(); +} + if ($_SERVER["REQUEST_METHOD"] === "POST") { $_SESSION["old_title"] = $_POST["title"] ?? ''; $_SESSION["old_content"] = $_POST["content"] ?? ''; @@ -22,6 +27,20 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") { exit(); } + try { + $articleManager = ArticleManager::getInstance(); + $article = $articleManager->getArticle($id); + if ($article->getAuthor() != $_SESSION["user"]->getUsername()) { + $_SESSION["message"] = "unauthorized_access"; + header("location: ../../index.php"); + exit(); + } + } catch (Exception $e) { + $_SESSION["message"] = $e->getMessage(); + header("location: ../../index.php?pfad=updateArticle&id=$id"); + exit(); + } + if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){ $_SESSION["message"] = "missing_parameters"; header("location: ../../index.php?pfad=updateArticle&id=$id");