Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a33f3b27fb |
Generated
+3
-1
@@ -10,7 +10,9 @@
|
|||||||
<option name="highlightLevel" value="WARNING" />
|
<option name="highlightLevel" value="WARNING" />
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.5" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.0">
|
||||||
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
|
</component>
|
||||||
<component name="PhpStanOptionsConfiguration">
|
<component name="PhpStanOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$user = $user ?? null;
|
session_start();
|
||||||
if (!isset($_SESSION["user"])) {
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Beitrag erstellen
|
Seite: Beitrag erstellen
|
||||||
@@ -22,40 +18,11 @@ if (!isset($_SESSION["user"])) {
|
|||||||
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Die ausgewählte Kategorie ist ungültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-50 Zeichen).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title" placeholder="Titel hier eingeben" required>
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."></textarea>
|
||||||
placeholder="Titel hier eingeben" required>
|
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
|
||||||
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
@@ -112,9 +79,7 @@ if (!isset($_SESSION["user"])) {
|
|||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags" placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_tags'] ?? ''); unset($_SESSION['old_tags']); ?>"
|
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
|
|
||||||
/*
|
|
||||||
Deregistrierung
|
|
||||||
Funktion: Entfernt User aus Dummy-Daten und beendet Session
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (isset($_SESSION["user_email"])) {
|
|
||||||
$dao->deleteUser($_SESSION["user_email"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
+12
-33
@@ -1,7 +1,3 @@
|
|||||||
<?php
|
|
||||||
$error = $error ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Form: Login-Bereich
|
Form: Login-Bereich
|
||||||
Funktion: Benutzerauthentifizierung und Zugang zum eigenen Profil, Erstellen von Beiträgen, etc.
|
Funktion: Benutzerauthentifizierung und Zugang zum eigenen Profil, Erstellen von Beiträgen, etc.
|
||||||
@@ -11,43 +7,26 @@ $error = $error ?? null;
|
|||||||
|
|
||||||
<h1>Bitte anmelden</h1>
|
<h1>Bitte anmelden</h1>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<form>
|
||||||
<p style="color:red;">
|
<label id ="inputEmail" class="screenreader-only">E-Mail Adresse / </label>
|
||||||
<?php echo htmlspecialchars($error); ?>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form method="post" action="index.php?pfad=login">
|
|
||||||
|
|
||||||
<p class="input-label">Benutzername/E-Mail-Adresse:</p>
|
<p class="input-label">Benutzername/E-Mail-Adresse:</p>
|
||||||
<input type="email"
|
<input type="email" name="email" class="login-input" placeholder="E-Mail-Adresse" required autofocus>
|
||||||
name="email"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="E-Mail-Adresse"
|
|
||||||
required
|
|
||||||
autofocus>
|
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
<input type="password"
|
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||||
name="password"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Passwort"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<button type="submit"
|
<div class="checkbox-wrapper">
|
||||||
value="anmelden"
|
<label>
|
||||||
name="loginSubmit"
|
<input type="checkbox" name="remember-me" value="1"> angemeldet bleiben
|
||||||
class="login-button">
|
</label>
|
||||||
anmelden
|
</div>
|
||||||
</button>
|
|
||||||
|
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">anmelden</button>
|
||||||
|
|
||||||
<div class="register-link">
|
<div class="register-link">
|
||||||
<a href="index.php?pfad=register">
|
<a href="register.php">Noch keinen Account? Jetzt hier registrieren!</a>
|
||||||
Noch keinen Account? Jetzt hier registrieren!
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
+24
-29
@@ -1,47 +1,42 @@
|
|||||||
<?php
|
|
||||||
include_once 'php/controller/profile-controller.php';
|
|
||||||
$user = $user ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Content: Profil
|
Content: Profil
|
||||||
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
||||||
-->
|
-->
|
||||||
|
<?php
|
||||||
|
include_once 'php/controller/profileArticles-controller.php';
|
||||||
|
?>
|
||||||
<main class="form-page">
|
<main class="form-page">
|
||||||
<div class="flexbox">
|
<div class="flexbox">
|
||||||
<!-- Linke Spalte: Profildaten -->
|
<!-- Linke Spalte: Profildaten -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form>
|
<form>
|
||||||
<label class="input-label">Name</label>
|
<label class="input-label">Vorname</label>
|
||||||
<input type="text"
|
<input type="text" name="Vorname" class="login-input" required
|
||||||
class="login-input"
|
placeholder="Vorname"
|
||||||
readonly
|
value="<?php //DB-Daten ?>">
|
||||||
value="<?php echo htmlspecialchars($user["username"] ?? ""); ?>">
|
|
||||||
|
<label class="input-label">Nachname</label>
|
||||||
|
<input type="text" name="Nachname" class="login-input" required
|
||||||
|
placeholder="Nachname"
|
||||||
|
value="<?php //DB-Daten ?>">
|
||||||
|
|
||||||
<label class="input-label">Email-Adresse</label>
|
<label class="input-label">Email-Adresse</label>
|
||||||
<input type="email"
|
<input type="email" name="Email" class="login-input" required
|
||||||
class="login-input"
|
placeholder="mustermann@web.de"
|
||||||
readonly
|
value="<?php //DB-Daten ?>">
|
||||||
value="<?php echo htmlspecialchars($user["email"] ?? ""); ?>">
|
|
||||||
|
|
||||||
<label class="input-label">Passwort</label>
|
<label class="input-label">Passwort</label>
|
||||||
<input type="password"
|
<input type="password" name="Passwort" class="login-input"
|
||||||
class="login-input"
|
required placeholder="Passwort">
|
||||||
readonly
|
|
||||||
value="********">
|
|
||||||
</form>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=deleteAccount" class="login-button">
|
<button type="submit" class="login-button">
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="login-button delete-account-button">
|
||||||
Account löschen
|
Account löschen
|
||||||
</a>
|
</button>
|
||||||
|
</form>
|
||||||
<br><br>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=logout" class="login-button">
|
|
||||||
Abmelden
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Rechte Spalte: Eigene Beiträge -->
|
<!-- Rechte Spalte: Eigene Beiträge -->
|
||||||
|
|||||||
+11
-41
@@ -1,9 +1,3 @@
|
|||||||
<?php
|
|
||||||
include_once 'php/controller/register-controller.php';
|
|
||||||
|
|
||||||
$error = $error ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Form: Registrierung
|
Form: Registrierung
|
||||||
Funktion: Erstellung neuer Benutzerkonten
|
Funktion: Erstellung neuer Benutzerkonten
|
||||||
@@ -13,50 +7,26 @@ $error = $error ?? null;
|
|||||||
|
|
||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<form>
|
||||||
<p style="color:red;">
|
|
||||||
<?php echo htmlspecialchars($error); ?>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form method="post" action="index.php?pfad=register">
|
|
||||||
|
|
||||||
<p class="input-label">Email:</p>
|
<p class="input-label">Email:</p>
|
||||||
<input type="email"
|
<input type="email" name="email" class="login-input" placeholder="mustermann@web.de" required>
|
||||||
name="email"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="mustermann@web.de"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Vorname:</p>
|
<p class="input-label">Vorname:</p>
|
||||||
<input type="text"
|
<input type="text" name="vorname" class="login-input" placeholder="Max" required>
|
||||||
name="vorname"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Max"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Nachname:</p>
|
<p class="input-label">Nachname:</p>
|
||||||
<input type="text"
|
<input type="text" name="nachname" class="login-input" placeholder="Mustermann" required>
|
||||||
name="nachname"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Mustermann"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
<input type="password"
|
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
||||||
name="password"
|
|
||||||
class="login-input"
|
|
||||||
placeholder="Passwort"
|
|
||||||
required>
|
|
||||||
|
|
||||||
<button type="submit"
|
<div class="checkbox-wrapper">
|
||||||
value="register"
|
<label>
|
||||||
name="registerSubmit"
|
<input type="checkbox" value="remember-me"> angemeldet bleiben
|
||||||
class="login-button">
|
</label>
|
||||||
kostenlos registrieren
|
</div>
|
||||||
</button>
|
|
||||||
|
|
||||||
|
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">kostenlos registrieren</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
+50
-41
@@ -1,10 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
$results = $_SESSION["search_results"] ?? [];
|
|
||||||
$query = $_SESSION["search_query"] ?? "";
|
|
||||||
$resultCount = count($results);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Suchergebnisse
|
Seite: Suchergebnisse
|
||||||
@@ -15,81 +10,95 @@ $resultCount = count($results);
|
|||||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||||
<aside class="s-res-sidebar">
|
<aside class="s-res-sidebar">
|
||||||
|
|
||||||
<!-- Sortierfuntion Box und Such Box-->
|
<!-- Suchleiste Box -->
|
||||||
<form action="php/controller/search-results-controller.php" method="GET" class="s-res-sidebar-form">
|
|
||||||
|
|
||||||
<div class="s-res-sidebar-box">
|
<div class="s-res-sidebar-box">
|
||||||
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
||||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50" required>
|
<form action="#" method="GET" class="s-res-search-form">
|
||||||
|
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
||||||
<button type="submit" class="nav__search-button">Suchen</button>
|
<button type="submit" class="nav__search-button">Suchen</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Sortierfuntion Box -->
|
||||||
<div class="s-res-sidebar-box">
|
<div class="s-res-sidebar-box">
|
||||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||||
<?php $currentSort = $_SESSION['search_sort'] ?? 'alphabet'; ?>
|
|
||||||
<div class="s-res-filter-group">
|
<div class="s-res-filter-group">
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="alphabet" <?php echo $currentSort === 'alphabet' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<input type="radio" name="sort" value="alphabet" checked>
|
||||||
<span>Alphabetisch</span>
|
<span>Alphabetisch</span>
|
||||||
</label>
|
</label>
|
||||||
<!-- Noch disabled, da likes noch nicht implementiert-->
|
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="likes" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?> disabled>
|
<input type="radio" name="sort" value="likes">
|
||||||
<span style="color: #94a3b8;">Beliebtheit (Likes)</span>
|
<span>Beliebtheit (Likes)</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="newest" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<input type="radio" name="sort" value="newest">
|
||||||
<span>Neueste Beiträge</span>
|
<span>Neueste Beiträge</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="oldest" <?php echo $currentSort === 'oldest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<input type="radio" name="sort" value="oldest">
|
||||||
<span>Älteste Beiträge</span>
|
<span>Älteste Beiträge</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main class="s-res-main-content">
|
<main class="s-res-main-content">
|
||||||
|
|
||||||
<div class="s-res-header">
|
<div class="s-res-header">
|
||||||
<h1 class="s-res-main-title">Suchergebnisse</h1>
|
<h1 class="s-res-main-title">Suchergebnisse</h1>
|
||||||
<p class="s-res-meta"><?php echo $resultCount; ?> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</p>
|
<p class="s-res-meta">3 Treffer für Ihre Suchanfrage</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Ergebnisliste -->
|
<!-- Ergebnisliste -->
|
||||||
<div class="s-res-list">
|
<div class="s-res-list">
|
||||||
<?php
|
|
||||||
if (!empty($results)): ?>
|
|
||||||
|
|
||||||
<?php foreach ($results as $item): ?>
|
|
||||||
<div class="s-res-item">
|
|
||||||
<div class="s-res-content">
|
|
||||||
<h2 class="s-res-item-title">
|
|
||||||
<a href="index.php?pfad=showArticle&id=<?php echo $item['id']; ?>" class="s-res-link">
|
|
||||||
<?php echo htmlspecialchars($item['title']); ?>
|
|
||||||
</a>
|
|
||||||
</h2>
|
|
||||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($item['author']); ?></span></p>
|
|
||||||
</div>
|
|
||||||
<div class="s-res-arrow">→</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
elseif (isset($_SESSION["search_query"]) && $_SESSION["search_query"] !== "" && $resultCount === 0): ?>
|
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
||||||
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
<!-- TODO: Hier die Beiträge ausgeben. -->
|
||||||
<?php
|
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
<p>
|
||||||
<p>Bitte überprüfe deine Sucheingabe und versuche es erneut!</p>
|
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
||||||
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!-- Beispielbeitrag -->
|
||||||
|
<div class="s-res-item">
|
||||||
|
<div class="s-res-content">
|
||||||
|
<h2 class="s-res-item-title">
|
||||||
|
<a href="#" class="s-res-link">Pythagoras</a>
|
||||||
|
</h2>
|
||||||
|
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="s-res-arrow">→</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Beispielbeitrag -->
|
||||||
|
<div class="s-res-item">
|
||||||
|
<div class="s-res-content">
|
||||||
|
<h2 class="s-res-item-title">
|
||||||
|
<a href="#" class="s-res-link">Pythagoras</a>
|
||||||
|
</h2>
|
||||||
|
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="s-res-arrow">→</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Beispielbeitrag -->
|
||||||
|
<div class="s-res-item">
|
||||||
|
<div class="s-res-content">
|
||||||
|
<h2 class="s-res-item-title">
|
||||||
|
<a href="#" class="s-res-link">Pythagoras</a>
|
||||||
|
</h2>
|
||||||
|
<p class="s-res-author">Von: <span class="s-res-author-name">Max Mustermann</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="s-res-arrow">→</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="s-res-pagination-footer">
|
<div class="s-res-pagination-footer">
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?php
|
|
||||||
include_once 'php/controller/showArticle-controller.php';
|
|
||||||
?>
|
|
||||||
<!--
|
<!--
|
||||||
Seite: Anzeige für Beiträge
|
Seite: Anzeige für Beiträge
|
||||||
Funktion: Stellt einen übergebenen Beitrag dar.
|
Funktion: Stellt einen übergebenen Beitrag dar.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
include_once 'php/controller/showArticle-controller.php';
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- Hauptcontainer für die Beitragsansicht (Ausschließlich der Content-Bereich) -->
|
<!-- Hauptcontainer für die Beitragsansicht (Ausschließlich der Content-Bereich) -->
|
||||||
<main class="article-view-container">
|
<main class="article-view-container">
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
$user = $user ?? null;
|
|
||||||
if (!isset($_SESSION["user"])) {
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
include_once 'php/controller/showArticle-controller.php';
|
include_once 'php/controller/showArticle-controller.php';
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
@@ -28,52 +23,12 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
Jeder Beitrag muss einen Titel, Kategorie und Inhalt besitzen.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_title"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Titel enthält ungültige Zeichen oder erfüllt die Länge von 5-120 Zeichen nicht.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_content"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Der Text erlaubt eine Länge von 10 bis maximal 7.000 Zeichen (ca. 1.000 Wörter).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Die ausgewählte Kategorie ist ungültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_tags"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Ungültige Schlagworte gefunden. Erlaubt sind nur Buchstaben, Zahlen, Leerzeichen und Bindestriche (2-20 Zeichen).
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "validation_missing"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title" value="<?php if (isset($title) && !empty($title)){echo htmlspecialchars($title);} ?>" placeholder="Titel hier eingeben" required>
|
||||||
value="<?php
|
|
||||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
|
||||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_title']);
|
|
||||||
unset($_SESSION['old_title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>"
|
|
||||||
placeholder="Titel hier eingeben" required>
|
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
||||||
<?php
|
<?php if (isset($content) && !empty($content)){echo htmlspecialchars($content);} ?>
|
||||||
if (isset($content) && !empty($content)){echo htmlspecialchars($content);
|
|
||||||
}elseif (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_content']);
|
|
||||||
unset($_SESSION['old_content']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</textarea>
|
</textarea>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
@@ -131,15 +86,7 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags" value="<?php if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);} ?>" placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
value="<?php
|
|
||||||
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
|
|
||||||
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_tags']);
|
|
||||||
unset($_SESSION['old_tags']);
|
|
||||||
}
|
|
||||||
?>"
|
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ CSS für die navbar
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
@media (max-width: 800px) {
|
@media (max-width: 760px) {
|
||||||
.nav {
|
.nav {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
[]
|
|
||||||
+10
-53
@@ -1,7 +1,3 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Globales Menü, wird via PHP später in alle Seiten eingebunden
|
Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||||
-->
|
-->
|
||||||
@@ -15,27 +11,17 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<!-- Mobile navbar mit Burger-Symbol -->
|
<!-- Mobile navbar mit Burger-Symbol -->
|
||||||
<input type="checkbox" id="nav-toggle" class="nav__checkbox">
|
<input type="checkbox" id="nav-toggle" class="nav__checkbox">
|
||||||
<label for="nav-toggle" id="mobile-nav">
|
<label for="nav-toggle" id="mobile-nav">
|
||||||
<span>☰</span>
|
<span>☰</span> <!-- Burger Icon Symbol -->
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<ul id="mobile-nav" class="nav__mobile-menu">
|
<ul id="mobile-nav" class="nav__mobile-menu">
|
||||||
<li>
|
<li>
|
||||||
<label for="nav-toggle" class="nav__close-btn">×</label>
|
<label for="nav-toggle" class="nav__close-btn">×</label>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<?php if (isset($_SESSION['user'])): ?>
|
|
||||||
|
|
||||||
<li><a href="index.php?pfad=profile">Profil</a></li>
|
<li><a href="index.php?pfad=profile">Profil</a></li>
|
||||||
<li><a href="index.php?pfad=logout">Abmelden</a></li>
|
|
||||||
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</a></li>
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
|
|
||||||
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
<li><a href="index.php?pfad=login">Anmelden</a></li>
|
||||||
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
<li><a href="index.php?pfad=register">Registrieren</a></li>
|
||||||
|
<li><a href="index.php?pfad=createArticle">Beitrag erstellen</a></li>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label class="nav__mobile-label">Sprachen</label>
|
<label class="nav__mobile-label">Sprachen</label>
|
||||||
<ul class="nav__mobile-submenu">
|
<ul class="nav__mobile-submenu">
|
||||||
@@ -53,7 +39,7 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<li><a href="index.php?pfad=mathe">Mathematik</a></li>
|
<li><a href="index.php?pfad=mathe">Mathematik</a></li>
|
||||||
<li><a href="index.php?pfad=biologie">Biologie</a></li>
|
<li><a href="index.php?pfad=biologie">Biologie</a></li>
|
||||||
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
||||||
<li><a href="index.php?pfad=physik">Physik</a></li>
|
<li><a href="index.php?pfad=englisch">Physik</a></li>
|
||||||
<li><a href="index.php?pfad=informatik">Informatik</a></li>
|
<li><a href="index.php?pfad=informatik">Informatik</a></li>
|
||||||
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -99,7 +85,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=literatur">Literatur</a>
|
<a href="index.php?pfad=literatur">Literatur</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">MINT</button>
|
<button class="nav__dropdown-toggle">MINT</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -111,7 +96,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=astronomie">Astronomie</a>
|
<a href="index.php?pfad=astronomie">Astronomie</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -128,7 +112,6 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<a href="index.php?pfad=theater">Theater</a>
|
<a href="index.php?pfad=theater">Theater</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
@@ -141,40 +124,14 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__right">
|
<div class="nav__right">
|
||||||
|
<a href="index.php?pfad=profile" class="nav_item nav__link">Profil</a>
|
||||||
<?php if (isset($_SESSION['user'])): ?>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=profile" class="nav__item nav__link">
|
|
||||||
Profil
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="nav__search">
|
<div class="nav__search">
|
||||||
<?php include_once 'search.php'; ?>
|
<?php
|
||||||
|
include_once 'search.php';
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="index.php?pfad=login" class="nav__item nav__button">Anmelden</a>
|
||||||
<a href="index.php?pfad=createArticle" class="nav__item nav__button">
|
<a href="index.php?pfad=register" class="nav__item nav__button">Registrieren</a>
|
||||||
Beitrag erstellen
|
<a href="index.php?pfad=createArticle" class="nav__item nav__button">Beitrag erstellen</a>
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=logout" class="nav__item nav__button">
|
|
||||||
Abmelden
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
|
|
||||||
<div class="nav__search">
|
|
||||||
<?php include_once 'search.php'; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=login" class="nav__item nav__button">
|
|
||||||
Anmelden
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="index.php?pfad=register" class="nav__item nav__button">
|
|
||||||
Registrieren
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
+1
-6
@@ -2,10 +2,5 @@
|
|||||||
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
||||||
-->
|
-->
|
||||||
<!--<label for="site-search">Suche</label>-->
|
<!--<label for="site-search">Suche</label>-->
|
||||||
<form action="php/controller/search-results-controller.php" method="GET" class="search-form" style="display: flex; align-items: center; gap: 5px;">
|
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
||||||
|
|
||||||
<input type="hidden" name="pfad" value="search-results">
|
|
||||||
|
|
||||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" maxlength="50" required>
|
|
||||||
<button type="submit" class="nav__search-button">Suchen</button>
|
<button type="submit" class="nav__search-button">Suchen</button>
|
||||||
</form>
|
|
||||||
|
|||||||
@@ -1,31 +1,10 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
ob_start();
|
if (!isset($abs_path)) {
|
||||||
|
require_once "path.php";
|
||||||
$pfad = $_GET["pfad"] ?? "home";
|
|
||||||
|
|
||||||
/*
|
|
||||||
Controller für Aktionen werden vor der HTML-Ausgabe geladen,
|
|
||||||
damit Weiterleitungen mit header() funktionieren.
|
|
||||||
*/
|
|
||||||
if ($pfad === "login") {
|
|
||||||
include_once "php/controller/login-controller.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pfad === "register") {
|
|
||||||
include_once "php/controller/register-controller.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pfad === "logout") {
|
|
||||||
include_once "content/logout.php";
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pfad === "deleteAccount") {
|
|
||||||
include_once "content/deleteAccount.php";
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
require_once $abs_path . "/php/controller/index-controller.php";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -56,28 +35,18 @@ if ($pfad === "deleteAccount") {
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once 'includes/navbar.php';
|
include_once 'includes/navbar.php';
|
||||||
|
//Dynamischer Inhalt:
|
||||||
/*
|
|
||||||
Dynamischer Inhalt:
|
|
||||||
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
|
||||||
*/
|
|
||||||
if (isset($_GET["pfad"])) {
|
if (isset($_GET["pfad"])) {
|
||||||
if (file_exists('content/' . $_GET["pfad"] . '.php')) {
|
if (file_exists($abs_path . '/content/' . $_GET["pfad"] . '.php')) {
|
||||||
include_once 'content/' . $_GET["pfad"] . '.php';
|
include_once $abs_path . '/content/' . $_GET["pfad"] . '.php';
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/404.php';
|
include_once $abs_path . '/content/404.php';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/home.php';
|
include_once $abs_path . '/content/home.php';
|
||||||
}
|
}
|
||||||
|
include_once $abs_path . '/includes/footer.php';
|
||||||
include_once 'includes/footer.php';
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
|
||||||
<?php
|
</html>
|
||||||
ob_end_flush();
|
|
||||||
?>
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
// mit $_SERVER['DOCUMENT_ROOT'] später umbauen?
|
|
||||||
$abs_path = __DIR__;
|
$abs_path = __DIR__;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,89 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
SESSION_START();
|
session_start();
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../validator/article-validator.php';
|
|
||||||
require_once "../model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
|
||||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
|
||||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
|
||||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
|
||||||
|
|
||||||
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
if(!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
header("location: ../../index.php?pfad=createArticle");
|
||||||
exit();
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
$content = $_POST["content"];
|
$content = $_POST["content"];
|
||||||
$author = $_SESSION["user_email"];
|
|
||||||
$category = $_POST["category"];
|
$category = $_POST["category"];
|
||||||
$tags = $_POST['tags'] ?? '';
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||||
|
$tags = $_POST["tags"];
|
||||||
|
|
||||||
// -------------------------------- Validierung der Daten: -------------------------
|
|
||||||
if (!articleAuthorValidator($author)) {
|
|
||||||
$_SESSION["message"] = "author_not_valid";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
|
||||||
$_SESSION["message"] = "invalid_title";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
|
||||||
$_SESSION["message"] = "invalid_content";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
|
||||||
$_SESSION["message"] = "invalid_category";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
|
||||||
$_SESSION["message"] = "invalid_tags";
|
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
$cleanedTags = [];
|
|
||||||
$rawTags = explode(',', $tags);
|
|
||||||
foreach ($rawTags as $rawTag) {
|
|
||||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
|
||||||
$tag = trim($rawTag);
|
|
||||||
$cleanedTags[] = $tag;
|
|
||||||
}
|
|
||||||
// Duplikate entfernen:
|
|
||||||
$cleanedTags = array_unique($cleanedTags);
|
|
||||||
$cleanedTags = implode(',', $cleanedTags);
|
|
||||||
}
|
|
||||||
// ----------------- Übertragung der validierten Daten in ArticleManager: ---------------------------
|
|
||||||
try {
|
try {
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$articleManager->addArticle($title, $content, $author, $category, $cleanedTags);
|
$articleManager->addArticle($title, $content, $author, $category, $tags);
|
||||||
|
|
||||||
// Formulardaten nach erfolgreichem Erstellen aus der Session löschen
|
|
||||||
unset($_SESSION["old_title"], $_SESSION["old_content"], $_SESSION["old_category"], $_SESSION["old_tags"]);
|
|
||||||
|
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
header("location: ../../index.php?pfad=createArticle");
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["message"] = "new_article";
|
$_SESSION["message"] = "new_article";
|
||||||
// Weiterleitung zur Homepage
|
// Weiterleitung zur Homepage
|
||||||
header("location: ../../index.php");
|
header("location: ../../index.php");
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$error = null;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Verarbeitung des Login-Formulars
|
|
||||||
Funktion: Prüft Benutzerdaten und erstellt Session für eingeloggten Nutzer
|
|
||||||
*/
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
|
|
||||||
$email = $_POST["email"] ?? "";
|
|
||||||
$password = $_POST["password"] ?? "";
|
|
||||||
|
|
||||||
$user = $dao->findUser($email);
|
|
||||||
|
|
||||||
if ($user && password_verify($password, $user["password"])) {
|
|
||||||
|
|
||||||
$_SESSION["user"] = $user["username"];
|
|
||||||
$_SESSION["user_email"] = $user["email"];
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
require_once 'php/model/Article.php';
|
|
||||||
require_once 'php/model/ArticleManager.php';
|
|
||||||
|
|
||||||
if (!isset($_SESSION["user"])) {
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
|
||||||
$userArticles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]);
|
|
||||||
if(!isset($userArticles)) {
|
|
||||||
$_SESSION["message"] = "user_has_no_articles";
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$_SESSION["message"] = "internal_error";
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
@@ -3,15 +3,12 @@
|
|||||||
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
|
* Controller für die Liste der eigenen Beiträge eines Nutzers auf der eigenen Profilseite
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
session_start();
|
||||||
require_once 'php/model/Article.php';
|
require_once 'php/model/Article.php';
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once 'php/model/ArticleManager.php';
|
||||||
require_once "../model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dao = new LocalUserDAO();
|
$author = "max.mustermann"; // TODO: später Nutzer aus der Session beziehen.
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
|
||||||
|
|
||||||
$author = $user["email"];
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$userArticles = $articleManager->getArticlesByAuthor($author);
|
$userArticles = $articleManager->getArticlesByAuthor($author);
|
||||||
if(!isset($userArticles)) {
|
if(!isset($userArticles)) {
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$error = null;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Verarbeitung des Registrierungs-Formulars
|
|
||||||
Funktion: Erstellt neuen Benutzer und speichert ihn im DAO + Session
|
|
||||||
*/
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
||||||
|
|
||||||
$email = $_POST["email"] ?? "";
|
|
||||||
$vorname = $_POST["vorname"] ?? "";
|
|
||||||
$nachname = $_POST["nachname"] ?? "";
|
|
||||||
$password = password_hash(
|
|
||||||
$_POST["password"] ?? "",
|
|
||||||
PASSWORD_DEFAULT
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($dao->findUser($email)) {
|
|
||||||
|
|
||||||
$error = "Diese E-Mail-Adresse ist bereits registriert.";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$dao->addUser(
|
|
||||||
$email,
|
|
||||||
$vorname . " " . $nachname,
|
|
||||||
$password
|
|
||||||
);
|
|
||||||
|
|
||||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
|
||||||
$_SESSION["user_email"] = $email;
|
|
||||||
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,67 +2,28 @@
|
|||||||
session_start();
|
session_start();
|
||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../model/Article.php';
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
if(!isset($_POST["search"])){
|
||||||
$search = trim($_GET["q"]);
|
|
||||||
if (empty($search)) {
|
|
||||||
$_SESSION["search_results"] = [];
|
|
||||||
$_SESSION["search_query"] = "";
|
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
|
header("location: ../../index.php?pfad=search-results");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
$search = $_POST["search"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
|
$articleManager->search($search); // TODO: Methode implementieren.
|
||||||
$results = $articleManager->search($search);
|
|
||||||
|
|
||||||
$sortStyle = $_GET['sort'] ?? 'alphabet';
|
|
||||||
$_SESSION['search_sort'] = $sortStyle;
|
|
||||||
|
|
||||||
if ($sortStyle === 'alphabet') {
|
|
||||||
// Titel aufsteigend alphabetiisch sortiert
|
|
||||||
usort($results, function($a, $b) {
|
|
||||||
return strcasecmp($a->title, $b->title);
|
|
||||||
});
|
|
||||||
} elseif ($sortStyle === 'newest') {
|
|
||||||
// Datum neu zu alt sortiert
|
|
||||||
usort($results, function($a, $b) {
|
|
||||||
return strcmp($b->creationDate, $a->creationDate);
|
|
||||||
});
|
|
||||||
} elseif ($sortStyle === 'oldest') {
|
|
||||||
// Datum alt zu neu sortiert
|
|
||||||
usort($results, function($a, $b) {
|
|
||||||
return strcmp($a->creationDate, $b->creationDate);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ergebnisse werden in ein flaches array umgewandelt, da sont incomplete-PHP error im Ergebnis
|
|
||||||
$safeArrayResults = [];
|
|
||||||
foreach ($results as $obj) {
|
|
||||||
$safeArrayResults[] = [
|
|
||||||
"id" => $obj->id,
|
|
||||||
"title" => $obj->title,
|
|
||||||
"content" => $obj->content,
|
|
||||||
"author" => $obj->author,
|
|
||||||
"category" => $obj->category,
|
|
||||||
"tags" => $obj->tags,
|
|
||||||
"creationDate" => $obj->creationDate
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SESSION["search_results"] = $safeArrayResults;
|
|
||||||
$_SESSION["search_query"] = $search;
|
|
||||||
$_SESSION["message"] = "new_search_results";
|
|
||||||
|
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
}
|
}
|
||||||
}
|
$_SESSION["message"] = "new_search_results";
|
||||||
header("Location: ../../index.php?pfad=search-results");
|
// TODO: Liste mit Artikeln in der Suchreihenfolge übertragen.
|
||||||
|
// Weiterleitung zur Suchergebnisanzeige
|
||||||
|
header("location: ../../index.php?pfad=search-results");
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -3,7 +3,7 @@ session_start();
|
|||||||
require_once 'php/model/Article.php';
|
require_once 'php/model/Article.php';
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once 'php/model/ArticleManager.php';
|
||||||
|
|
||||||
if (isset($_GET["id"]) && !empty($_GET["id"])){
|
if (isset($_GET["id"])){
|
||||||
try {
|
try {
|
||||||
$id = $_GET["id"];
|
$id = $_GET["id"];
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
@@ -15,15 +15,12 @@ if (isset($_GET["id"]) && !empty($_GET["id"])){
|
|||||||
$author = $article->getAuthor();
|
$author = $article->getAuthor();
|
||||||
$tags = $article->getTags();
|
$tags = $article->getTags();
|
||||||
}else{
|
}else{
|
||||||
//header("location: index.php?pfad=404");
|
$_SESSION["message"] = "article_not_found";
|
||||||
include_once "content/404.php";
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$_SESSION["message"] = "missing_id";
|
$_SESSION["message"] = "article_not_found";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -3,93 +3,44 @@ session_start();
|
|||||||
require_once '../model/LocalArticleManager.php';
|
require_once '../model/LocalArticleManager.php';
|
||||||
require_once '../model/ArticleManager.php';
|
require_once '../model/ArticleManager.php';
|
||||||
require_once '../model/Article.php';
|
require_once '../model/Article.php';
|
||||||
require_once '../validator/article-validator.php';
|
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
try {
|
||||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
|
||||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
|
||||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
|
||||||
|
|
||||||
if (isset($_GET["id"]) && !empty($_GET["id"])) {
|
|
||||||
$id = $_GET["id"];
|
$id = $_GET["id"];
|
||||||
} else {
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "missing_id";
|
$_SESSION["message"] = "missing_id";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle");
|
||||||
exit();
|
} elseif(!isset($id)) {
|
||||||
|
$_SESSION["message"] = "missing_id";
|
||||||
|
//header("location: ../../index.php?pfad=updateArticle");
|
||||||
}else{
|
}else{
|
||||||
$title = $_POST["title"];
|
|
||||||
$content = $_POST["content"];
|
$newTitle = $_POST["title"];
|
||||||
|
$newContent = $_POST["content"];
|
||||||
|
$newCategory = $_POST["category"];
|
||||||
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
||||||
$category = $_POST["category"];
|
$newTags = $_POST["tags"];
|
||||||
$tags = $_POST['tags'] ?? '';
|
|
||||||
|
|
||||||
// -------------------------------- Validierung der Daten: -------------------------
|
|
||||||
if (!articleAuthorValidator($author)) {
|
|
||||||
$_SESSION["message"] = "author_not_valid";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
|
||||||
$_SESSION["message"] = "invalid_title";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
|
||||||
$_SESSION["message"] = "invalid_content";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
|
||||||
$_SESSION["message"] = "invalid_category";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
|
||||||
$_SESSION["message"] = "invalid_tags";
|
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
$cleanedTags = [];
|
|
||||||
$rawTags = explode(',', $tags);
|
|
||||||
foreach ($rawTags as $rawTag) {
|
|
||||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
|
||||||
$tag = trim($rawTag);
|
|
||||||
$cleanedTags[] = $tag;
|
|
||||||
}
|
|
||||||
// Duplikate entfernen:
|
|
||||||
$cleanedTags = array_unique($cleanedTags);
|
|
||||||
$cleanedTags = implode(',', $cleanedTags);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------- Übertragung der validierten Daten in ArticleManager: ---------------------------
|
|
||||||
try {
|
try {
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance(); // TODO: Später aus Session den Nutzer auslesen und Autorenrechte prüfen!
|
||||||
$article = $articleManager->getArticle($id);
|
$article = $articleManager->getArticle($id);
|
||||||
$article->setTitle($title);
|
$article->setTitle($newTitle);
|
||||||
$article->setContent($content);
|
$article->setContent($newContent);
|
||||||
$article->setCategory($category);
|
$article->setCategory($newCategory);
|
||||||
$article->setTags($cleanedTags);
|
$article->setTags($newTags);
|
||||||
$articleManager->updateArticle($id ,$article, $author);
|
$articleManager->updateArticle($id ,$article, $author);
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
$_SESSION["message"] = "article_updated";
|
$_SESSION["message"] = "article_updated";
|
||||||
// Weiterleitung zur Homepage
|
// Weiterleitung zur Homepage
|
||||||
header("location: ../../index.php?pfad=showArticle&id=$id");
|
header("location: ../../index.php?pfad=showArticle&id=$id");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -7,13 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
class Article
|
class Article
|
||||||
{
|
{
|
||||||
public $id;
|
private $id;
|
||||||
public $title;
|
private $title;
|
||||||
public $content;
|
private $content;
|
||||||
public $author;
|
private $author;
|
||||||
public $creationDate;
|
private $creationDate;
|
||||||
public $category;
|
private $category;
|
||||||
public $tags;
|
private $tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor
|
* Konstruktor
|
||||||
|
|||||||
@@ -44,5 +44,4 @@ class ArticleManager extends LocalArticleManager
|
|||||||
|
|
||||||
return $articleManager;
|
return $articleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -67,15 +67,5 @@ interface ArticleManagerDAO
|
|||||||
*/
|
*/
|
||||||
public function getArticlesByAuthor($author);
|
public function getArticlesByAuthor($author);
|
||||||
|
|
||||||
/**
|
|
||||||
* Durchsucht die vorhandenen Beiträge nach einem bestimmten Suchbegriff.
|
|
||||||
* Die Suche prüft, ob das übergebene Keyword im Titel oder im Inhalt eines Beitrags vorkommt.
|
|
||||||
* (Unabhängig von Groß-und Kleinschreibung)
|
|
||||||
* @param string $keyword Der eingegebene Suchbegriff.
|
|
||||||
* @return array Ein Array von Artikeln ,die dem Suchkriterium entsprechen. Wenn nichts gefunden wird, ein leeres Array.
|
|
||||||
*/
|
|
||||||
public function search(string $keyword): array;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -168,40 +168,5 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
}
|
}
|
||||||
return $filteredArticles;
|
return $filteredArticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function search(string $keyword): array
|
|
||||||
{
|
|
||||||
$articles = $this->getAllArticles();
|
|
||||||
$filteredArticles = [];
|
|
||||||
|
|
||||||
if (!is_array($articles)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$cleanKeyword = strtolower(trim($keyword));
|
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
|
||||||
$title = isset($article['title']) ? strtolower((string)$article['title']) : '';
|
|
||||||
$content = isset($article['content']) ? strtolower((string)$article['content']) : '';
|
|
||||||
|
|
||||||
if (($cleanKeyword !== '' && strpos($title, $cleanKeyword) !== false) ||
|
|
||||||
($cleanKeyword !== '' && strpos($content, $cleanKeyword) !== false)) {
|
|
||||||
|
|
||||||
$filteredArticles[] = new Article(
|
|
||||||
intval($article['id'] ?? 0),
|
|
||||||
$article['title'] ?? '',
|
|
||||||
$article['content'] ?? '',
|
|
||||||
$article['author'] ?? '',
|
|
||||||
$article['category'] ?? '',
|
|
||||||
$article['tags'] ?? '',
|
|
||||||
$article['creationDate'] ?? ''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $filteredArticles;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once "UserDAOInterface.php";
|
|
||||||
|
|
||||||
class LocalUserDAO implements UserDAOInterface {
|
|
||||||
|
|
||||||
private string $file = "data/users.json";
|
|
||||||
|
|
||||||
private function loadUsers() {
|
|
||||||
if (!file_exists($this->file)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$json = file_get_contents($this->file);
|
|
||||||
$users = json_decode($json, true);
|
|
||||||
|
|
||||||
return is_array($users) ? $users : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function saveUsers($users) {
|
|
||||||
file_put_contents(
|
|
||||||
$this->file,
|
|
||||||
json_encode($users, JSON_PRETTY_PRINT)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findUser($email) {
|
|
||||||
$users = $this->loadUsers();
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
if ($user["email"] === $email) {
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addUser($email, $username, $password) {
|
|
||||||
$users = $this->loadUsers();
|
|
||||||
|
|
||||||
$users[] = [
|
|
||||||
"email" => $email,
|
|
||||||
"username" => $username,
|
|
||||||
"password" => $password
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->saveUsers($users);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteUser($email) {
|
|
||||||
$users = $this->loadUsers();
|
|
||||||
|
|
||||||
foreach ($users as $i => $user) {
|
|
||||||
if ($user["email"] === $email) {
|
|
||||||
unset($users[$i]);
|
|
||||||
$users = array_values($users);
|
|
||||||
$this->saveUsers($users);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface für den Zugriff auf Benutzerdaten.
|
|
||||||
*
|
|
||||||
* Definiert die Methoden, die jede UserDAO-Implementierung
|
|
||||||
* bereitstellen muss.
|
|
||||||
*/
|
|
||||||
interface UserDAOInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
|
||||||
*
|
|
||||||
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
|
||||||
* @return array|null Benutzerdaten als Array oder null
|
|
||||||
*/
|
|
||||||
public function findUser($email);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fügt einen neuen Benutzer hinzu.
|
|
||||||
*
|
|
||||||
* @param string $email E-Mail-Adresse des Benutzers
|
|
||||||
* @param string $username Benutzername des Benutzers
|
|
||||||
* @param string $password Passwort des Benutzers
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addUser($email, $username, $password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
|
||||||
*
|
|
||||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
|
||||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
|
||||||
*/
|
|
||||||
public function deleteUser($email);
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Autor auch der Eigentümer des Beitrags ist.
|
|
||||||
* @param $author
|
|
||||||
* @return true
|
|
||||||
* TODO: Implement this.
|
|
||||||
*/
|
|
||||||
function articleAuthorValidator($author)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Titel die folgenden Bedingungen erfüllt:
|
|
||||||
* Buchstaben von a-z; A-Z
|
|
||||||
* Zahlen von 0-9
|
|
||||||
* Umlaute äöüÄÖÜß
|
|
||||||
* Satzeichen .,!?:;()"„“«»_+-
|
|
||||||
* 5-120 Zeichen
|
|
||||||
* @param $title
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleTitleValidator($title)
|
|
||||||
{
|
|
||||||
$title = trim($title);
|
|
||||||
$titlePattern = '/^[a-zA-Z0-9äöüÄÖÜß\s.,!?:;()\'"„“«»_+-]{5,120}$/u';
|
|
||||||
if (preg_match($titlePattern, $title)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob der Contenttext 10-7000 Zeichen enthält.
|
|
||||||
* @param $content
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleContentValidator($content)
|
|
||||||
{
|
|
||||||
$content = trim($content);
|
|
||||||
$zeichenAnzahl = mb_strlen($content);
|
|
||||||
if ($zeichenAnzahl <= 7000 && $zeichenAnzahl >= 10) {
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob die Kategorie eine erlaubt Kategorie ist.
|
|
||||||
* @param $category
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleCategoryValidator($category)
|
|
||||||
{
|
|
||||||
$allowedCategories = [
|
|
||||||
'deutsch', 'englisch', 'franzoesisch', 'latein', 'literatur',
|
|
||||||
'mathe', 'biologie', 'chemie', 'physik', 'informatik', 'astronomie',
|
|
||||||
'geschichte', 'erdkunde', 'sozialkunde', 'wirtschaft', 'religion',
|
|
||||||
'ethik', 'philosophie', 'psychologie', 'kunst', 'musik', 'theater',
|
|
||||||
'technik', 'werken', 'hauswirtschaft', 'sport'
|
|
||||||
];
|
|
||||||
if (in_array($category, $allowedCategories, true)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob die Tags die folgenden Bedingungen erfüllen:
|
|
||||||
* Buchstaben von a-z; A-Z
|
|
||||||
* Zahlen von 0-9
|
|
||||||
* Umlaute äöüÄÖÜß
|
|
||||||
* Satzeichen -
|
|
||||||
* 2-50 Zeichen
|
|
||||||
* @param $tags
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function articleTagValidator($tags)
|
|
||||||
{
|
|
||||||
if (!isset($tags)) {
|
|
||||||
$tags = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rawTags = explode(',', $tags);
|
|
||||||
|
|
||||||
foreach ($rawTags as $rawTag) {
|
|
||||||
// Leerzeichen am Anfang/Ende des einzelnen Tags entfernen:
|
|
||||||
$tag = trim($rawTag);
|
|
||||||
|
|
||||||
// leere Elemente überspringen:
|
|
||||||
if ($tag === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tag mit Regex prüfen:
|
|
||||||
$tagPattern = '/^[a-zA-Z0-9äöüÄÖÜß\s-]{2,50}$/u';
|
|
||||||
if (!preg_match($tagPattern, $tag)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user