Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1314362df9 | |||
| 5a1c032f1b | |||
| fae4bc86ad | |||
| 664092d52f | |||
| 22b1dd827d | |||
| 50df844e23 | |||
| 45b6b41d60 | |||
| a0a79e0191 | |||
| bfc9ee4d01 | |||
| 92574a0f76 | |||
| ade73f3105 | |||
| ee75620cd8 | |||
| 94486e2b0a |
@@ -4,14 +4,6 @@
|
|||||||
-->
|
-->
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Es ist ein interner Fehler beim Speichern aufgetreten. Bitte versuche es erneut.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
|
||||||
?>
|
|
||||||
<h1>404 - Seite nicht vorhanden</h1>
|
<h1>404 - Seite nicht vorhanden</h1>
|
||||||
<p>
|
<p>
|
||||||
Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden.
|
Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden.
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ include_once 'php/controller/home-controller.php';
|
|||||||
Dein Beitrag wurde erfolgreich veröffentlicht!
|
Dein Beitrag wurde erfolgreich veröffentlicht!
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "invalid_category"): ?>
|
|
||||||
<p class="alert-message is-error">
|
|
||||||
Diese Kategorie ist nicht gültig.
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
|
|||||||
+104
-30
@@ -1,36 +1,84 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once 'php/controller/profile-controller.php';
|
include_once 'php/controller/profile-controller.php';
|
||||||
$user = $user ?? null;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!--
|
$user = $user ?? null;
|
||||||
Content: Profil
|
$isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
||||||
Inhalt: Das eigene Profil, wenn man angemeldet ist. Dort hat man die Möglichkeit seine Angaben zu ändern.
|
?>
|
||||||
-->
|
|
||||||
|
|
||||||
<main class="form-page">
|
<main class="form-page">
|
||||||
<div class="flexbox">
|
<div class="flexbox">
|
||||||
<!-- Linke Spalte: Profildaten -->
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form>
|
|
||||||
<label class="input-label">Name</label>
|
<?php if (!empty($error)): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
<?php echo htmlspecialchars($error); ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="post" action="index.php?pfad=profile">
|
||||||
|
|
||||||
|
<label class="input-label">Vorname</label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
|
name="vorname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
readonly
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? $user["vorname"] ?? ""); ?>"
|
||||||
value="<?php echo htmlspecialchars($user["username"] ?? ""); ?>">
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
|
required>
|
||||||
|
|
||||||
|
<label class="input-label">Nachname</label>
|
||||||
|
<input type="text"
|
||||||
|
name="nachname"
|
||||||
|
class="login-input"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? $user["nachname"] ?? ""); ?>"
|
||||||
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
|
required>
|
||||||
|
|
||||||
<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"
|
class="login-input"
|
||||||
readonly
|
value="<?php echo htmlspecialchars($_POST["email"] ?? $user["email"] ?? ""); ?>"
|
||||||
value="<?php echo htmlspecialchars($user["email"] ?? ""); ?>">
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
|
required>
|
||||||
|
|
||||||
|
<label class="input-label">
|
||||||
|
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<?php if ($isEditMode): ?>
|
||||||
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Leer lassen, wenn es gleich bleiben soll">
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
value="********"
|
||||||
|
readonly>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<?php if ($isEditMode): ?>
|
||||||
|
<button type="submit"
|
||||||
|
name="saveProfile"
|
||||||
|
class="button">
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a href="index.php?pfad=profile" class="button">
|
||||||
|
Abbrechen
|
||||||
|
</a>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="index.php?pfad=profile&edit=1" class="button">
|
||||||
|
Bearbeiten
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<label class="input-label">Passwort</label>
|
|
||||||
<input type="password"
|
|
||||||
class="login-input"
|
|
||||||
readonly
|
|
||||||
value="********">
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="index.php?pfad=deleteAccount" class="button">
|
<a href="index.php?pfad=deleteAccount" class="button">
|
||||||
@@ -44,36 +92,53 @@ $user = $user ?? null;
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Rechte Spalte: Eigene Beiträge -->
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2 class="section-title">Meine Beiträge</h2>
|
<h2 class="section-title">Meine Beiträge</h2>
|
||||||
|
|
||||||
<div class="articles-list">
|
<div class="articles-list">
|
||||||
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "internal_error"): ?>
|
||||||
|
|
||||||
<p class="alert-message is-error">
|
<p class="alert-message is-error">
|
||||||
Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.
|
Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php elseif (isset($userArticles) && count($userArticles) > 0): ?>
|
<?php elseif (isset($userArticles) && count($userArticles) > 0): ?>
|
||||||
|
|
||||||
<?php foreach ($userArticles as $userArticle): ?>
|
<?php foreach ($userArticles as $userArticle): ?>
|
||||||
<!-- Ein einzelner Artikel-Eintrag -->
|
|
||||||
<div class="article-item">
|
<div class="article-item">
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<span class="article-date"><?php echo htmlspecialchars($userArticle->getCreationDate()); ?></span>
|
<span class="article-date">
|
||||||
<span class="article-category"><?php echo htmlspecialchars($userArticle->getCategory()); ?></span>
|
<?php echo htmlspecialchars($userArticle->getCreationDate()); ?>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="article-category">
|
||||||
|
<?php echo htmlspecialchars($userArticle->getCategory()); ?>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="article-title"><?php echo htmlspecialchars($userArticle->getTitle()); ?></h3>
|
|
||||||
|
<h3 class="article-title">
|
||||||
|
<?php echo htmlspecialchars($userArticle->getTitle()); ?>
|
||||||
|
</h3>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$tags = $userArticle->getTags();
|
$tags = $userArticle->getTags();
|
||||||
if (isset($tags) && !empty($tags)): ?>
|
if (isset($tags) && !empty($tags)):
|
||||||
|
?>
|
||||||
<div class="article-view-bottom-section">
|
<div class="article-view-bottom-section">
|
||||||
<div class="article-view-tags-label">Tags:</div>
|
<div class="article-view-tags-label">Tags:</div>
|
||||||
|
|
||||||
<div class="article-view-tags-list">
|
<div class="article-view-tags-list">
|
||||||
<?php
|
<?php
|
||||||
$tagArray = is_array($tags) ? $tags : explode(',', $tags);
|
$tagArray = is_array($tags) ? $tags : explode(',', $tags);
|
||||||
|
|
||||||
foreach ($tagArray as $tag):
|
foreach ($tagArray as $tag):
|
||||||
$trimmedTag = trim($tag);
|
$trimmedTag = trim($tag);
|
||||||
|
|
||||||
if (!empty($trimmedTag)):
|
if (!empty($trimmedTag)):
|
||||||
?>
|
?>
|
||||||
<span class="article-view-tag-item"><?php echo htmlspecialchars($trimmedTag); ?></span>
|
<span class="article-view-tag-item">
|
||||||
|
<?php echo htmlspecialchars($trimmedTag); ?>
|
||||||
|
</span>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
@@ -81,18 +146,27 @@ $user = $user ?? null;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>" class="edit-link-button">Bearbeiten</a>
|
|
||||||
|
<a href="index.php?pfad=updateArticle&id=<?php echo $userArticle->getID(); ?>"
|
||||||
|
class="edit-link-button">
|
||||||
|
Bearbeiten
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<p>Du hast noch keine Beiträge erstellt.</p>
|
<p>Du hast noch keine Beiträge erstellt.</p>
|
||||||
<button type="button" class="button" onclick="window.location.href='index.php?pfad=createArticle';">
|
|
||||||
|
<button type="button"
|
||||||
|
class="button"
|
||||||
|
onclick="window.location.href='index.php?pfad=createArticle';">
|
||||||
Beitrag erstellen!
|
Beitrag erstellen!
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php
|
|
||||||
unset($_SESSION["message"]);
|
<?php unset($_SESSION["message"]); ?>
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once 'php/controller/register-controller.php';
|
|
||||||
|
|
||||||
$error = $error ?? null;
|
$error = $error ?? null;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -13,8 +11,8 @@ $error = $error ?? null;
|
|||||||
|
|
||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<?php if (!empty($error)): ?>
|
||||||
<p style="color:red;">
|
<p class="alert-message is-error" style="color:red;">
|
||||||
<?php echo htmlspecialchars($error); ?>
|
<?php echo htmlspecialchars($error); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -26,6 +24,7 @@ $error = $error ?? null;
|
|||||||
name="email"
|
name="email"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="mustermann@web.de"
|
placeholder="mustermann@web.de"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Vorname:</p>
|
<p class="input-label">Vorname:</p>
|
||||||
@@ -33,6 +32,7 @@ $error = $error ?? null;
|
|||||||
name="vorname"
|
name="vorname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="Max"
|
placeholder="Max"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Nachname:</p>
|
<p class="input-label">Nachname:</p>
|
||||||
@@ -40,6 +40,7 @@ $error = $error ?? null;
|
|||||||
name="nachname"
|
name="nachname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="Mustermann"
|
placeholder="Mustermann"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
|
|||||||
+69
-60
@@ -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,40 +10,37 @@ $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">
|
||||||
|
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
||||||
<div class="s-res-sidebar-box">
|
<form action="#" method="GET" class="s-res-search-form">
|
||||||
<h3 class="s-res-sidebar-title">Suche anpassen</h3>
|
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
||||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50" required>
|
|
||||||
<button type="submit" class="nav__search-button">Suchen</button>
|
<button type="submit" class="nav__search-button">Suchen</button>
|
||||||
</div>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="s-res-sidebar-box">
|
<!-- Sortierfuntion Box -->
|
||||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
<div class="s-res-sidebar-box">
|
||||||
<?php $currentSort = $_SESSION['search_sort'] ?? 'alphabet'; ?>
|
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||||
<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">
|
||||||
<input type="radio" name="sort" value="likes" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?> disabled>
|
<span>Beliebtheit (Likes)</span>
|
||||||
<span style="color: #94a3b8;">Beliebtheit (Likes)</span>
|
</label>
|
||||||
</label>
|
<label class="s-res-filter-option">
|
||||||
<label class="s-res-filter-option">
|
<input type="radio" name="sort" value="newest">
|
||||||
<input type="radio" name="sort" value="newest" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<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">
|
||||||
<input type="radio" name="sort" value="oldest" <?php echo $currentSort === 'oldest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<span>Älteste Beiträge</span>
|
||||||
<span>Älteste Beiträge</span>
|
</label>
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
@@ -56,40 +48,57 @@ $resultCount = count($results);
|
|||||||
|
|
||||||
<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,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
include_once "php/controller/showCategory-controller.php";
|
|
||||||
?>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<h1><?php if (isset($category) && !empty($category)){ echo htmlspecialchars($category); } ?></h1>
|
|
||||||
|
|
||||||
<div class="s-res-list">
|
|
||||||
<?php
|
|
||||||
if (!empty($articles)): ?>
|
|
||||||
<?php foreach ($articles as $article): ?>
|
|
||||||
<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 $article['id']; ?>" class="s-res-link">
|
|
||||||
<?php echo htmlspecialchars($article['title']); ?>
|
|
||||||
</a>
|
|
||||||
</h2>
|
|
||||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($article['author']); ?></span></p>
|
|
||||||
</div>
|
|
||||||
<div class="s-res-arrow">→</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php
|
|
||||||
else: ?>
|
|
||||||
<p> Es sind noch keine Beiträge in dieser Kategorie enthalten.</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
@@ -22,10 +22,6 @@ a, button, input, select, textarea, label, main{
|
|||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flexbox {
|
.flexbox {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
+52
-52
@@ -39,50 +39,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<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">
|
||||||
<li><a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a></li>
|
<li><a href="index.php?pfad=deutsch">Deutsch</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=englisch">Englisch</a></li>
|
<li><a href="index.php?pfad=englisch">Englisch</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a></li>
|
<li><a href="index.php?pfad=franzoesisch">Französisch</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=latein">Latein</a></li>
|
<li><a href="index.php?pfad=latein">Latein</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=literatur">Literatur</a></li>
|
<li><a href="index.php?pfad=literatur">Literatur</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label class="nav__mobile-label">MINT</label>
|
<label class="nav__mobile-label">MINT</label>
|
||||||
<ul class="nav__mobile-submenu">
|
<ul class="nav__mobile-submenu">
|
||||||
<li><a href="index.php?pfad=showCategory&category=mathe">Mathematik</a></li>
|
<li><a href="index.php?pfad=mathe">Mathematik</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=biologie">Biologie</a></li>
|
<li><a href="index.php?pfad=biologie">Biologie</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=chemie">Chemie</a></li>
|
<li><a href="index.php?pfad=chemie">Chemie</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=physik">Physik</a></li>
|
<li><a href="index.php?pfad=physik">Physik</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=informatik">Informatik</a></li>
|
<li><a href="index.php?pfad=informatik">Informatik</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a></li>
|
<li><a href="index.php?pfad=astronomie">Astronomie</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label class="nav__mobile-label">Gesellschaft & Werte</label>
|
<label class="nav__mobile-label">Gesellschaft & Werte</label>
|
||||||
<ul class="nav__mobile-submenu">
|
<ul class="nav__mobile-submenu">
|
||||||
<li><a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a></li>
|
<li><a href="index.php?pfad=geschichte">Geschichte</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a></li>
|
<li><a href="index.php?pfad=erdkunde">Erdkunde</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a></li>
|
<li><a href="index.php?pfad=sozialkunde">Sozialkunde</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a></li>
|
<li><a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=religion">Religion</a></li>
|
<li><a href="index.php?pfad=religion">Religion</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a></li>
|
<li><a href="index.php?pfad=ethik">Ethikunterricht</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a></li>
|
<li><a href="index.php?pfad=philosophie">Philosophie</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a></li>
|
<li><a href="index.php?pfad=psychologie">Psychologie</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=kunst">Kunst</a></li>
|
<li><a href="index.php?pfad=kunst">Kunst</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=musik">Musik</a></li>
|
<li><a href="index.php?pfad=musik">Musik</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=theater">Theater</a></li>
|
<li><a href="index.php?pfad=theater">Theater</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label class="nav__mobile-label">Technik & Praxis</label>
|
<label class="nav__mobile-label">Technik & Praxis</label>
|
||||||
<ul class="nav__mobile-submenu">
|
<ul class="nav__mobile-submenu">
|
||||||
<li><a href="index.php?pfad=showCategory&category=technik">Technik</a></li>
|
<li><a href="index.php?pfad=technik">Technik</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=werken">Werken</a></li>
|
<li><a href="index.php?pfad=werken">Werken</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a></li>
|
<li><a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a></li>
|
||||||
<li><a href="index.php?pfad=showCategory&category=sport">Sport</a></li>
|
<li><a href="index.php?pfad=sport">Sport</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -92,50 +92,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
|||||||
<div class="nav__item nav__dropdown">
|
<div class="nav__item nav__dropdown">
|
||||||
<button class="nav__dropdown-toggle">Sprachen</button>
|
<button class="nav__dropdown-toggle">Sprachen</button>
|
||||||
<div class="nav__dropdown-menu">
|
<div class="nav__dropdown-menu">
|
||||||
<a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a>
|
<a href="index.php?pfad=deutsch">Deutsch</a>
|
||||||
<a href="index.php?pfad=showCategory&category=englisch">Englisch</a>
|
<a href="index.php?pfad=englisch">Englisch</a>
|
||||||
<a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a>
|
<a href="index.php?pfad=franzoesisch">Französisch</a>
|
||||||
<a href="index.php?pfad=showCategory&category=latein">Latein</a>
|
<a href="index.php?pfad=latein">Latein</a>
|
||||||
<a href="index.php?pfad=showCategory&category=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">
|
||||||
<a href="index.php?pfad=showCategory&category=mathe">Mathematik</a>
|
<a href="index.php?pfad=mathe">Mathematik</a>
|
||||||
<a href="index.php?pfad=showCategory&category=biologie">Biologie</a>
|
<a href="index.php?pfad=biologie">Biologie</a>
|
||||||
<a href="index.php?pfad=showCategory&category=chemie">Chemie</a>
|
<a href="index.php?pfad=chemie">Chemie</a>
|
||||||
<a href="index.php?pfad=showCategory&category=physik">Physik</a>
|
<a href="index.php?pfad=physik">Physik</a>
|
||||||
<a href="index.php?pfad=showCategory&category=informatik">Informatik</a>
|
<a href="index.php?pfad=informatik">Informatik</a>
|
||||||
<a href="index.php?pfad=showCategory&category=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">
|
||||||
<a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a>
|
<a href="index.php?pfad=geschichte">Geschichte</a>
|
||||||
<a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a>
|
<a href="index.php?pfad=erdkunde">Erdkunde</a>
|
||||||
<a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a>
|
<a href="index.php?pfad=sozialkunde">Sozialkunde</a>
|
||||||
<a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a>
|
<a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a>
|
||||||
<a href="index.php?pfad=showCategory&category=religion">Religion</a>
|
<a href="index.php?pfad=religion">Religion</a>
|
||||||
<a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a>
|
<a href="index.php?pfad=ethik">Ethikunterricht</a>
|
||||||
<a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a>
|
<a href="index.php?pfad=philosophie">Philosophie</a>
|
||||||
<a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a>
|
<a href="index.php?pfad=psychologie">Psychologie</a>
|
||||||
<a href="index.php?pfad=showCategory&category=kunst">Kunst</a>
|
<a href="index.php?pfad=kunst">Kunst</a>
|
||||||
<a href="index.php?pfad=showCategory&category=musik">Musik</a>
|
<a href="index.php?pfad=musik">Musik</a>
|
||||||
<a href="index.php?pfad=showCategory&category=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">
|
||||||
<a href="index.php?pfad=showCategory&category=technik">Technik</a>
|
<a href="index.php?pfad=technik">Technik</a>
|
||||||
<a href="index.php?pfad=showCategory&category=werken">Werken</a>
|
<a href="index.php?pfad=werken">Werken</a>
|
||||||
<a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a>
|
<a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a>
|
||||||
<a href="index.php?pfad=showCategory&category=sport">Sport</a>
|
<a href="index.php?pfad=sport">Sport</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+2
-7
@@ -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">
|
||||||
|
<button type="submit" class="nav__search-button">Suchen</button>
|
||||||
<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>
|
|
||||||
</form>
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
ob_start();
|
ob_start();
|
||||||
@@ -52,8 +51,8 @@ if ($pfad === "deleteAccount") {
|
|||||||
<title>EduForge</title>
|
<title>EduForge</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
<body>
|
|
||||||
<?php
|
<?php
|
||||||
include_once 'includes/navbar.php';
|
include_once 'includes/navbar.php';
|
||||||
|
|
||||||
@@ -61,20 +60,15 @@ if ($pfad === "deleteAccount") {
|
|||||||
Dynamischer Inhalt:
|
Dynamischer Inhalt:
|
||||||
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
||||||
*/
|
*/
|
||||||
if (isset($_GET["pfad"])) {
|
if (file_exists('content/' . $pfad . '.php')) {
|
||||||
if (file_exists('content/' . $_GET["pfad"] . '.php')) {
|
include_once 'content/' . $pfad . '.php';
|
||||||
include_once 'content/' . $_GET["pfad"] . '.php';
|
|
||||||
} else {
|
|
||||||
include_once 'content/404.php';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/home.php';
|
include_once 'content/404.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once 'includes/footer.php';
|
include_once 'includes/footer.php';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
|
|
||||||
if ($user && password_verify($password, $user["password"])) {
|
if ($user && password_verify($password, $user["password"])) {
|
||||||
|
|
||||||
$_SESSION["user"] = $user["username"];
|
if (isset($user["vorname"]) && isset($user["nachname"])) {
|
||||||
|
$_SESSION["user"] = $user["vorname"] . " " . $user["nachname"];
|
||||||
|
} else {
|
||||||
|
$_SESSION["user"] = $user["username"] ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
$_SESSION["user_email"] = $user["email"];
|
$_SESSION["user_email"] = $user["email"];
|
||||||
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
@@ -27,4 +32,4 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
} else {
|
} else {
|
||||||
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserDAO.php";
|
||||||
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 "php/validator/user-validator.php";
|
||||||
|
|
||||||
|
$error = null;
|
||||||
|
|
||||||
if (!isset($_SESSION["user"])) {
|
if (!isset($_SESSION["user"])) {
|
||||||
header("Location: index.php?pfad=login");
|
header("Location: index.php?pfad=login");
|
||||||
@@ -11,21 +14,78 @@ if (!isset($_SESSION["user"])) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$dao = new LocalUserDAO();
|
$dao = new LocalUserDAO();
|
||||||
|
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
$_SESSION = [];
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header("Location: index.php?pfad=login");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["saveProfile"])) {
|
||||||
|
$oldEmail = $_SESSION["user_email"];
|
||||||
|
|
||||||
|
$newEmail = trim($_POST["email"] ?? "");
|
||||||
|
$vorname = trim($_POST["vorname"] ?? "");
|
||||||
|
$nachname = trim($_POST["nachname"] ?? "");
|
||||||
|
$password = $_POST["password"] ?? "";
|
||||||
|
|
||||||
|
if (!userEmailValidator($newEmail)) {
|
||||||
|
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userNameValidator($vorname)) {
|
||||||
|
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userNameValidator($nachname)) {
|
||||||
|
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userOptionalPasswordValidator($password)) {
|
||||||
|
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$updated = $dao->updateUser(
|
||||||
|
$oldEmail,
|
||||||
|
$newEmail,
|
||||||
|
$vorname,
|
||||||
|
$nachname,
|
||||||
|
$password
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($updated) {
|
||||||
|
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||||
|
$_SESSION["user_email"] = $newEmail;
|
||||||
|
|
||||||
|
header("Location: index.php?pfad=profile");
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$error = "Die Daten konnten nicht gespeichert werden.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||||
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
$articleManager = ArticleManager::getInstance();
|
||||||
$userArticles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]);
|
$userArticles = $articleManager->getArticlesByAuthor($_SESSION["user_email"]);
|
||||||
if(!isset($userArticles)) {
|
|
||||||
|
if (!isset($userArticles)) {
|
||||||
$_SESSION["message"] = "user_has_no_articles";
|
$_SESSION["message"] = "user_has_no_articles";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.";
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
exit();
|
$_GET["edit"] = "1";
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$_SESSION = [];
|
|
||||||
session_destroy();
|
|
||||||
|
|
||||||
header("Location: index.php?pfad=login");
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserDAO.php";
|
||||||
|
require_once "php/validator/user-validator.php";
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
/*
|
|
||||||
Verarbeitung des Registrierungs-Formulars
|
|
||||||
Funktion: Erstellt neuen Benutzer und speichert ihn im DAO + Session
|
|
||||||
*/
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
|
||||||
$email = $_POST["email"] ?? "";
|
$email = trim($_POST["email"] ?? "");
|
||||||
$vorname = $_POST["vorname"] ?? "";
|
$vorname = trim($_POST["vorname"] ?? "");
|
||||||
$nachname = $_POST["nachname"] ?? "";
|
$nachname = trim($_POST["nachname"] ?? "");
|
||||||
$password = password_hash(
|
$plainPassword = $_POST["password"] ?? "";
|
||||||
$_POST["password"] ?? "",
|
|
||||||
PASSWORD_DEFAULT
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($dao->findUser($email)) {
|
|
||||||
|
|
||||||
$error = "Diese E-Mail-Adresse ist bereits registriert.";
|
|
||||||
|
|
||||||
|
if (!userEmailValidator($email)) {
|
||||||
|
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||||
|
} elseif (!userNameValidator($vorname)) {
|
||||||
|
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
} elseif (!userNameValidator($nachname)) {
|
||||||
|
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
} elseif (!userPasswordValidator($plainPassword)) {
|
||||||
|
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
|
$dao = new LocalUserDAO();
|
||||||
|
|
||||||
$dao->addUser(
|
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
||||||
$email,
|
|
||||||
$vorname . " " . $nachname,
|
|
||||||
$password
|
|
||||||
);
|
|
||||||
|
|
||||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
$dao->addUser($email, $vorname, $nachname, $password);
|
||||||
$_SESSION["user_email"] = $email;
|
|
||||||
|
|
||||||
header("Location: index.php");
|
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||||
exit();
|
$_SESSION["user_email"] = $email;
|
||||||
|
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Die Registrierung konnte nicht gespeichert werden.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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";
|
||||||
|
// TODO: Liste mit Artikeln in der Suchreihenfolge übertragen.
|
||||||
|
// Weiterleitung zur Suchergebnisanzeige
|
||||||
|
header("location: ../../index.php?pfad=search-results");
|
||||||
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
header("Location: ../../index.php?pfad=search-results");
|
|
||||||
exit();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once 'php/model/Article.php';
|
|
||||||
require_once 'php/model/ArticleManager.php';
|
|
||||||
require_once 'php/validator/article-validator.php';
|
|
||||||
|
|
||||||
if (isset($_GET["category"]) && !empty($_GET["category"]) && articleCategoryValidator($_GET["category"])){
|
|
||||||
$category = $_GET["category"];
|
|
||||||
try {
|
|
||||||
$articleManager = ArticleManager::getInstance();
|
|
||||||
$articles = $articleManager->getArticlesByCategory($category);
|
|
||||||
echo $articles[0]->getTitle();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$_SESSION["message"] = "internal_error";
|
|
||||||
include_once "content/404.php";
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$_SESSION["message"] = "invalid_category";
|
|
||||||
include_once "content/404.php";
|
|
||||||
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
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ArticleManager extends LocalArticleManager
|
|||||||
"Satz des Pythagoras",
|
"Satz des Pythagoras",
|
||||||
"Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im dritten Jahrhundert vor Christus veröffentlicht. In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck...",
|
"Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im dritten Jahrhundert vor Christus veröffentlicht. In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck...",
|
||||||
"max.mustermann",
|
"max.mustermann",
|
||||||
"mathe",
|
"Mathe",
|
||||||
"Dreiecke, Dreiecksseiten berechnen"
|
"Dreiecke, Dreiecksseiten berechnen"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ class ArticleManager extends LocalArticleManager
|
|||||||
"Tunneleffekt",
|
"Tunneleffekt",
|
||||||
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
||||||
"max.mustermann",
|
"max.mustermann",
|
||||||
"physik",
|
"Physik",
|
||||||
"Quantenphysik, Energie"
|
"Quantenphysik, Energie"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -37,12 +37,11 @@ class ArticleManager extends LocalArticleManager
|
|||||||
"Datenschutz vs Datensicherheit",
|
"Datenschutz vs Datensicherheit",
|
||||||
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
|
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
|
||||||
"max.mustermann",
|
"max.mustermann",
|
||||||
"informatik",
|
"Informatik",
|
||||||
"Daten, DSGVO"
|
"Daten, DSGVO"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $articleManager;
|
return $articleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -76,22 +76,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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gibt alle Beiträge einer gegebenen Kategorie aus.
|
|
||||||
* @param $category
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getArticlesByCategory($category);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -166,61 +166,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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getArticlesByCategory($category)
|
|
||||||
{
|
|
||||||
$articles = $this->getAllArticles();
|
|
||||||
$filteredArticles = [];
|
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
|
||||||
if (isset($article['category']) && $article['category'] == $category) {
|
|
||||||
$filteredArticles[] = new Article(
|
|
||||||
intval($article['id']),
|
|
||||||
$article['title'],
|
|
||||||
$article['content'],
|
|
||||||
$article['author'],
|
|
||||||
$article['category'],
|
|
||||||
$article['tags'],
|
|
||||||
$article['creationDate']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $filteredArticles;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
+123
-8
@@ -1,33 +1,78 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "UserDAOInterface.php";
|
require_once "UserDAOInterface.php";
|
||||||
|
|
||||||
class LocalUserDAO implements UserDAOInterface {
|
class LocalUserDAO implements UserDAOInterface {
|
||||||
|
|
||||||
private string $file = "data/users.json";
|
private string $file = "data/users.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lädt alle Benutzer aus der JSON-Datei.
|
||||||
|
*
|
||||||
|
* @return array Liste aller Benutzer
|
||||||
|
* @throws RuntimeException wenn die Datei nicht gelesen werden kann
|
||||||
|
* oder fehlerhafte JSON-Daten enthält
|
||||||
|
*/
|
||||||
private function loadUsers() {
|
private function loadUsers() {
|
||||||
if (!file_exists($this->file)) {
|
if (!file_exists($this->file)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = file_get_contents($this->file);
|
$json = file_get_contents($this->file);
|
||||||
|
|
||||||
|
if ($json === false) {
|
||||||
|
throw new RuntimeException("Benutzerdaten konnten nicht gelesen werden.");
|
||||||
|
}
|
||||||
|
|
||||||
$users = json_decode($json, true);
|
$users = json_decode($json, true);
|
||||||
|
|
||||||
|
if ($users === null && json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
throw new RuntimeException("Benutzerdaten sind fehlerhaft.");
|
||||||
|
}
|
||||||
|
|
||||||
return is_array($users) ? $users : [];
|
return is_array($users) ? $users : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert alle Benutzer in die JSON-Datei.
|
||||||
|
*
|
||||||
|
* @param array $users Liste aller Benutzer
|
||||||
|
* @return void
|
||||||
|
* @throws RuntimeException wenn die Daten nicht gespeichert werden können
|
||||||
|
*/
|
||||||
private function saveUsers($users) {
|
private function saveUsers($users) {
|
||||||
file_put_contents(
|
$json = json_encode($users, JSON_PRETTY_PRINT);
|
||||||
$this->file,
|
|
||||||
json_encode($users, JSON_PRETTY_PRINT)
|
if ($json === false) {
|
||||||
);
|
throw new RuntimeException("Benutzerdaten konnten nicht umgewandelt werden.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = file_put_contents($this->file, $json);
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
throw new RuntimeException("Benutzerdaten konnten nicht gespeichert werden.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
|
*
|
||||||
|
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
||||||
|
* @return array|null Benutzerdaten oder null, wenn kein Benutzer gefunden wurde
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||||
|
*/
|
||||||
public function findUser($email) {
|
public function findUser($email) {
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if ($user["email"] === $email) {
|
if (isset($user["email"]) && $user["email"] === $email) {
|
||||||
|
|
||||||
|
if (!isset($user["vorname"]) && isset($user["username"])) {
|
||||||
|
$nameParts = explode(" ", $user["username"], 2);
|
||||||
|
$user["vorname"] = $nameParts[0] ?? "";
|
||||||
|
$user["nachname"] = $nameParts[1] ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,23 +80,93 @@ class LocalUserDAO implements UserDAOInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUser($email, $username, $password) {
|
/**
|
||||||
|
* Fügt einen neuen Benutzer hinzu.
|
||||||
|
*
|
||||||
|
* @param string $email E-Mail-Adresse
|
||||||
|
* @param string $vorname Vorname
|
||||||
|
* @param string $nachname Nachname
|
||||||
|
* @param string $password Passwort-Hash
|
||||||
|
* @return void
|
||||||
|
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
|
public function addUser($email, $vorname, $nachname, $password) {
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
|
foreach ($users as $user) {
|
||||||
|
if (isset($user["email"]) && $user["email"] === $email) {
|
||||||
|
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$users[] = [
|
$users[] = [
|
||||||
"email" => $email,
|
"email" => $email,
|
||||||
"username" => $username,
|
"vorname" => $vorname,
|
||||||
|
"nachname" => $nachname,
|
||||||
"password" => $password
|
"password" => $password
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->saveUsers($users);
|
$this->saveUsers($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert einen bestehenden Benutzer.
|
||||||
|
*
|
||||||
|
* @param string $oldEmail Alte E-Mail-Adresse
|
||||||
|
* @param string $newEmail Neue E-Mail-Adresse
|
||||||
|
* @param string $vorname Neuer Vorname
|
||||||
|
* @param string $nachname Neuer Nachname
|
||||||
|
* @param string|null $password Neues Passwort oder null
|
||||||
|
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||||
|
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
|
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) {
|
||||||
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
|
foreach ($users as $user) {
|
||||||
|
if (
|
||||||
|
isset($user["email"])
|
||||||
|
&& $user["email"] === $newEmail
|
||||||
|
&& $newEmail !== $oldEmail
|
||||||
|
) {
|
||||||
|
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($users as $i => $user) {
|
||||||
|
if (isset($user["email"]) && $user["email"] === $oldEmail) {
|
||||||
|
$users[$i]["email"] = $newEmail;
|
||||||
|
$users[$i]["vorname"] = $vorname;
|
||||||
|
$users[$i]["nachname"] = $nachname;
|
||||||
|
|
||||||
|
unset($users[$i]["username"]);
|
||||||
|
|
||||||
|
if (!empty($password)) {
|
||||||
|
$users[$i]["password"] = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->saveUsers($users);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
public function deleteUser($email) {
|
public function deleteUser($email) {
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $i => $user) {
|
foreach ($users as $i => $user) {
|
||||||
if ($user["email"] === $email) {
|
if (isset($user["email"]) && $user["email"] === $email) {
|
||||||
unset($users[$i]);
|
unset($users[$i]);
|
||||||
$users = array_values($users);
|
$users = array_values($users);
|
||||||
$this->saveUsers($users);
|
$this->saveUsers($users);
|
||||||
|
|||||||
@@ -11,26 +11,79 @@ interface UserDAOInterface {
|
|||||||
/**
|
/**
|
||||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
*
|
*
|
||||||
|
* Funktion:
|
||||||
|
* Liefert die gespeicherten Benutzerdaten zu einer E-Mail-Adresse.
|
||||||
|
*
|
||||||
|
* Eingabe:
|
||||||
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
||||||
|
*
|
||||||
|
* Ausgabe:
|
||||||
* @return array|null Benutzerdaten als Array oder null
|
* @return array|null Benutzerdaten als Array oder null
|
||||||
|
*
|
||||||
|
* Mögliche Fehler:
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||||
*/
|
*/
|
||||||
public function findUser($email);
|
public function findUser($email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fügt einen neuen Benutzer hinzu.
|
* Fügt einen neuen Benutzer hinzu.
|
||||||
*
|
*
|
||||||
|
* Funktion:
|
||||||
|
* Erstellt einen neuen Benutzereintrag und speichert ihn
|
||||||
|
* in der jeweiligen Datenquelle.
|
||||||
|
*
|
||||||
|
* Eingabe:
|
||||||
* @param string $email E-Mail-Adresse des Benutzers
|
* @param string $email E-Mail-Adresse des Benutzers
|
||||||
* @param string $username Benutzername des Benutzers
|
* @param string $vorname Vorname des Benutzers
|
||||||
|
* @param string $nachname Nachname des Benutzers
|
||||||
* @param string $password Passwort des Benutzers
|
* @param string $password Passwort des Benutzers
|
||||||
|
*
|
||||||
|
* Ausgabe:
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
|
* Mögliche Fehler:
|
||||||
|
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
*/
|
*/
|
||||||
public function addUser($email, $username, $password);
|
public function addUser($email, $vorname, $nachname, $password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert einen bestehenden Benutzer.
|
||||||
|
*
|
||||||
|
* Funktion:
|
||||||
|
* Ändert die E-Mail-Adresse, den Vornamen, den Nachnamen
|
||||||
|
* und optional das Passwort eines bestehenden Benutzers.
|
||||||
|
*
|
||||||
|
* Eingabe:
|
||||||
|
* @param string $oldEmail Alte E-Mail-Adresse
|
||||||
|
* @param string $newEmail Neue E-Mail-Adresse
|
||||||
|
* @param string $vorname Neuer Vorname
|
||||||
|
* @param string $nachname Neuer Nachname
|
||||||
|
* @param string|null $password Neues Passwort oder null
|
||||||
|
*
|
||||||
|
* Ausgabe:
|
||||||
|
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||||
|
*
|
||||||
|
* Mögliche Fehler:
|
||||||
|
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
|
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
*
|
*
|
||||||
|
* Funktion:
|
||||||
|
* Entfernt einen vorhandenen Benutzer aus der Datenquelle.
|
||||||
|
*
|
||||||
|
* Eingabe:
|
||||||
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||||
|
*
|
||||||
|
* Ausgabe:
|
||||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||||
|
*
|
||||||
|
* Mögliche Fehler:
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
*/
|
*/
|
||||||
public function deleteUser($email);
|
public function deleteUser($email);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function userNameValidator($name)
|
||||||
|
{
|
||||||
|
$name = trim($name);
|
||||||
|
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u';
|
||||||
|
|
||||||
|
return preg_match($namePattern, $name) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userEmailValidator($email)
|
||||||
|
{
|
||||||
|
$email = trim($email);
|
||||||
|
|
||||||
|
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
|
||||||
|
&& mb_strlen($email) <= 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userPasswordValidator($password)
|
||||||
|
{
|
||||||
|
$zeichenAnzahl = mb_strlen($password);
|
||||||
|
|
||||||
|
return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userOptionalPasswordValidator($password)
|
||||||
|
{
|
||||||
|
if (!isset($password) || $password === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return userPasswordValidator($password);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user