Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1735dd28a2 | |||
| 9c3ebc9877 | |||
| 3d13c3b8c8 | |||
| 6c3e788f13 | |||
| aceac0bf8b | |||
| 78d04f1715 | |||
| 1d773ea4e6 | |||
| a595567db1 | |||
| 945d3e1c1f | |||
| d58ea953af | |||
| b9475a045f | |||
| 32c2a1a3d8 | |||
| fc93f2b3f0 | |||
| f33778f97a | |||
| 1c72a03f26 | |||
| 3dcbdbf23c | |||
| 8143d501fa | |||
| 3471eedf4a | |||
| b6a3dad2ab | |||
| 375e6d9625 | |||
| 4d144ec704 | |||
| a26e985edf | |||
| cf9ac795eb | |||
| 370c047c16 | |||
| a562a67923 | |||
| 078dbd8901 | |||
| 64d624a6df | |||
| 90ab57e4cb | |||
| a00ddf18e6 | |||
| 5048dc2466 | |||
| 7209fe3e20 | |||
| 4e35e67ef1 | |||
| 830b57d245 | |||
| 06930644a6 | |||
| a519387773 | |||
| ed40596389 | |||
| 4c855c05ed | |||
| e7189245d5 | |||
| 709a4ba83c | |||
| fb54ba2462 | |||
| c6b55030cf | |||
| af04557f58 | |||
| 2c100bddf2 | |||
| 8e3642c668 | |||
| 87d78b749b | |||
| 604dbeca93 | |||
| 8e9e7d65d0 | |||
| e2c317e507 | |||
| 5a7fa35465 | |||
| 2601a1c1ca | |||
| 0e26679f24 | |||
| d5ab659217 | |||
| 2d5919d572 | |||
| f56a074a3c | |||
| 24dc432f01 | |||
| 016193de07 | |||
| f04d8fecd3 | |||
| 36276c7c88 | |||
| 4a2cf0b55b | |||
| 400436a73f | |||
| 4c378dfba6 | |||
| c3a9de71f4 | |||
| ecf2e9ef57 | |||
| 45ac70eba2 | |||
| 3b66c6aa3a | |||
| e37b882481 | |||
| 5c7a47e002 | |||
| bbaa73dc1a | |||
| 9f5806f019 | |||
| 6de86c3143 | |||
| c9c0de6c3c | |||
| 4f827ed3a8 | |||
| aedac79743 | |||
| 84a39bf0d4 | |||
| 75c6d099f5 | |||
| 319957c01e | |||
| 26dc33ea2f | |||
| 7597eddd7c | |||
| 0441b4e56f | |||
| cbff21136c | |||
| 03f0d19b01 | |||
| ca65c6c6e1 | |||
| 2b095f16bf | |||
| 930bf99fa1 | |||
| 366527e8e9 | |||
| 4e06240307 | |||
| 38608a5278 | |||
| b19f30cca4 | |||
| b206e809ac | |||
| e88f741fa7 | |||
| 6958e71bfb | |||
| c6ad0b2a59 | |||
| da9ea4f413 | |||
| 5703c0a6dd | |||
| b70943dd35 | |||
| 0f7099be81 | |||
| 9cbc1637b4 | |||
| d01be7d84c | |||
| 28511e0cc4 | |||
| 3774a2caee | |||
| 70277d3712 | |||
| 18cb092d06 | |||
| 417f34e35f | |||
| c62ff5b2c0 | |||
| ad422a134d | |||
| 9fce9ec8dd | |||
| a329137de2 | |||
| b328c2613c | |||
| 21bdb0d66d | |||
| 5db4ad3e63 | |||
| 2ce13cef72 | |||
| 02551049e0 | |||
| 55e9fa6a20 | |||
| c82378baa8 | |||
| 541d5b4c5e | |||
| f9ab3f8db2 | |||
| 6c5047be30 | |||
| 25f6d2bf4a | |||
| 4d8f338649 | |||
| 46a307a5b0 | |||
| 7706c7dfbf | |||
| a946cee891 | |||
| 4d4b8aeb99 |
Generated
+1
-3
@@ -10,9 +10,7 @@
|
|||||||
<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="7.0">
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.5" />
|
||||||
<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,13 +1,31 @@
|
|||||||
Team Tag-Buchstabe: DI-14-C-Schulte-Eilers-Ortmann
|
# Webprogrammierung: Gruppe DI-14-C
|
||||||
Namen der Studierenden:
|
|
||||||
- Name 1 Caroline Schulte
|
|
||||||
- Name 2 Jacques Eilers
|
|
||||||
- Name 3 Niklas Ortmann
|
|
||||||
Abgabe zu Aufgabenblatt 1
|
|
||||||
|
|
||||||
Hinweise:
|
## Beteiligte
|
||||||
index.html wurde zu einer index.php umbenannt.
|
- Caroline Schulte
|
||||||
webhook.php bitte ignorieren. Diese dient nur als zukünftige Automatisierung des Repo-Pulls (s. https://docs.gitea.com/usage/webhooks)
|
- Jacques Eilers
|
||||||
|
- Niklas Ortmann
|
||||||
|
|
||||||
Beim Verwenden der Navbar-Links bitte Folgendes beachten: nur die Kategorien Physik, Mathe, Informatik führen exemplarisch auf eine Beispiel-Seite.
|
## Login-Informationen für Dummy-User
|
||||||
Die anderen Links sind erstmal Platzhalter, dessen dynamischer Inhalt später mit PHP in die index.php eingefügt wird. Alle anderen Links führen auf eine 404-Seite.
|
Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
||||||
|
- `max.mustermann, test123, mustermann@web.de`
|
||||||
|
|
||||||
|
## Weitere Voraussetzungen zur Nutzung
|
||||||
|
- Per Klick auf das Logo gelangt man auf die Home-Seite.
|
||||||
|
|
||||||
|
## Ausgelassene Teilaufgaben
|
||||||
|
|
||||||
|
## Bekannte Fehler und Mängel
|
||||||
|
- Der Beitragseditor fügt beim Laden von Inhalten leere Zeichen ein.
|
||||||
|
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
||||||
|
- Die Navbar hat noch keine onHover-Effekte und erschwert etwas die Bedienung.
|
||||||
|
- Suchleiste in der Nav ist in der mobilen Ansicht etwas schmal. Ggf. ein alternatives (kleineres) Logo implementieren.
|
||||||
|
|
||||||
|
## Besonderheiten des Projektes
|
||||||
|
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
||||||
|
Es handelt es sich um eine einfache Version. Später sollen z.B. Bilder und die Positionierung der Elemente folgen.
|
||||||
|
- Es sind drei Dummy-Beiträge für den Nutzer max.mustermann hinterlegt.
|
||||||
|
- Beim Verwenden der Navbar-Links bitte Folgendes beachten: nur die Kategorien Physik, Mathe, Informatik führen exemplarisch auf eine Beispiel-Seite.
|
||||||
|
Die anderen Links sind erstmal Platzhalter und führen auf eine 404-Seite.
|
||||||
|
- Die Such-Seite umfasst eine Suchfunktion (aber noch nicht nach Tags) und Sortierfunktion. Jedoch fehlt noch eine Filterfunktion (z.B. nur Mathe anzeigen).
|
||||||
|
Wenn die Filterfunktion implementiert ist, dann können die statischen Seiten "Informatik", "Mathe", "Physik" entfernt und dynamisch auf der Suchseite
|
||||||
|
nach gefiltertem Fach angezeigt werden. (Vorläufige showCategory.php implementiert)
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
$user = $user ?? null;
|
||||||
|
if (!isset($_SESSION["user"])) {
|
||||||
|
header("Location: index.php?pfad=login");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Beitrag erstellen
|
Seite: Beitrag erstellen
|
||||||
@@ -58,7 +62,7 @@ session_start();
|
|||||||
<aside class="editor-sidebar">
|
<aside class="editor-sidebar">
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<button type="submit" class="btn-publish">Veröffentlichen</button>
|
<button type="submit" id="editor-button" class="button">Veröffentlichen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?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();
|
||||||
+33
-12
@@ -1,3 +1,7 @@
|
|||||||
|
<?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.
|
||||||
@@ -7,26 +11,43 @@
|
|||||||
|
|
||||||
<h1>Bitte anmelden</h1>
|
<h1>Bitte anmelden</h1>
|
||||||
|
|
||||||
<form>
|
<?php if ($error): ?>
|
||||||
<label id ="inputEmail" class="screenreader-only">E-Mail Adresse / </label>
|
<p style="color:red;">
|
||||||
|
<?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" name="email" class="login-input" placeholder="E-Mail-Adresse" required autofocus>
|
<input type="email"
|
||||||
|
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" name="password" class="login-input" placeholder="Passwort" required>
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Passwort"
|
||||||
|
required>
|
||||||
|
|
||||||
<div class="checkbox-wrapper">
|
<button type="submit"
|
||||||
<label>
|
value="anmelden"
|
||||||
<input type="checkbox" name="remember-me" value="1"> angemeldet bleiben
|
name="loginSubmit"
|
||||||
</label>
|
class="button">
|
||||||
</div>
|
anmelden
|
||||||
|
</button>
|
||||||
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">anmelden</button>
|
|
||||||
|
|
||||||
<div class="register-link">
|
<div class="register-link">
|
||||||
<a href="register.php">Noch keinen Account? Jetzt hier registrieren!</a>
|
<a href="index.php?pfad=register">
|
||||||
|
Noch keinen Account? Jetzt hier registrieren!
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
$_SESSION = [];
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
+31
-26
@@ -1,42 +1,47 @@
|
|||||||
|
<?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">Vorname</label>
|
<label class="input-label">Name</label>
|
||||||
<input type="text" name="Vorname" class="login-input" required
|
<input type="text"
|
||||||
placeholder="Vorname"
|
class="login-input"
|
||||||
value="<?php //DB-Daten ?>">
|
readonly
|
||||||
|
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" name="Email" class="login-input" required
|
<input type="email"
|
||||||
placeholder="mustermann@web.de"
|
class="login-input"
|
||||||
value="<?php //DB-Daten ?>">
|
readonly
|
||||||
|
value="<?php echo htmlspecialchars($user["email"] ?? ""); ?>">
|
||||||
|
|
||||||
<label class="input-label">Passwort</label>
|
<label class="input-label">Passwort</label>
|
||||||
<input type="password" name="Passwort" class="login-input"
|
<input type="password"
|
||||||
required placeholder="Passwort">
|
class="login-input"
|
||||||
|
readonly
|
||||||
<button type="submit" class="login-button">
|
value="********">
|
||||||
Speichern
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button type="button" class="login-button delete-account-button">
|
|
||||||
Account löschen
|
|
||||||
</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<a href="index.php?pfad=deleteAccount" class="button">
|
||||||
|
Account löschen
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<a href="index.php?pfad=logout" class="button">
|
||||||
|
Abmelden
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Rechte Spalte: Eigene Beiträge -->
|
<!-- Rechte Spalte: Eigene Beiträge -->
|
||||||
@@ -81,7 +86,7 @@ include_once 'php/controller/profileArticles-controller.php';
|
|||||||
<?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="login-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; ?>
|
||||||
|
|||||||
+41
-11
@@ -1,3 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
include_once 'php/controller/register-controller.php';
|
||||||
|
|
||||||
|
$error = $error ?? null;
|
||||||
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Form: Registrierung
|
Form: Registrierung
|
||||||
Funktion: Erstellung neuer Benutzerkonten
|
Funktion: Erstellung neuer Benutzerkonten
|
||||||
@@ -7,26 +13,50 @@
|
|||||||
|
|
||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<form>
|
<?php if ($error): ?>
|
||||||
|
<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" name="email" class="login-input" placeholder="mustermann@web.de" required>
|
<input type="email"
|
||||||
|
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" name="vorname" class="login-input" placeholder="Max" required>
|
<input type="text"
|
||||||
|
name="vorname"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Max"
|
||||||
|
required>
|
||||||
|
|
||||||
<p class="input-label">Nachname:</p>
|
<p class="input-label">Nachname:</p>
|
||||||
<input type="text" name="nachname" class="login-input" placeholder="Mustermann" required>
|
<input type="text"
|
||||||
|
name="nachname"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Mustermann"
|
||||||
|
required>
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
<input type="password" name="password" class="login-input" placeholder="Passwort" required>
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
placeholder="Passwort"
|
||||||
|
required>
|
||||||
|
|
||||||
<div class="checkbox-wrapper">
|
<button type="submit"
|
||||||
<label>
|
value="register"
|
||||||
<input type="checkbox" value="remember-me"> angemeldet bleiben
|
name="registerSubmit"
|
||||||
</label>
|
class="button">
|
||||||
</div>
|
kostenlos registrieren
|
||||||
|
</button>
|
||||||
|
|
||||||
<button type="submit" value="anmelden" name="loginSubmit" class="login-button">kostenlos registrieren</button>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
+41
-50
@@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
$results = $_SESSION["search_results"] ?? [];
|
||||||
|
$query = $_SESSION["search_query"] ?? "";
|
||||||
|
$resultCount = count($results);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Seite: Suchergebnisse
|
Seite: Suchergebnisse
|
||||||
@@ -10,95 +15,81 @@ session_start();
|
|||||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||||
<aside class="s-res-sidebar">
|
<aside class="s-res-sidebar">
|
||||||
|
|
||||||
<!-- Suchleiste Box -->
|
<!-- Sortierfuntion Box und Such 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>
|
||||||
<form action="#" method="GET" class="s-res-search-form">
|
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search" value="<?php echo htmlspecialchars($query); ?>" maxlength="50" required>
|
||||||
<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" checked>
|
<input type="radio" name="sort" value="alphabet" <?php echo $currentSort === 'alphabet' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
||||||
<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>
|
||||||
|
|
||||||
<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">3 Treffer für Ihre Suchanfrage</p>
|
<p class="s-res-meta"><?php echo $resultCount; ?> Treffer für Ihre Suchanfrage "<?php echo htmlspecialchars($query); ?>"</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
|
||||||
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
elseif (isset($_SESSION["search_query"]) && $_SESSION["search_query"] !== "" && $resultCount === 0): ?>
|
||||||
<!-- TODO: Hier die Beiträge ausgeben. -->
|
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||||
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
<?php
|
||||||
<p>
|
elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||||
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
<p>Bitte überprüfe deine Sucheingabe und versuche es erneut!</p>
|
||||||
</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,4 +1,9 @@
|
|||||||
<?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';
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
@@ -48,6 +53,11 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
Bei der Validierung deiner Daten ist ein Fehler aufgetreten. Bitte versuche es erneut.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "unauthorized_access"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
@@ -76,7 +86,7 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<aside class="editor-sidebar">
|
<aside class="editor-sidebar">
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
<button type="submit" class="btn-publish">Änderungen speichern</button>
|
<button type="submit" class="button">Änderungen speichern</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebar-block">
|
<div class="sidebar-block">
|
||||||
|
|||||||
+2
-14
@@ -86,20 +86,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Button-Zeugs */
|
/* Button-Zeugs */
|
||||||
.article-editor-scope .btn-publish {
|
.button#editor-button {
|
||||||
background-color: #007cba;
|
padding: 18px 12px;
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 1rem;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-editor-scope .btn-publish:hover {
|
|
||||||
background-color: #006ba1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
|
|||||||
+2
-2
@@ -155,7 +155,7 @@ a, button, input, select, textarea, label, main{
|
|||||||
color: #1f2937;
|
color: #1f2937;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-button {
|
.button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background-color: #2563eb;
|
background-color: #2563eb;
|
||||||
@@ -168,7 +168,7 @@ a, button, input, select, textarea, label, main{
|
|||||||
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-button:hover {
|
.button:hover {
|
||||||
background-color: #1d4ed8;
|
background-color: #1d4ed8;
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
box-shadow: 0 4px 10px rgba(0,0,0,0.15);
|
||||||
|
|||||||
+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: 760px) {
|
@media (max-width: 800px) {
|
||||||
.nav {
|
.nav {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Datenschutz vs Datensicherheit
|
Artikel: Datenschutz vs Datensicherheit
|
||||||
Funktion: Inhalt zum Fach Informatik
|
Funktion: Inhalt zum Fach Informatik
|
||||||
|
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
+53
-10
@@ -1,3 +1,7 @@
|
|||||||
|
<?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
|
||||||
-->
|
-->
|
||||||
@@ -11,17 +15,27 @@ 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> <!-- Burger Icon Symbol -->
|
<span>☰</span>
|
||||||
</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">
|
||||||
@@ -39,7 +53,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=englisch">Physik</a></li>
|
<li><a href="index.php?pfad=physik">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>
|
||||||
@@ -85,6 +99,7 @@ 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">
|
||||||
@@ -96,6 +111,7 @@ 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">
|
||||||
@@ -112,6 +128,7 @@ 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">
|
||||||
@@ -124,14 +141,40 @@ 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
|
<?php include_once 'search.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=register" class="nav__item nav__button">Registrieren</a>
|
<a href="index.php?pfad=createArticle" class="nav__item nav__button">
|
||||||
<a href="index.php?pfad=createArticle" class="nav__item nav__button">Beitrag erstellen</a>
|
Beitrag erstellen
|
||||||
|
</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>
|
||||||
+6
-1
@@ -2,5 +2,10 @@
|
|||||||
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>-->
|
||||||
<input type="search" id="site-search" name="q" placeholder="Suchen..." class="nav__search">
|
<form action="php/controller/search-results-controller.php" method="GET" class="search-form" style="display: flex; align-items: center; gap: 5px;">
|
||||||
|
|
||||||
|
<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,10 +1,31 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($abs_path)) {
|
ob_start();
|
||||||
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";
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -35,18 +56,28 @@ require_once $abs_path . "/php/controller/index-controller.php";
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once 'includes/navbar.php';
|
include_once 'includes/navbar.php';
|
||||||
//Dynamischer Inhalt:
|
|
||||||
if (isset($_GET["pfad"])) {
|
|
||||||
if (file_exists($abs_path . '/content/' . $_GET["pfad"] . '.php')) {
|
|
||||||
include_once $abs_path . '/content/' . $_GET["pfad"] . '.php';
|
|
||||||
} else {
|
|
||||||
include_once $abs_path . '/content/404.php';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
include_once $abs_path . '/content/home.php';
|
|
||||||
}
|
|
||||||
include_once $abs_path . '/includes/footer.php';
|
|
||||||
?>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Dynamischer Inhalt:
|
||||||
|
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
||||||
|
*/
|
||||||
|
if (isset($_GET["pfad"])) {
|
||||||
|
if (file_exists('content/' . $_GET["pfad"] . '.php')) {
|
||||||
|
include_once 'content/' . $_GET["pfad"] . '.php';
|
||||||
|
} else {
|
||||||
|
include_once 'content/404.php';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
include_once 'content/home.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once 'includes/footer.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
ob_end_flush();
|
||||||
|
?>
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?php
|
|
||||||
// mit $_SERVER['DOCUMENT_ROOT'] später umbauen?
|
|
||||||
$abs_path = __DIR__;
|
|
||||||
?>
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
<?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 '../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_title"] = $_POST["title"] ?? '';
|
||||||
@@ -17,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
} else {
|
} else {
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
$content = $_POST["content"];
|
$content = $_POST["content"];
|
||||||
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
$author = $_SESSION["user_email"];
|
||||||
$category = $_POST["category"];
|
$category = $_POST["category"];
|
||||||
$tags = $_POST['tags'] ?? '';
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
@@ -83,4 +84,6 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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,12 +3,15 @@
|
|||||||
* 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 {
|
||||||
$author = "max.mustermann"; // TODO: später Nutzer aus der Session beziehen.
|
$dao = new LocalUserDAO();
|
||||||
|
$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)) {
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?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,28 +2,67 @@
|
|||||||
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"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
|
||||||
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.
|
header("Location: ../../index.php?pfad=search-results");
|
||||||
// Weiterleitung zur Suchergebnisanzeige
|
|
||||||
header("location: ../../index.php?pfad=search-results");
|
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?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 '../model/Article.php';
|
require_once '../model/Article.php';
|
||||||
@@ -8,7 +8,7 @@ require_once '../validator/article-validator.php';
|
|||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||||
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
$_SESSION["old_content"] = $_POST["content"] ?? '';
|
||||||
$_SESSION["old_category"] = $_POST["category"] ?? '';
|
$_SESSION["old_category"] = $_POST["category"] ?? ''; // TODO: die Kategorie im Dropdown setzen, wenn der Editor erneut geöffnet wird.
|
||||||
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
$_SESSION["old_tags"] = $_POST["tags"] ?? '';
|
||||||
|
|
||||||
if (isset($_GET["id"]) && !empty($_GET["id"])) {
|
if (isset($_GET["id"]) && !empty($_GET["id"])) {
|
||||||
@@ -26,7 +26,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
}else{
|
}else{
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
$content = $_POST["content"];
|
$content = $_POST["content"];
|
||||||
$author = "max.mustermann"; // TODO: später aus Session den angemeldeten Nutzer beziehen.
|
$author = $_SESSION["user_email"];
|
||||||
$category = $_POST["category"];
|
$category = $_POST["category"];
|
||||||
$tags = $_POST['tags'] ?? '';
|
$tags = $_POST['tags'] ?? '';
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$article->setTags($cleanedTags);
|
$article->setTags($cleanedTags);
|
||||||
$articleManager->updateArticle($id ,$article, $author);
|
$articleManager->updateArticle($id ,$article, $author);
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = $e->getMessage();
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
class Article
|
class Article
|
||||||
{
|
{
|
||||||
private $id;
|
public $id;
|
||||||
private $title;
|
public $title;
|
||||||
private $content;
|
public $content;
|
||||||
private $author;
|
public $author;
|
||||||
private $creationDate;
|
public $creationDate;
|
||||||
private $category;
|
public $category;
|
||||||
private $tags;
|
public $tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Konstruktor
|
* Konstruktor
|
||||||
|
|||||||
@@ -44,4 +44,5 @@ class ArticleManager extends LocalArticleManager
|
|||||||
|
|
||||||
return $articleManager;
|
return $articleManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "Article.php";
|
require_once "Article.php";
|
||||||
|
|
||||||
|
class NotFoundException extends Exception {}
|
||||||
|
class UnauthorizedAccessException extends Exception {}
|
||||||
|
class InternalServerErrorException extends Exception {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
* Die Klasse beinhaltet alle Methoden für die Operation mit den Artikel-Daten.
|
||||||
*
|
*
|
||||||
@@ -16,7 +21,7 @@ interface ArticleManagerDAO
|
|||||||
* @param $tags string optionale Schlagworte für eine bessere Suche
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO Fehlerbeschreibung hinzufügen & tags hinzufügen
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
public function addArticle($title, $content, $author, $category, $tags);
|
public function addArticle($title, $content, $author, $category, $tags);
|
||||||
|
|
||||||
@@ -29,7 +34,10 @@ interface ArticleManagerDAO
|
|||||||
* @param $author
|
* @param $author
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* TODO: Fehlerbeschreibung hinzufügen
|
* @throws InternalServerErrorException
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws UnauthorizedAccessException
|
||||||
|
* /
|
||||||
*/
|
*/
|
||||||
public function updateArticle($id, $article, $author);
|
public function updateArticle($id, $article, $author);
|
||||||
|
|
||||||
@@ -38,7 +46,7 @@ interface ArticleManagerDAO
|
|||||||
* @param $id
|
* @param $id
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* TODO: Fehlerbeschreibung hinzufügen
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
public function deleteArticle($id);
|
public function deleteArticle($id);
|
||||||
|
|
||||||
@@ -48,7 +56,7 @@ interface ArticleManagerDAO
|
|||||||
*
|
*
|
||||||
* @return Article
|
* @return Article
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO Fehlerbeschreibung hinzufügen
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
public function getArticle($id);
|
public function getArticle($id);
|
||||||
|
|
||||||
@@ -56,7 +64,7 @@ interface ArticleManagerDAO
|
|||||||
* Alle Beiträge aufrufen.
|
* Alle Beiträge aufrufen.
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* Mögliche Exceptions:
|
||||||
* TODO Fehlerbeschreibung hinzufügen
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
public function getAllArticles();
|
public function getAllArticles();
|
||||||
|
|
||||||
@@ -64,8 +72,19 @@ interface ArticleManagerDAO
|
|||||||
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
||||||
* @param $author
|
* @param $author
|
||||||
* @return Article[]
|
* @return Article[]
|
||||||
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -36,6 +36,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
* Speichert alle Artikel/Beiträge in der Datei.
|
* Speichert alle Artikel/Beiträge in der Datei.
|
||||||
* @param $articles
|
* @param $articles
|
||||||
* @return void
|
* @return void
|
||||||
|
* TODO: Exceptions implementieren.
|
||||||
*/
|
*/
|
||||||
public function saveArticle($articles)
|
public function saveArticle($articles)
|
||||||
{
|
{
|
||||||
@@ -65,14 +66,12 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
public function updateArticle($id, $article, $author)
|
public function updateArticle($id, $article, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
// TODO: Implement Exception.
|
throw new InternalServerErrorException("internal_error");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechtigungsprüfung:
|
// Berechtigungsprüfung:
|
||||||
if ($article->getAuthor() !== $author) {
|
if ($article->getAuthor() !== $author) {
|
||||||
// TODO: Implement Exception.
|
throw new UnauthorizedAccessException("unauthorized_access");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beitrag aktualisieren:
|
// Beitrag aktualisieren:
|
||||||
@@ -92,15 +91,14 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
];
|
];
|
||||||
$updated = true;
|
$updated = true;
|
||||||
break;
|
break;
|
||||||
}else{
|
|
||||||
// TODO: Implement Exception.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nur speichern, wenn Beitrag geändert wurde:
|
// Nur speichern, wenn Beitrag geändert wurde:
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$this->saveArticle($articles);
|
$this->saveArticle($articles);
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("missing_id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,5 +166,40 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?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,6 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Satz des Pythagoras
|
Artikel: Satz des Pythagoras
|
||||||
Funktion: Inhalt zum Fach Mathe
|
Funktion: Inhalt zum Fach Mathe
|
||||||
|
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Artikel: Tunneleffekt
|
Artikel: Tunneleffekt
|
||||||
Funktion: Inhalt zum Fach Physik
|
Funktion: Inhalt zum Fach Physik
|
||||||
|
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
|
|||||||
Reference in New Issue
Block a user