Compare commits
114 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b5fc79a2e7 | |||
| 24a3176f43 | |||
| a5650f2720 | |||
| 4758366063 | |||
| e7a5c2b352 | |||
| 36ec2a539c | |||
| 339e51cca7 | |||
| 0726ba214c | |||
| 0e032ae029 | |||
| b9dead1c8b | |||
| 9010b68a39 | |||
| 252c14a377 | |||
| 4abfe801ec | |||
| c23a10eb6e | |||
| 11b55008ea | |||
| 46dcc16c59 | |||
| d42dff1165 | |||
| 11da418f60 | |||
| 981e78ff7e | |||
| c798bbd230 | |||
| e22d97e15a | |||
| c662369259 | |||
| 11b7be4ca0 | |||
| a029314bc9 | |||
| 8dd2d4f4ea | |||
| a4efbd4f0b | |||
| f63b8c6506 | |||
| caa9a9ff8f | |||
| 524dc2a399 | |||
| 793d9632b2 | |||
| 5892a875c8 | |||
| b130bf9e19 | |||
| 46def40a14 | |||
| a76113dcaf | |||
| f56a04c3ab | |||
| 7f891b6ebf | |||
| 1343496a12 | |||
| 1735dd28a2 | |||
| 9321d09489 | |||
| 7269ea03db | |||
| 2a3a15c92d | |||
| a7f1729e6e | |||
| cdccb0bfe8 | |||
| 48501a9069 | |||
| a175765e33 | |||
| 3d57c2e482 | |||
| bac4334fb8 | |||
| aa3e7c2f36 | |||
| 46cd524f70 | |||
| 86fb37abc4 | |||
| 9349b91926 | |||
| b9c86e2074 | |||
| 68672474e4 | |||
| a08197cc10 | |||
| e28620d9fb | |||
| ded98ed757 | |||
| 18fe69cbcd | |||
| e35d07ebc3 | |||
| e772a8b57f | |||
| 9c3ebc9877 | |||
| 3d13c3b8c8 | |||
| 6c3e788f13 | |||
| aceac0bf8b | |||
| 78d04f1715 | |||
| 1d773ea4e6 | |||
| a595567db1 | |||
| 945d3e1c1f | |||
| d58ea953af | |||
| b9475a045f | |||
| 32c2a1a3d8 | |||
| fc93f2b3f0 | |||
| f33778f97a | |||
| 1c72a03f26 | |||
| 3dcbdbf23c | |||
| 8143d501fa | |||
| 3471eedf4a | |||
| b6a3dad2ab | |||
| 375e6d9625 | |||
| 4d144ec704 | |||
| 370c047c16 | |||
| a562a67923 | |||
| 078dbd8901 | |||
| 64d624a6df | |||
| 90ab57e4cb | |||
| a00ddf18e6 | |||
| 5048dc2466 | |||
| 7209fe3e20 | |||
| 4e35e67ef1 | |||
| 830b57d245 | |||
| 06930644a6 | |||
| 8e3642c668 | |||
| 87d78b749b | |||
| 604dbeca93 | |||
| 8e9e7d65d0 | |||
| e2c317e507 | |||
| 5a7fa35465 | |||
| 2601a1c1ca | |||
| 0e26679f24 | |||
| d5ab659217 | |||
| 2d5919d572 | |||
| f56a074a3c | |||
| 24dc432f01 | |||
| 016193de07 | |||
| f04d8fecd3 | |||
| 36276c7c88 | |||
| 4a2cf0b55b | |||
| 400436a73f | |||
| 4c378dfba6 | |||
| c3a9de71f4 | |||
| ecf2e9ef57 | |||
| 45ac70eba2 | |||
| 3b66c6aa3a | |||
| e37b882481 | |||
| b328c2613c |
+42
@@ -0,0 +1,42 @@
|
||||
<DataSourcesHistory>
|
||||
<DataSourceFromHistory isRemovedFromProject="true">
|
||||
<data-source source="LOCAL" name="articles" uuid="a0abcd0a-1d6f-40e4-88be-f442bcb431ba">
|
||||
<database-info product="SQLite" version="3.51.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.51.1.0" dbms="SQLITE" exact-version="3.51.1" exact-driver-version="3.51">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
</database-info>
|
||||
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db/articles</jdbc-url>
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<auth-provider>no-auth</auth-provider>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" qname="@" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</DataSourceFromHistory>
|
||||
<DataSourceFromHistory isRemovedFromProject="false">
|
||||
<data-source source="LOCAL" name="articles" uuid="315cb5c9-2b0f-435b-b602-59823b160908">
|
||||
<database-info product="SQLite" version="3.51.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.51.1.0" dbms="SQLITE" exact-version="3.51.1" exact-driver-version="3.51">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
</database-info>
|
||||
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db/articles</jdbc-url>
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<auth-provider>no-auth</auth-provider>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" qname="@" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</DataSourceFromHistory>
|
||||
</DataSourcesHistory>
|
||||
@@ -10,16 +10,26 @@ 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.
|
||||
- Die Suchseite und Kategorieseite packen momentan alle passenden Beiträge untereinander. Später sollen zunächst 10
|
||||
Ergebnisse auf einer Seite angezeigt werden.
|
||||
|
||||
## 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.
|
||||
- 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).
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
-->
|
||||
<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>
|
||||
<p>
|
||||
Später im Projekt sollen über index.php?pfad= ... der Inhalt der index.php dynamisch gesetzt werden.
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
require_once "php/model/LocalUserDAO.php";
|
||||
|
||||
$dao = new LocalUserDAO();
|
||||
|
||||
/*
|
||||
Deregistrierung
|
||||
Funktion: Entfernt User aus Dummy-Daten und beendet Session
|
||||
*/
|
||||
|
||||
if (isset($_SESSION["user_email"])) {
|
||||
$dao->deleteUser($_SESSION["user_email"]);
|
||||
}
|
||||
|
||||
$_SESSION = [];
|
||||
session_destroy();
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
+8
-3
@@ -17,6 +17,11 @@ include_once 'php/controller/home-controller.php';
|
||||
Dein Beitrag wurde erfolgreich veröffentlicht!
|
||||
</p>
|
||||
<?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
|
||||
unset($_SESSION["message"]);
|
||||
?>
|
||||
@@ -34,21 +39,21 @@ include_once 'php/controller/home-controller.php';
|
||||
<!-- Flexbox -->
|
||||
<div class="flexbox">
|
||||
<div class="container">
|
||||
<a href="index.php?pfad=informatik" class="category-link">Informatik</a>
|
||||
<a href="index.php?pfad=showCategory&category=informatik" class="category-link">Informatik</a>
|
||||
<div class="article-link">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $dummy3->getId()?>"><?php if(isset($dummy3)){echo $dummy3->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<a href="index.php?pfad=mathe" class="category-link">Mathe</a>
|
||||
<a href="index.php?pfad=showCategory&category=mathe" class="category-link">Mathe</a>
|
||||
<div class="article-link">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $dummy1->getId()?>"><?php if(isset($dummy1)){echo $dummy1->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<a href="index.php?pfad=physik" class="category-link">Physik</a>
|
||||
<a href="index.php?pfad=showCategory&category=physik" class="category-link">Physik</a>
|
||||
<div class="article-link">
|
||||
<a href="index.php?pfad=showArticle&id=<?php echo $dummy2->getId()?>"><?php if(isset($dummy2)){echo $dummy2->getTitle();}else{echo "Fehler: Beitrag nicht gefunden!";} ?></a>
|
||||
</div>
|
||||
|
||||
+41
-50
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
$results = $_SESSION["search_results"] ?? [];
|
||||
$query = $_SESSION["search_query"] ?? "";
|
||||
$resultCount = count($results);
|
||||
|
||||
?>
|
||||
<!--
|
||||
Seite: Suchergebnisse
|
||||
@@ -10,95 +15,81 @@ session_start();
|
||||
<!-- Links: Seitenleiste für Filter und Suche -->
|
||||
<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">
|
||||
<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">
|
||||
<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>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Sortierfuntion Box -->
|
||||
<div class="s-res-sidebar-box">
|
||||
<h3 class="s-res-sidebar-title">Sortierung</h3>
|
||||
<?php $currentSort = $_SESSION['search_sort'] ?? 'alphabet'; ?>
|
||||
<div class="s-res-filter-group">
|
||||
<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>
|
||||
</label>
|
||||
<!-- Noch disabled, da likes noch nicht implementiert-->
|
||||
<label class="s-res-filter-option">
|
||||
<input type="radio" name="sort" value="likes">
|
||||
<span>Beliebtheit (Likes)</span>
|
||||
<input type="radio" name="sort" value="likes" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?> disabled>
|
||||
<span style="color: #94a3b8;">Beliebtheit (Likes)</span>
|
||||
</label>
|
||||
<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>
|
||||
</label>
|
||||
<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>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</aside>
|
||||
|
||||
<main class="s-res-main-content">
|
||||
|
||||
<div class="s-res-header">
|
||||
<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>
|
||||
|
||||
<!-- Ergebnisliste -->
|
||||
<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
|
||||
if(isset($_SESSION['message']) && $_SESSION['message'] == "new_search_results"): ?>
|
||||
<!-- TODO: Hier die Beiträge ausgeben. -->
|
||||
<?php elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||
<p>
|
||||
Bitte überprüfe deine Sucheingabe und versuche es erneut!
|
||||
</p>
|
||||
elseif (isset($_SESSION["search_query"]) && $_SESSION["search_query"] !== "" && $resultCount === 0): ?>
|
||||
<p>Keine Beiträge zu diesem Suchbegriff gefunden.</p>
|
||||
<?php
|
||||
elseif (isset($_SESSION["message"]) && $_SESSION["message"] == "missing_parameters"): ?>
|
||||
<p>Bitte überprüfe deine Sucheingabe und versuche es erneut!</p>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
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 class="s-res-pagination-footer">
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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->getId(); ?>" class="s-res-link">
|
||||
<?php echo htmlspecialchars($article->getTitle()); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($article->getAuthor()); ?></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>
|
||||
@@ -86,7 +86,7 @@ include_once 'php/controller/showArticle-controller.php';
|
||||
<aside class="editor-sidebar">
|
||||
|
||||
<div class="sidebar-block">
|
||||
<button type="submit" class="button">Änderungen speichern</button>
|
||||
<button type="submit" id="editor-button" class="button">Änderungen speichern</button>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-block">
|
||||
|
||||
@@ -22,6 +22,10 @@ a, button, input, select, textarea, label, main{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.flexbox {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<!--
|
||||
Artikel: Datenschutz vs Datensicherheit
|
||||
Funktion: Inhalt zum Fach Informatik
|
||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Datenschutz vs Datensicherheit</h1>
|
||||
|
||||
<p>
|
||||
Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig – ob in sozialen Netzwerken, beim
|
||||
Online-Shopping oder dem Einsatz von Bonuskarten, bei der Auswertung von Konsumverhalten und selbstverständlich
|
||||
auch im schulischen Kontext.
|
||||
</p>
|
||||
<h2>
|
||||
Was ist Datenschutz?
|
||||
</h2>
|
||||
<p>
|
||||
Datenschutz bedeutet, dass persönliche Daten nur gesammelt, gespeichert und verwendet werden dürfen, wenn
|
||||
es wirklich nötig ist – und nur für klar festgelegte Zwecke. Es geht darum, die Privatsphäre von Menschen
|
||||
zu schützen.
|
||||
</p>
|
||||
<h2>
|
||||
Was ist Datenschutz?
|
||||
</h2>
|
||||
<p>
|
||||
Datensicherheit umfasst alle technischen und organisatorischen Maßnahmen, die verhindern sollen, dass Daten
|
||||
verloren gehen, beschädigt oder unbemerkt verändert werden. Sie schützt Informationen vor Missbrauch.
|
||||
</p>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<FilesMatch "\.db">
|
||||
deny from all
|
||||
</FilesMatch>
|
||||
+52
-52
@@ -39,50 +39,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||
<li>
|
||||
<label class="nav__mobile-label">Sprachen</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=deutsch">Deutsch</a></li>
|
||||
<li><a href="index.php?pfad=englisch">Englisch</a></li>
|
||||
<li><a href="index.php?pfad=franzoesisch">Französisch</a></li>
|
||||
<li><a href="index.php?pfad=latein">Latein</a></li>
|
||||
<li><a href="index.php?pfad=literatur">Literatur</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=englisch">Englisch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=latein">Latein</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=literatur">Literatur</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">MINT</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<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=chemie">Chemie</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=astronomie">Astronomie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=mathe">Mathematik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=biologie">Biologie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=chemie">Chemie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=physik">Physik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=informatik">Informatik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">Gesellschaft & Werte</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=geschichte">Geschichte</a></li>
|
||||
<li><a href="index.php?pfad=erdkunde">Erdkunde</a></li>
|
||||
<li><a href="index.php?pfad=sozialkunde">Sozialkunde</a></li>
|
||||
<li><a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a></li>
|
||||
<li><a href="index.php?pfad=religion">Religion</a></li>
|
||||
<li><a href="index.php?pfad=ethik">Ethikunterricht</a></li>
|
||||
<li><a href="index.php?pfad=philosophie">Philosophie</a></li>
|
||||
<li><a href="index.php?pfad=psychologie">Psychologie</a></li>
|
||||
<li><a href="index.php?pfad=kunst">Kunst</a></li>
|
||||
<li><a href="index.php?pfad=musik">Musik</a></li>
|
||||
<li><a href="index.php?pfad=theater">Theater</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=religion">Religion</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=kunst">Kunst</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=musik">Musik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=theater">Theater</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="nav__mobile-label">Technik & Praxis</label>
|
||||
<ul class="nav__mobile-submenu">
|
||||
<li><a href="index.php?pfad=technik">Technik</a></li>
|
||||
<li><a href="index.php?pfad=werken">Werken</a></li>
|
||||
<li><a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a></li>
|
||||
<li><a href="index.php?pfad=sport">Sport</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=technik">Technik</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=werken">Werken</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a></li>
|
||||
<li><a href="index.php?pfad=showCategory&category=sport">Sport</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -92,50 +92,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Sprachen</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=deutsch">Deutsch</a>
|
||||
<a href="index.php?pfad=englisch">Englisch</a>
|
||||
<a href="index.php?pfad=franzoesisch">Französisch</a>
|
||||
<a href="index.php?pfad=latein">Latein</a>
|
||||
<a href="index.php?pfad=literatur">Literatur</a>
|
||||
<a href="index.php?pfad=showCategory&category=deutsch">Deutsch</a>
|
||||
<a href="index.php?pfad=showCategory&category=englisch">Englisch</a>
|
||||
<a href="index.php?pfad=showCategory&category=franzoesisch">Französisch</a>
|
||||
<a href="index.php?pfad=showCategory&category=latein">Latein</a>
|
||||
<a href="index.php?pfad=showCategory&category=literatur">Literatur</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">MINT</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=mathe">Mathematik</a>
|
||||
<a href="index.php?pfad=biologie">Biologie</a>
|
||||
<a href="index.php?pfad=chemie">Chemie</a>
|
||||
<a href="index.php?pfad=physik">Physik</a>
|
||||
<a href="index.php?pfad=informatik">Informatik</a>
|
||||
<a href="index.php?pfad=astronomie">Astronomie</a>
|
||||
<a href="index.php?pfad=showCategory&category=mathe">Mathematik</a>
|
||||
<a href="index.php?pfad=showCategory&category=biologie">Biologie</a>
|
||||
<a href="index.php?pfad=showCategory&category=chemie">Chemie</a>
|
||||
<a href="index.php?pfad=showCategory&category=physik">Physik</a>
|
||||
<a href="index.php?pfad=showCategory&category=informatik">Informatik</a>
|
||||
<a href="index.php?pfad=showCategory&category=astronomie">Astronomie</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Gesellschaft & Werte</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=geschichte">Geschichte</a>
|
||||
<a href="index.php?pfad=erdkunde">Erdkunde</a>
|
||||
<a href="index.php?pfad=sozialkunde">Sozialkunde</a>
|
||||
<a href="index.php?pfad=wirtschaft">Wirtschaftskunde</a>
|
||||
<a href="index.php?pfad=religion">Religion</a>
|
||||
<a href="index.php?pfad=ethik">Ethikunterricht</a>
|
||||
<a href="index.php?pfad=philosophie">Philosophie</a>
|
||||
<a href="index.php?pfad=psychologie">Psychologie</a>
|
||||
<a href="index.php?pfad=kunst">Kunst</a>
|
||||
<a href="index.php?pfad=musik">Musik</a>
|
||||
<a href="index.php?pfad=theater">Theater</a>
|
||||
<a href="index.php?pfad=showCategory&category=geschichte">Geschichte</a>
|
||||
<a href="index.php?pfad=showCategory&category=erdkunde">Erdkunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=sozialkunde">Sozialkunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=wirtschaft">Wirtschaftskunde</a>
|
||||
<a href="index.php?pfad=showCategory&category=religion">Religion</a>
|
||||
<a href="index.php?pfad=showCategory&category=ethik">Ethikunterricht</a>
|
||||
<a href="index.php?pfad=showCategory&category=philosophie">Philosophie</a>
|
||||
<a href="index.php?pfad=showCategory&category=psychologie">Psychologie</a>
|
||||
<a href="index.php?pfad=showCategory&category=kunst">Kunst</a>
|
||||
<a href="index.php?pfad=showCategory&category=musik">Musik</a>
|
||||
<a href="index.php?pfad=showCategory&category=theater">Theater</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav__item nav__dropdown">
|
||||
<button class="nav__dropdown-toggle">Technik & Praxis</button>
|
||||
<div class="nav__dropdown-menu">
|
||||
<a href="index.php?pfad=technik">Technik</a>
|
||||
<a href="index.php?pfad=werken">Werken</a>
|
||||
<a href="index.php?pfad=hauswirtschaft">Hauswirtschaft</a>
|
||||
<a href="index.php?pfad=sport">Sport</a>
|
||||
<a href="index.php?pfad=showCategory&category=technik">Technik</a>
|
||||
<a href="index.php?pfad=showCategory&category=werken">Werken</a>
|
||||
<a href="index.php?pfad=showCategory&category=hauswirtschaft">Hauswirtschaft</a>
|
||||
<a href="index.php?pfad=showCategory&category=sport">Sport</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-1
@@ -2,5 +2,10 @@
|
||||
Suchleiste. Wird via PHP später in alle Seiten eingebunden
|
||||
-->
|
||||
<!--<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>
|
||||
</form>
|
||||
|
||||
@@ -17,12 +17,12 @@ if ($pfad === "register") {
|
||||
}
|
||||
|
||||
if ($pfad === "logout") {
|
||||
include_once "content/logout.php";
|
||||
include_once "content/logout-controller.php";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($pfad === "deleteAccount") {
|
||||
include_once "content/deleteAccount.php";
|
||||
include_once "content/deleteAccount-controller.php";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -3,7 +3,6 @@ SESSION_START();
|
||||
require_once '../model/LocalArticleManager.php';
|
||||
require_once '../model/ArticleManager.php';
|
||||
require_once '../validator/article-validator.php';
|
||||
require_once "../model/LocalUserDAO.php";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/UserManager.php";
|
||||
|
||||
/*
|
||||
Deregistrierung
|
||||
Funktion: Entfernt User aus der Datenbank und beendet die Session
|
||||
*/
|
||||
|
||||
try {
|
||||
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
if (isset($_SESSION["user_email"])) {
|
||||
$dao->deleteUser($_SESSION["user_email"]);
|
||||
}
|
||||
|
||||
$_SESSION = [];
|
||||
session_destroy();
|
||||
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
$_SESSION["message"] = "internal_error";
|
||||
|
||||
header("Location: index.php?pfad=profile");
|
||||
exit();
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/LocalUserDAO.php";
|
||||
require_once "php/model/UserManager.php";
|
||||
|
||||
$dao = new LocalUserDAO();
|
||||
$error = null;
|
||||
|
||||
/*
|
||||
@@ -11,6 +10,10 @@ $error = null;
|
||||
*/
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
try {
|
||||
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$email = $_POST["email"] ?? "";
|
||||
$password = $_POST["password"] ?? "";
|
||||
|
||||
@@ -18,12 +21,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
if ($user && password_verify($password, $user["password"])) {
|
||||
|
||||
if (isset($user["vorname"]) && isset($user["nachname"])) {
|
||||
$_SESSION["user"] = $user["vorname"] . " " . $user["nachname"];
|
||||
} else {
|
||||
$_SESSION["user"] = $user["username"] ?? "";
|
||||
}
|
||||
|
||||
$_SESSION["user_email"] = $user["email"];
|
||||
|
||||
header("Location: index.php");
|
||||
@@ -32,4 +30,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
} else {
|
||||
$error = "Login fehlgeschlagen. Bitte überprüfe deine Eingaben.";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/LocalUserDAO.php";
|
||||
require_once "php/model/UserManager.php";
|
||||
require_once "php/model/Article.php";
|
||||
require_once "php/model/ArticleManager.php";
|
||||
require_once "php/validator/user-validator.php";
|
||||
@@ -13,7 +13,7 @@ if (!isset($_SESSION["user"])) {
|
||||
}
|
||||
|
||||
try {
|
||||
$dao = new LocalUserDAO();
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||
|
||||
@@ -38,15 +38,15 @@ try {
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} elseif (!userNameValidator($vorname)) {
|
||||
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||
$error = "Der Vorname muss 2 bis 20 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.";
|
||||
$error = "Der Nachname muss 2 bis 20 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.";
|
||||
$error = "Das Passwort muss 5 bis 12 Zeichen lang sein.";
|
||||
$_GET["edit"] = "1";
|
||||
|
||||
} else {
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
require_once 'php/model/Article.php';
|
||||
require_once 'php/model/ArticleManager.php';
|
||||
require_once "../model/LocalUserDAO.php";
|
||||
require_once "php/model/UserManager.php";
|
||||
|
||||
try {
|
||||
$dao = new LocalUserDAO();
|
||||
$dao = UserManager::getInstance();
|
||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||
|
||||
$author = $user["email"];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once "php/model/LocalUserDAO.php";
|
||||
require_once "php/model/UserManager.php";
|
||||
require_once "php/validator/user-validator.php";
|
||||
|
||||
$error = null;
|
||||
@@ -15,14 +15,14 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
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.";
|
||||
$error = "Der Vorname muss 2 bis 20 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.";
|
||||
$error = "Der Nachname muss 2 bis 20 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.";
|
||||
$error = "Das Passwort muss 5 bis 12 Zeichen lang sein.";
|
||||
} else {
|
||||
try {
|
||||
$dao = new LocalUserDAO();
|
||||
$dao = UserManager::getInstance();
|
||||
|
||||
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
||||
|
||||
|
||||
@@ -2,28 +2,67 @@
|
||||
session_start();
|
||||
require_once '../model/LocalArticleManager.php';
|
||||
require_once '../model/ArticleManager.php';
|
||||
require_once '../model/Article.php';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
if(!isset($_POST["search"])){
|
||||
if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
|
||||
|
||||
$search = trim($_GET["q"]);
|
||||
if (empty($search)) {
|
||||
$_SESSION["search_results"] = [];
|
||||
$_SESSION["search_query"] = "";
|
||||
$_SESSION["message"] = "missing_parameters";
|
||||
header("location: ../../index.php?pfad=search-results");
|
||||
} else {
|
||||
|
||||
$search = $_POST["search"];
|
||||
|
||||
try {
|
||||
|
||||
$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){
|
||||
$_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");
|
||||
}
|
||||
header("Location: ../../index.php?pfad=search-results");
|
||||
exit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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);
|
||||
} 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
|
||||
{
|
||||
private $id;
|
||||
private $title;
|
||||
private $content;
|
||||
private $author;
|
||||
private $creationDate;
|
||||
private $category;
|
||||
private $tags;
|
||||
public $id;
|
||||
public $title;
|
||||
public $content;
|
||||
public $author;
|
||||
public $creationDate;
|
||||
public $category;
|
||||
public $tags;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once 'LocalArticleManager.php';
|
||||
require_once 'DatabaseArticleManager.php';
|
||||
require_once 'Article.php';
|
||||
|
||||
/**
|
||||
@@ -7,11 +8,11 @@ require_once 'Article.php';
|
||||
*
|
||||
* @author Niklas Ortmann
|
||||
*/
|
||||
class ArticleManager extends LocalArticleManager
|
||||
class ArticleManager
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
$articleManager = LocalArticleManager::getInstance(); // TODO: später durch DataBaseArticleManager ersetzen.
|
||||
$articleManager = DatabaseArticleManager::getInstance(); // Hier kann zwischen dem lokalen und datenbankbasiertem ArticleManager gewechselt werden.
|
||||
|
||||
// Erstellen von Dummy-Beiträgen:
|
||||
if($articleManager->getArticle(1) == null ){
|
||||
@@ -19,7 +20,7 @@ class ArticleManager extends LocalArticleManager
|
||||
"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...",
|
||||
"max.mustermann",
|
||||
"Mathe",
|
||||
"mathe",
|
||||
"Dreiecke, Dreiecksseiten berechnen"
|
||||
);
|
||||
}
|
||||
@@ -28,7 +29,7 @@ class ArticleManager extends LocalArticleManager
|
||||
"Tunneleffekt",
|
||||
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
|
||||
"max.mustermann",
|
||||
"Physik",
|
||||
"physik",
|
||||
"Quantenphysik, Energie"
|
||||
);
|
||||
}
|
||||
@@ -37,11 +38,12 @@ class ArticleManager extends LocalArticleManager
|
||||
"Datenschutz vs Datensicherheit",
|
||||
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
|
||||
"max.mustermann",
|
||||
"Informatik",
|
||||
"informatik",
|
||||
"Daten, DSGVO"
|
||||
);
|
||||
}
|
||||
|
||||
return $articleManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,8 +20,7 @@ interface ArticleManagerDAO
|
||||
* @param $category string Kategorie des Beitrages
|
||||
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||
*
|
||||
* Mögliche Exceptions:
|
||||
* TODO: Exceptions implementieren.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function addArticle($title, $content, $author, $category, $tags);
|
||||
|
||||
@@ -38,33 +37,32 @@ interface ArticleManagerDAO
|
||||
* @throws NotFoundException
|
||||
* @throws UnauthorizedAccessException
|
||||
*/
|
||||
*/
|
||||
public function updateArticle($id, $article, $author);
|
||||
|
||||
/**
|
||||
* Löscht einen Beitrag aus übergebener ID.
|
||||
* Löscht einen Beitrag aus übergebener ID und dem Nutzer, der die Löschung ausführt.
|
||||
* @param $id
|
||||
* @param $author
|
||||
* @return void
|
||||
*
|
||||
* TODO: Exceptions implementieren.
|
||||
* @throws InternalServerErrorException
|
||||
* @throws NotFoundException
|
||||
* @throws UnauthorizedAccessException
|
||||
*/
|
||||
public function deleteArticle($id);
|
||||
public function deleteArticle($id, $author);
|
||||
|
||||
/**
|
||||
* Beitrag aufrufen.
|
||||
* $id ID des Beitrags
|
||||
*
|
||||
* @return Article
|
||||
* Mögliche Exceptions:
|
||||
* TODO: Exceptions implementieren.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getArticle($id);
|
||||
|
||||
/**
|
||||
* Alle Beiträge aufrufen.
|
||||
*
|
||||
* Mögliche Exceptions:
|
||||
* TODO: Exceptions implementieren.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getAllArticles();
|
||||
|
||||
@@ -72,9 +70,27 @@ interface ArticleManagerDAO
|
||||
* Gibt alle Beiträge eines Nutzer mit einer gegebenen ID aus.
|
||||
* @param $author
|
||||
* @return Article[]
|
||||
* TODO: Exceptions implementieren.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
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
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function getArticlesByCategory($category);
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
require_once 'ArticleManagerDAO.php';
|
||||
require_once 'Article.php';
|
||||
/**
|
||||
* Klasse: Eine SQLLite3 Lösung des ArticleManagerDAO.
|
||||
*
|
||||
* @author Niklas Ortmann
|
||||
*/
|
||||
class DatabaseArticleManager implements ArticleManagerDAO {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
*
|
||||
* Erstellt die Datenbankverbindung und die Tabelle articles.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (!file_exists(__DIR__ . '/../../db/articles.db')) {
|
||||
try {
|
||||
$user = 'root';
|
||||
$pw = null;
|
||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/articles.db';
|
||||
$db = new PDO($dsn, $user, $pw);
|
||||
|
||||
$db->exec("
|
||||
CREATE TABLE articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author TEXT,
|
||||
category TEXT,
|
||||
tags TEXT,
|
||||
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);");
|
||||
unset($db);
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut die Verbindung zur Datenbank auf.
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
private function getConnection()
|
||||
{
|
||||
try {
|
||||
$user = 'root';
|
||||
$pw = null;
|
||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/articles.db';
|
||||
return new PDO($dsn, $user, $pw);
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die DatabaseArticleManager-Instanz zurück.
|
||||
* @return DatabaseArticleManager
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new DatabaseArticleManager();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function addArticle($title, $content, $author, $category, $tags)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "INSERT INTO articles (title, content, author, category, tags)
|
||||
VALUES (:title, :content, :author, :category, :tags);";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
// Verknüpft die übergebenen Parameter exakt mit den SQL-Platzhaltern
|
||||
$success = $command->execute([
|
||||
":title" => $title,
|
||||
":content" => $content,
|
||||
":author" => $author,
|
||||
":category" => $category,
|
||||
":tags" => $tags
|
||||
]);
|
||||
|
||||
if (!$success) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
return intval($db->lastInsertId());
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateArticle($id, $article, $author)
|
||||
{
|
||||
if (empty($article)) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung analog zur lokalen Implementierung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "UPDATE articles
|
||||
SET title = :title, content = :content, author = :author, category = :category, tags = :tags
|
||||
WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$success = $command->execute([
|
||||
":id" => $id,
|
||||
":title" => $article->getTitle(),
|
||||
":content" => $article->getContent(),
|
||||
":author" => $author,
|
||||
":category" => $article->getCategory(),
|
||||
":tags" => $article->getTags()
|
||||
]);
|
||||
|
||||
// rowCount() prüft, ob eine Zeile mit dieser ID existierte und geändert werden konnte
|
||||
if (!$success || $command->rowCount() === 0) {
|
||||
// Falls die ID nicht existiert, prüfen wir, ob sie überhaupt da ist
|
||||
if (!$this->getArticle($id)) {
|
||||
throw new NotFoundException("missing_id");
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteArticle($id, $author)
|
||||
{
|
||||
$article = getArticle($id);
|
||||
if (empty($article)) {
|
||||
throw new NotFoundException("not_found_article");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "DELETE FROM articles WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
if (!$command->execute([":id" => $id])) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
} catch (PDOException $exc) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticle($id)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE id = :id;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":id" => $id]);
|
||||
$row = $command->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
return new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllArticles()
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles;";
|
||||
|
||||
$command = $db->query($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$rows = $command->fetchAll(PDO::FETCH_ASSOC);
|
||||
$articles = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$articles[] = new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return $articles;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticlesByAuthor($author)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE author = :author;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":author" => $author]);
|
||||
$rows = $command->fetchAll(PDO::FETCH_ASSOC);
|
||||
$filteredArticles = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$filteredArticles[] = new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return $filteredArticles;
|
||||
} catch (PDOException $e) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticlesByCategory($category)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$sql = "SELECT * FROM articles WHERE category = :category;";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
if (!$command) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
|
||||
$command->execute([":category" => $category]);
|
||||
$rows = $command->fetchAll(PDO::FETCH_ASSOC);
|
||||
$filteredArticles = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$filteredArticles[] = new Article(
|
||||
intval($row['id']),
|
||||
$row['title'],
|
||||
$row['content'],
|
||||
$row['author'],
|
||||
$row['category'],
|
||||
$row['tags'],
|
||||
$row['created']
|
||||
);
|
||||
}
|
||||
|
||||
return $filteredArticles;
|
||||
} catch (PDOException $exc) {
|
||||
throw new InternalServerErrorException("internal_error");
|
||||
}
|
||||
}
|
||||
|
||||
public function search(string $keyword): array
|
||||
{
|
||||
// TODO: implement search()
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
require_once "UserManagerDAO.php";
|
||||
|
||||
/**
|
||||
* Klasse für den Zugriff auf Benutzerdaten über eine SQLite-Datenbank.
|
||||
*
|
||||
* Diese Klasse verwendet PDO, Prepared Statements und speichert
|
||||
* Benutzerdaten in der Datei db/users.db.
|
||||
*/
|
||||
class DatabaseUserManager implements UserManagerDAO {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Konstruktor.
|
||||
*
|
||||
* Erstellt die Benutzerdatenbank und die Tabelle users,
|
||||
* falls diese noch nicht existieren.
|
||||
*
|
||||
* @throws RuntimeException wenn die Datenbank nicht erstellt werden kann
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$db->exec("
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
email TEXT PRIMARY KEY,
|
||||
vorname TEXT NOT NULL,
|
||||
nachname TEXT NOT NULL,
|
||||
password TEXT NOT NULL
|
||||
);
|
||||
");
|
||||
|
||||
unset($db);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzerdatenbank konnte nicht erstellt werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut eine Verbindung zur SQLite-Datenbank auf.
|
||||
*
|
||||
* @return PDO Datenbankverbindung
|
||||
*
|
||||
* @throws RuntimeException wenn keine Verbindung hergestellt werden kann
|
||||
*/
|
||||
private function getConnection()
|
||||
{
|
||||
try {
|
||||
$dsn = 'sqlite:' . __DIR__ . '/../../db/users.db';
|
||||
|
||||
$db = new PDO($dsn, null, null);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
return $db;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Verbindung zur Benutzerdatenbank fehlgeschlagen.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die Singleton-Instanz des DatabaseUserManagers zurück.
|
||||
*
|
||||
* @return DatabaseUserManager Instanz des DatabaseUserManagers
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new DatabaseUserManager();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des Benutzers
|
||||
*
|
||||
* @return array|null Benutzerdaten als Array oder null,
|
||||
* wenn kein Benutzer gefunden wurde
|
||||
*
|
||||
* @throws RuntimeException wenn der Benutzer nicht geladen werden kann
|
||||
*/
|
||||
public function findUser($email)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "SELECT * FROM users WHERE email = :email";
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email
|
||||
]);
|
||||
|
||||
$user = $command->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return $user ?: null;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzer konnte nicht geladen werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt einen neuen Benutzer in die Datenbank ein.
|
||||
*
|
||||
* Die Speicherung erfolgt innerhalb einer Transaktion.
|
||||
* Doppelte E-Mail-Adressen werden durch den Primary Key verhindert.
|
||||
*
|
||||
* @param string $email E-Mail-Adresse des Benutzers
|
||||
* @param string $vorname Vorname des Benutzers
|
||||
* @param string $nachname Nachname des Benutzers
|
||||
* @param string $password Passwort-Hash des Benutzers
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||
* @throws RuntimeException wenn der Benutzer nicht gespeichert werden kann
|
||||
*/
|
||||
public function addUser($email, $vorname, $nachname, $password)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
$db->beginTransaction();
|
||||
|
||||
$sql = "
|
||||
INSERT INTO users (email, vorname, nachname, password)
|
||||
VALUES (:email, :vorname, :nachname, :password)
|
||||
";
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":password" => $password
|
||||
]);
|
||||
|
||||
$db->commit();
|
||||
|
||||
} catch (PDOException $e) {
|
||||
if (isset($db) && $db->inTransaction()) {
|
||||
$db->rollBack();
|
||||
}
|
||||
|
||||
if ($e->getCode() === "23000") {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
|
||||
throw new RuntimeException("Benutzer konnte nicht gespeichert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die Daten eines bestehenden Benutzers.
|
||||
*
|
||||
* Optional kann zusätzlich das Passwort geändert werden.
|
||||
* Wenn kein neues Passwort übergeben wird, bleibt das alte Passwort erhalten.
|
||||
*
|
||||
* @param string $oldEmail Aktuelle E-Mail-Adresse des Benutzers
|
||||
* @param string $newEmail Neue E-Mail-Adresse des Benutzers
|
||||
* @param string $vorname Neuer Vorname des Benutzers
|
||||
* @param string $nachname Neuer Nachname des Benutzers
|
||||
* @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 der Benutzer nicht aktualisiert werden kann
|
||||
*/
|
||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
if (!empty($password)) {
|
||||
$sql = "
|
||||
UPDATE users
|
||||
SET email = :newEmail,
|
||||
vorname = :vorname,
|
||||
nachname = :nachname,
|
||||
password = :password
|
||||
WHERE email = :oldEmail
|
||||
";
|
||||
|
||||
$params = [
|
||||
":newEmail" => $newEmail,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":password" => password_hash($password, PASSWORD_DEFAULT),
|
||||
":oldEmail" => $oldEmail
|
||||
];
|
||||
} else {
|
||||
$sql = "
|
||||
UPDATE users
|
||||
SET email = :newEmail,
|
||||
vorname = :vorname,
|
||||
nachname = :nachname
|
||||
WHERE email = :oldEmail
|
||||
";
|
||||
|
||||
$params = [
|
||||
":newEmail" => $newEmail,
|
||||
":vorname" => $vorname,
|
||||
":nachname" => $nachname,
|
||||
":oldEmail" => $oldEmail
|
||||
];
|
||||
}
|
||||
|
||||
$command = $db->prepare($sql);
|
||||
$command->execute($params);
|
||||
|
||||
return $command->rowCount() > 0;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === "23000") {
|
||||
throw new InvalidArgumentException("Diese E-Mail-Adresse wird bereits verwendet.");
|
||||
}
|
||||
|
||||
throw new RuntimeException("Benutzer konnte nicht aktualisiert werden.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 der Benutzer nicht gelöscht werden kann
|
||||
*/
|
||||
public function deleteUser($email)
|
||||
{
|
||||
try {
|
||||
$db = $this->getConnection();
|
||||
|
||||
$sql = "DELETE FROM users WHERE email = :email";
|
||||
$command = $db->prepare($sql);
|
||||
|
||||
$command->execute([
|
||||
":email" => $email
|
||||
]);
|
||||
|
||||
return $command->rowCount() > 0;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new RuntimeException("Benutzer konnte nicht gelöscht werden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,8 +102,18 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteArticle($id)
|
||||
public function deleteArticle($id, $author)
|
||||
{
|
||||
$article = getArticle($id);
|
||||
if (empty($article)) {
|
||||
throw new NotFoundException("not_found_article");
|
||||
}
|
||||
|
||||
// Berechtigungsprüfung:
|
||||
if ($article->getAuthor() !== $author) {
|
||||
throw new UnauthorizedAccessException("unauthorized_access");
|
||||
}
|
||||
|
||||
$articles = $this->getAllArticles();
|
||||
$articleFound = false;
|
||||
|
||||
@@ -166,5 +176,61 @@ class LocalArticleManager implements ArticleManagerDAO {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once "UserDAOInterface.php";
|
||||
require_once "UserManagerDAO.php";
|
||||
|
||||
class LocalUserDAO implements UserDAOInterface {
|
||||
class LocalUserManager implements UserManagerDAO {
|
||||
|
||||
private string $file = "data/users.json";
|
||||
|
||||
public static function getInstance(){
|
||||
// TODO: implement the getIsntance method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt alle Benutzer aus der JSON-Datei.
|
||||
*
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once "LocalUserManager.php";
|
||||
require_once "DatabaseUserManager.php";
|
||||
|
||||
/**
|
||||
* Zentrale Klasse für den Zugriff auf Benutzerdaten.
|
||||
*
|
||||
* Hier kann zwischen lokaler Speicherung und Datenbankspeicherung
|
||||
* gewechselt werden.
|
||||
*/
|
||||
class UserManager {
|
||||
|
||||
public static function getInstance() {
|
||||
$userManager = DatabaseUserManager::getInstance();
|
||||
|
||||
/*
|
||||
* Dummy-User anlegen, falls er noch nicht existiert.
|
||||
* Passwort: test123
|
||||
*/
|
||||
if ($userManager->findUser("mustermann@web.de") == null) {
|
||||
$userManager->addUser(
|
||||
"mustermann@web.de",
|
||||
"Max",
|
||||
"Mustermann",
|
||||
password_hash("test12345", PASSWORD_DEFAULT)
|
||||
);
|
||||
}
|
||||
|
||||
return $userManager;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
* Definiert die Methoden, die jede UserDAO-Implementierung
|
||||
* bereitstellen muss.
|
||||
*/
|
||||
interface UserDAOInterface {
|
||||
interface UserManagerDAO {
|
||||
|
||||
/**
|
||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||
@@ -1,13 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Prüft, ob ein Vor- oder Nachname gültig ist.
|
||||
*
|
||||
* Erlaubt werden Buchstaben, Umlaute, Leerzeichen und Bindestriche.
|
||||
* Die Länge muss zwischen 2 und 20 Zeichen liegen.
|
||||
*
|
||||
* @param string $name Zu prüfender Name
|
||||
*
|
||||
* @return bool true wenn der Name gültig ist, sonst false
|
||||
*/
|
||||
function userNameValidator($name)
|
||||
{
|
||||
$name = trim($name);
|
||||
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u';
|
||||
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,20}$/u';
|
||||
|
||||
return preg_match($namePattern, $name) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob eine E-Mail-Adresse gültig ist.
|
||||
*
|
||||
* Die E-Mail-Adresse muss dem Standardformat entsprechen
|
||||
* und darf höchstens 100 Zeichen lang sein.
|
||||
*
|
||||
* @param string $email Zu prüfende E-Mail-Adresse
|
||||
*
|
||||
* @return bool true wenn die E-Mail-Adresse gültig ist, sonst false
|
||||
*/
|
||||
function userEmailValidator($email)
|
||||
{
|
||||
$email = trim($email);
|
||||
@@ -16,13 +36,35 @@ function userEmailValidator($email)
|
||||
&& mb_strlen($email) <= 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob ein Passwort die Längenanforderungen erfüllt.
|
||||
*
|
||||
* Das Passwort muss zwischen 5 und 12 Zeichen lang sein.
|
||||
*
|
||||
* @param string $password Zu prüfendes Passwort
|
||||
*
|
||||
* @return bool true wenn das Passwort gültig ist, sonst false
|
||||
*/
|
||||
function userPasswordValidator($password)
|
||||
{
|
||||
$zeichenAnzahl = mb_strlen($password);
|
||||
|
||||
return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72;
|
||||
return $zeichenAnzahl >= 5 && $zeichenAnzahl <= 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ein optionales Passwort.
|
||||
*
|
||||
* Ein leeres Passwort ist erlaubt und bedeutet,
|
||||
* dass das bestehende Passwort unverändert bleibt.
|
||||
* Falls ein Passwort angegeben wurde, wird es
|
||||
* mit den normalen Passwortregeln geprüft.
|
||||
*
|
||||
* @param string|null $password Zu prüfendes Passwort
|
||||
*
|
||||
* @return bool true wenn das Passwort gültig oder leer ist,
|
||||
* sonst false
|
||||
*/
|
||||
function userOptionalPasswordValidator($password)
|
||||
{
|
||||
if (!isset($password) || $password === '') {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<!--
|
||||
Artikel: Satz des Pythagoras
|
||||
Funktion: Inhalt zum Fach Mathe
|
||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Satz des Pythagoras</h1>
|
||||
|
||||
<p>
|
||||
Der Satz des Pythagoras wurde von dem griechischen Philosophen Pythagoras von Samos formuliert und im
|
||||
dritten Jahrhundert vor Christus veröffentlicht.
|
||||
</p>
|
||||
<figure>
|
||||
<img src="https://cdn8.picryl.com/photo/2016/05/14/pythagoras-e9560b-1024.jpg" alt="Trulli" style="width:10%">
|
||||
<figcaption><a href="https://cdn8.picryl.com/photo/2016/05/14/pythagoras-e9560b-1024.jpg">Quelle</a></figcaption>
|
||||
</figure>
|
||||
<p>
|
||||
In der beigefügten Abbildung sehen wir ein rechtwinkliges Dreieck, dessen drei Seiten die Längen a, b und c
|
||||
besitzen. Auf jeder Seite ist ein Quadrat konstruiert. Das Quadrat auf der Seite a hat die Fläche a2, das
|
||||
Quadrat auf der Seite b hat die Fläche b2 und das Quadrat auf der Seite c hat die Fläche c2. Der Satz des
|
||||
Pythagoras besagt, dass die Summe der Flächen der beiden kleineren Quadrate gleich der Fläche des größten
|
||||
Quadrats ist. Das bedeutet, dass a^2+b^2=c^2 (Satz des Pythagoras).
|
||||
</p>
|
||||
<a href="docs/Uebungsaufgaben_Pythagoras.pdf">Lernzettel-Download</a>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,47 +0,0 @@
|
||||
<!--
|
||||
Artikel: Tunneleffekt
|
||||
Funktion: Inhalt zum Fach Physik
|
||||
TODO: entfernen, wenn die Kategorie-Anzeige implementiert ist.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="EduForge">
|
||||
<meta name="author" content="Niklas Ortmann">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/x-icon" href="images/logos/logo_icon.ico">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/navbar.css">
|
||||
<link rel="stylesheet" href="css/footer.css">
|
||||
<title>EduForge</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once 'includes/navbar.php';
|
||||
?>
|
||||
<main>
|
||||
|
||||
<h1>Tunneleffekt</h1>
|
||||
|
||||
<p>
|
||||
Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen – vor allem Elektronen – eine
|
||||
Energiebarriere überwinden können, obwohl sie nach den Regeln der klassischen Physik nicht genügend Energie
|
||||
dafür besitzen. In der klassischen Vorstellung müsste ein Elektron entweder genügend Energie haben, um über
|
||||
eine Barriere zu „springen“, oder es würde vollständig zurückgeworfen. In der Quantenphysik wird ein Elektron
|
||||
jedoch nicht als punktförmiges Teilchen beschrieben, sondern als Wellenfunktion, die sich räumlich ausdehnt.
|
||||
Dadurch besteht eine endliche Wahrscheinlichkeit, dass sich das Elektron auf der anderen Seite einer Barriere
|
||||
befindet (Griffiths & Schroeter, 2018).
|
||||
</p>
|
||||
|
||||
</main>
|
||||
|
||||
<?php
|
||||
include_once 'includes/footer.php';
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user