Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23321f90c2 | |||
| 90c6f67c24 | |||
| 7e2b29bfb0 | |||
| cd6aa80f59 | |||
| d5fdc9383f | |||
| 53865efc78 | |||
| 8cbd442371 | |||
| f54cf58dc2 | |||
| ede8e1cb21 | |||
| aaff15ee8c | |||
| bb7c85d770 | |||
| b7160f4df6 | |||
| a6b57bc352 | |||
| 70f7e05fe1 | |||
| 15f17b7af4 | |||
| 3c14df129d | |||
| 5660f8d59d | |||
| 11b55008ea | |||
| 46dcc16c59 | |||
| d42dff1165 | |||
| 11da418f60 | |||
| 981e78ff7e | |||
| c798bbd230 | |||
| e22d97e15a | |||
| c662369259 | |||
| 11b7be4ca0 | |||
| a029314bc9 | |||
| 8dd2d4f4ea | |||
| a4efbd4f0b | |||
| f63b8c6506 | |||
| 198fefbdf5 | |||
| 135bd7b9cd | |||
| 4cd0383322 | |||
| caa9a9ff8f | |||
| 524dc2a399 | |||
| 793d9632b2 | |||
| 5892a875c8 | |||
| b130bf9e19 | |||
| 1314362df9 | |||
| 5a1c032f1b | |||
| fae4bc86ad | |||
| 664092d52f | |||
| 22b1dd827d | |||
| 50df844e23 | |||
| 45b6b41d60 | |||
| a0a79e0191 | |||
| 46def40a14 |
Generated
+18
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="dataSourceStorageLocal" created-in="IU-261.24374.151">
|
||||||
|
<data-source 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" />
|
||||||
|
<secret-storage>master_key</secret-storage>
|
||||||
|
<auth-provider>no-auth</auth-provider>
|
||||||
|
<schema-mapping>
|
||||||
|
<introspection-scope>
|
||||||
|
<node kind="schema" qname="@" />
|
||||||
|
</introspection-scope>
|
||||||
|
</schema-mapping>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="articles" uuid="315cb5c9-2b0f-435b-b602-59823b160908">
|
||||||
|
<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>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+1833
File diff suppressed because it is too large
Load Diff
Generated
+2
@@ -0,0 +1,2 @@
|
|||||||
|
#n:main
|
||||||
|
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
||||||
+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>
|
||||||
@@ -19,13 +19,17 @@ Jeweils im Format `Anmeldename, Passwort, Mailadresse`:
|
|||||||
- Bitte auf die gesetzten TODO's achten. Wenn Inhalte fehlen, sind sie i.d.R. als TODO kommentiert.
|
- 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.
|
- 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.
|
- 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
|
## Besonderheiten des Projektes
|
||||||
- Es wurde ein einfacher Beitrags-Editor erstellt. Mit diesem können Beiträge erstellt oder bearbeitet werden.
|
- 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 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.
|
- 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 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).
|
- Die Such-Seite umfasst eine Suchfunktion (aber noch nicht nach Tags) und Sortierfunktion. Jedoch fehlt noch eine
|
||||||
Wenn die Filterfunktion implementiert ist, dann können die statischen Seiten "Informatik", "Mathe", "Physik" entfernt und dynamisch auf der Suchseite
|
Filterfunktion (z.B. nur Mathe anzeigen).
|
||||||
nach gefiltertem Fach angezeigt werden. (Vorläufige showCategory.php implementiert)
|
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).
|
||||||
|
|||||||
@@ -53,9 +53,8 @@ if (!isset($_SESSION["user"])) {
|
|||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserManager.php";
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
$dao = new LocalUserManager();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Deregistrierung
|
Deregistrierung
|
||||||
|
|||||||
+16
-8
@@ -2,7 +2,7 @@
|
|||||||
include_once 'php/controller/profile-controller.php';
|
include_once 'php/controller/profile-controller.php';
|
||||||
|
|
||||||
$user = $user ?? null;
|
$user = $user ?? null;
|
||||||
$isEditMode = isset($_GET["edit"]) && $_GET["edit"] === "1";
|
$isEditMode = (isset($_GET["edit"]) && $_GET["edit"] === "1") || !empty($error);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<main class="form-page">
|
<main class="form-page">
|
||||||
@@ -10,8 +10,8 @@ $isEditMode = isset($_GET["edit"]) && $_GET["edit"] === "1";
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<?php if (isset($error) && $error): ?>
|
<?php if (!empty($error)): ?>
|
||||||
<p style="color:red;">
|
<p class="alert-message is-error">
|
||||||
<?php echo htmlspecialchars($error); ?>
|
<?php echo htmlspecialchars($error); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -22,7 +22,7 @@ $isEditMode = isset($_GET["edit"]) && $_GET["edit"] === "1";
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
name="vorname"
|
name="vorname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
value="<?php echo htmlspecialchars($user["vorname"] ?? ""); ?>"
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? $user["vorname"] ?? ""); ?>"
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
required>
|
required>
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ $isEditMode = isset($_GET["edit"]) && $_GET["edit"] === "1";
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
name="nachname"
|
name="nachname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
value="<?php echo htmlspecialchars($user["nachname"] ?? ""); ?>"
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? $user["nachname"] ?? ""); ?>"
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
required>
|
required>
|
||||||
|
|
||||||
@@ -38,18 +38,26 @@ $isEditMode = isset($_GET["edit"]) && $_GET["edit"] === "1";
|
|||||||
<input type="email"
|
<input type="email"
|
||||||
name="email"
|
name="email"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
value="<?php echo htmlspecialchars($user["email"] ?? ""); ?>"
|
value="<?php echo htmlspecialchars($_POST["email"] ?? $user["email"] ?? ""); ?>"
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>
|
<?php echo $isEditMode ? "" : "readonly"; ?>
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<label class="input-label">
|
<label class="input-label">
|
||||||
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
<?php echo $isEditMode ? "Neues Passwort" : "Passwort"; ?>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<?php if ($isEditMode): ?>
|
||||||
<input type="password"
|
<input type="password"
|
||||||
name="password"
|
name="password"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="<?php echo $isEditMode ? "Leer lassen, wenn es gleich bleiben soll" : "********"; ?>"
|
placeholder="Leer lassen, wenn es gleich bleiben soll">
|
||||||
<?php echo $isEditMode ? "" : "readonly"; ?>>
|
<?php else: ?>
|
||||||
|
<input type="password"
|
||||||
|
name="password"
|
||||||
|
class="login-input"
|
||||||
|
value="********"
|
||||||
|
readonly>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once 'php/controller/register-controller.php';
|
|
||||||
|
|
||||||
$error = $error ?? null;
|
$error = $error ?? null;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Form: Registrierung
|
||||||
|
Funktion: Erstellung neuer Benutzerkonten
|
||||||
|
-->
|
||||||
<main class="login-page">
|
<main class="login-page">
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
|
|
||||||
<h1>Jetzt Registrieren!</h1>
|
<h1>Jetzt Registrieren!</h1>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<?php if (!empty($error)): ?>
|
||||||
<p style="color:red;">
|
<p class="alert-message is-error" style="color:red;">
|
||||||
<?php echo htmlspecialchars($error); ?>
|
<?php echo htmlspecialchars($error); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -22,6 +24,7 @@ $error = $error ?? null;
|
|||||||
name="email"
|
name="email"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="mustermann@web.de"
|
placeholder="mustermann@web.de"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["email"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Vorname:</p>
|
<p class="input-label">Vorname:</p>
|
||||||
@@ -29,6 +32,7 @@ $error = $error ?? null;
|
|||||||
name="vorname"
|
name="vorname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="Max"
|
placeholder="Max"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["vorname"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Nachname:</p>
|
<p class="input-label">Nachname:</p>
|
||||||
@@ -36,6 +40,7 @@ $error = $error ?? null;
|
|||||||
name="nachname"
|
name="nachname"
|
||||||
class="login-input"
|
class="login-input"
|
||||||
placeholder="Mustermann"
|
placeholder="Mustermann"
|
||||||
|
value="<?php echo htmlspecialchars($_POST["nachname"] ?? ""); ?>"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<p class="input-label">Passwort:</p>
|
<p class="input-label">Passwort:</p>
|
||||||
|
|||||||
+13
-13
@@ -58,28 +58,27 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if (isset($_SESSION["message"]) && $_SESSION["message"] == "not_found_article"): ?>
|
||||||
|
<p class="alert-message is-error">
|
||||||
|
Der zu bearbeitende Artikel wurde nicht gefunden. Bitte versuche es erneut.
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
unset($_SESSION["message"]);
|
unset($_SESSION["message"]);
|
||||||
?>
|
?>
|
||||||
<input type="text" id="title" name="title"
|
<input type="text" id="title" name="title"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
|
if (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
||||||
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_title']);
|
echo htmlspecialchars($_SESSION['old_title']);
|
||||||
unset($_SESSION['old_title']);
|
unset($_SESSION['old_title']);
|
||||||
|
}elseif (isset($title) && !empty($title)){
|
||||||
|
echo htmlspecialchars($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>"
|
?>"
|
||||||
placeholder="Titel hier eingeben" required>
|
placeholder="Titel hier eingeben" required>
|
||||||
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
|
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag..."><?php if (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){echo htmlspecialchars($_SESSION['old_content']); unset($_SESSION['old_content']);}elseif (isset($content) && !empty($content)){echo htmlspecialchars($content);}?></textarea>
|
||||||
<?php
|
|
||||||
if (isset($content) && !empty($content)){echo htmlspecialchars($content);
|
|
||||||
}elseif (isset($_SESSION['old_content']) && !empty($_SESSION['old_content'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_content']);
|
|
||||||
unset($_SESSION['old_content']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</textarea>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<!-- Seitenleiste -->
|
<!-- Seitenleiste -->
|
||||||
@@ -138,10 +137,11 @@ include_once 'php/controller/showArticle-controller.php';
|
|||||||
<label for="tags">Schlagwörter</label>
|
<label for="tags">Schlagwörter</label>
|
||||||
<input type="text" id="tags" name="tags"
|
<input type="text" id="tags" name="tags"
|
||||||
value="<?php
|
value="<?php
|
||||||
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
|
if (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
||||||
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
|
|
||||||
echo htmlspecialchars($_SESSION['old_tags']);
|
echo htmlspecialchars($_SESSION['old_tags']);
|
||||||
unset($_SESSION['old_tags']);
|
unset($_SESSION['old_tags']);
|
||||||
|
} elseif (isset($tags) && !empty($tags)){
|
||||||
|
echo htmlspecialchars($tags);
|
||||||
}
|
}
|
||||||
?>"
|
?>"
|
||||||
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
placeholder="z.B. Technik, IT (mit Komma trennen)">
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
ob_start();
|
ob_start();
|
||||||
@@ -52,8 +51,8 @@ if ($pfad === "deleteAccount") {
|
|||||||
<title>EduForge</title>
|
<title>EduForge</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
include_once 'includes/navbar.php';
|
include_once 'includes/navbar.php';
|
||||||
|
|
||||||
@@ -61,20 +60,15 @@ if ($pfad === "deleteAccount") {
|
|||||||
Dynamischer Inhalt:
|
Dynamischer Inhalt:
|
||||||
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
Je nach pfad-Parameter wird die passende Datei aus content geladen.
|
||||||
*/
|
*/
|
||||||
if (isset($_GET["pfad"])) {
|
if (file_exists('content/' . $pfad . '.php')) {
|
||||||
if (file_exists('content/' . $_GET["pfad"] . '.php')) {
|
include_once 'content/' . $pfad . '.php';
|
||||||
include_once 'content/' . $_GET["pfad"] . '.php';
|
|
||||||
} else {
|
} else {
|
||||||
include_once 'content/404.php';
|
include_once 'content/404.php';
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
include_once 'content/home.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once 'includes/footer.php';
|
include_once 'includes/footer.php';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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";
|
require_once "../model/LocalUserManager.php";
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
$_SESSION["old_title"] = $_POST["title"] ?? '';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserManager.php";
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
$dao = new LocalUserManager();
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserManager.php";
|
||||||
require_once 'php/model/Article.php';
|
require_once "php/model/Article.php";
|
||||||
require_once 'php/model/ArticleManager.php';
|
require_once "php/model/ArticleManager.php";
|
||||||
|
require_once "php/validator/user-validator.php";
|
||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
@@ -11,36 +12,8 @@ if (!isset($_SESSION["user"])) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Prüft Vor- und Nachnamen.
|
|
||||||
* Erlaubt sind Buchstaben, Umlaute, Leerzeichen und Bindestriche.
|
|
||||||
*/
|
|
||||||
function isValidName($name): bool {
|
|
||||||
return preg_match("/^[a-zA-ZäöüÄÖÜß -]{2,50}$/", $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prüft, ob die E-Mail-Adresse ein gültiges Format hat.
|
|
||||||
*/
|
|
||||||
function isValidEmailAddress($email): bool {
|
|
||||||
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
|
|
||||||
&& strlen($email) <= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prüft das neue Passwort.
|
|
||||||
* Leeres Passwort ist erlaubt, wenn der Nutzer es nicht ändern möchte.
|
|
||||||
*/
|
|
||||||
function isValidProfilePassword($password): bool {
|
|
||||||
if ($password === "") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return strlen($password) >= 8 && strlen($password) <= 72;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dao = new LocalUserDAO();
|
$dao = new LocalUserManager();
|
||||||
|
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||||
|
|
||||||
@@ -60,19 +33,22 @@ try {
|
|||||||
$nachname = trim($_POST["nachname"] ?? "");
|
$nachname = trim($_POST["nachname"] ?? "");
|
||||||
$password = $_POST["password"] ?? "";
|
$password = $_POST["password"] ?? "";
|
||||||
|
|
||||||
if (!isValidName($vorname)) {
|
if (!userEmailValidator($newEmail)) {
|
||||||
$error = "Der Vorname darf nur Buchstaben, Leerzeichen und Bindestriche enthalten und muss 2 bis 50 Zeichen lang sein.";
|
|
||||||
} elseif (!isValidName($nachname)) {
|
|
||||||
$error = "Der Nachname darf nur Buchstaben, Leerzeichen und Bindestriche enthalten und muss 2 bis 50 Zeichen lang sein.";
|
|
||||||
} elseif (!isValidEmailAddress($newEmail)) {
|
|
||||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||||
} elseif (!isValidProfilePassword($password)) {
|
$_GET["edit"] = "1";
|
||||||
$error = "Das Passwort muss mindestens 8 Zeichen lang sein.";
|
|
||||||
} else {
|
} elseif (!userNameValidator($vorname)) {
|
||||||
$existingUser = $dao->findUser($newEmail);
|
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userNameValidator($nachname)) {
|
||||||
|
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
|
} elseif (!userOptionalPasswordValidator($password)) {
|
||||||
|
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
if ($existingUser && $newEmail !== $oldEmail) {
|
|
||||||
$error = "Diese E-Mail-Adresse wird bereits verwendet.";
|
|
||||||
} else {
|
} else {
|
||||||
$updated = $dao->updateUser(
|
$updated = $dao->updateUser(
|
||||||
$oldEmail,
|
$oldEmail,
|
||||||
@@ -90,7 +66,7 @@ try {
|
|||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$error = "Die Daten konnten nicht gespeichert werden.";
|
$error = "Die Daten konnten nicht gespeichert werden.";
|
||||||
}
|
$_GET["edit"] = "1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +80,12 @@ try {
|
|||||||
$_SESSION["message"] = "user_has_no_articles";
|
$_SESSION["message"] = "user_has_no_articles";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
$_GET["edit"] = "1";
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
$error = "Es ist ein interner Fehler aufgetreten. Bitte versuche es erneut.";
|
||||||
$_SESSION["message"] = "internal_error";
|
$_SESSION["message"] = "internal_error";
|
||||||
|
$_GET["edit"] = "1";
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
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";
|
require_once "../model/LocalUserManager.php";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dao = new LocalUserDAO();
|
$dao = new LocalUserManager();
|
||||||
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
$user = $dao->findUser($_SESSION["user_email"] ?? "");
|
||||||
|
|
||||||
$author = $user["email"];
|
$author = $user["email"];
|
||||||
|
|||||||
@@ -1,37 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "php/model/LocalUserDAO.php";
|
require_once "php/model/LocalUserManager.php";
|
||||||
|
require_once "php/validator/user-validator.php";
|
||||||
|
|
||||||
$dao = new LocalUserDAO();
|
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
|
||||||
$email = $_POST["email"] ?? "";
|
$email = trim($_POST["email"] ?? "");
|
||||||
$vorname = $_POST["vorname"] ?? "";
|
$vorname = trim($_POST["vorname"] ?? "");
|
||||||
$nachname = $_POST["nachname"] ?? "";
|
$nachname = trim($_POST["nachname"] ?? "");
|
||||||
$password = password_hash(
|
$plainPassword = $_POST["password"] ?? "";
|
||||||
$_POST["password"] ?? "",
|
|
||||||
PASSWORD_DEFAULT
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($dao->findUser($email)) {
|
|
||||||
|
|
||||||
$error = "Diese E-Mail-Adresse ist bereits registriert.";
|
|
||||||
|
|
||||||
|
if (!userEmailValidator($email)) {
|
||||||
|
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||||
|
} elseif (!userNameValidator($vorname)) {
|
||||||
|
$error = "Der Vorname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
} elseif (!userNameValidator($nachname)) {
|
||||||
|
$error = "Der Nachname muss 2 bis 50 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||||
|
} elseif (!userPasswordValidator($plainPassword)) {
|
||||||
|
$error = "Das Passwort muss 8 bis 72 Zeichen lang sein.";
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
|
$dao = new LocalUserManager();
|
||||||
|
|
||||||
$dao->addUser(
|
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
||||||
$email,
|
|
||||||
$vorname,
|
$dao->addUser($email, $vorname, $nachname, $password);
|
||||||
$nachname,
|
|
||||||
$password
|
|
||||||
);
|
|
||||||
|
|
||||||
$_SESSION["user"] = $vorname . " " . $nachname;
|
$_SESSION["user"] = $vorname . " " . $nachname;
|
||||||
$_SESSION["user_email"] = $email;
|
$_SESSION["user_email"] = $email;
|
||||||
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$error = $e->getMessage();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Die Registrierung konnte nicht gespeichert werden.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
|
|
||||||
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
|
||||||
$_SESSION["message"] = "missing_parameters";
|
$_SESSION["message"] = "missing_parameters";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}else{
|
}else{
|
||||||
$title = $_POST["title"];
|
$title = $_POST["title"];
|
||||||
@@ -33,31 +33,31 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
// -------------------------------- Validierung der Daten: -------------------------
|
// -------------------------------- Validierung der Daten: -------------------------
|
||||||
if (!articleAuthorValidator($author)) {
|
if (!articleAuthorValidator($author)) {
|
||||||
$_SESSION["message"] = "author_not_valid";
|
$_SESSION["message"] = "author_not_valid";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTitleValidator($title)) {
|
if (!articleTitleValidator($title)) {
|
||||||
$_SESSION["message"] = "invalid_title";
|
$_SESSION["message"] = "invalid_title";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleContentValidator($content)) {
|
if (!articleContentValidator($content)) {
|
||||||
$_SESSION["message"] = "invalid_content";
|
$_SESSION["message"] = "invalid_content";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleCategoryValidator($category)) {
|
if (!articleCategoryValidator($category)) {
|
||||||
$_SESSION["message"] = "invalid_category";
|
$_SESSION["message"] = "invalid_category";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!articleTagValidator($tags)) {
|
if (!articleTagValidator($tags)) {
|
||||||
$_SESSION["message"] = "invalid_tags";
|
$_SESSION["message"] = "invalid_tags";
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
$cleanedTags = [];
|
$cleanedTags = [];
|
||||||
@@ -83,7 +83,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|||||||
$articleManager->updateArticle($id ,$article, $author);
|
$articleManager->updateArticle($id ,$article, $author);
|
||||||
} catch (Exception $e){
|
} catch (Exception $e){
|
||||||
$_SESSION["message"] = $e->getMessage();
|
$_SESSION["message"] = $e->getMessage();
|
||||||
header("location: ../../index.php?pfad=updateArticle");
|
header("location: ../../index.php?pfad=updateArticle&id=$id");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$_SESSION["message"] = "article_updated";
|
$_SESSION["message"] = "article_updated";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'LocalArticleManager.php';
|
require_once 'LocalArticleManager.php';
|
||||||
|
require_once 'DatabaseArticleManager.php';
|
||||||
require_once 'Article.php';
|
require_once 'Article.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,11 +8,11 @@ require_once 'Article.php';
|
|||||||
*
|
*
|
||||||
* @author Niklas Ortmann
|
* @author Niklas Ortmann
|
||||||
*/
|
*/
|
||||||
class ArticleManager extends LocalArticleManager
|
class ArticleManager
|
||||||
{
|
{
|
||||||
public static function getInstance()
|
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:
|
// Erstellen von Dummy-Beiträgen:
|
||||||
if($articleManager->getArticle(1) == null ){
|
if($articleManager->getArticle(1) == null ){
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ interface ArticleManagerDAO
|
|||||||
* @param $category string Kategorie des Beitrages
|
* @param $category string Kategorie des Beitrages
|
||||||
* @param $tags string optionale Schlagworte für eine bessere Suche
|
* @param $tags string optionale Schlagworte für eine bessere Suche
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* @throws InternalServerErrorException
|
||||||
* TODO: Exceptions implementieren.
|
|
||||||
*/
|
*/
|
||||||
public function addArticle($title, $content, $author, $category, $tags);
|
public function addArticle($title, $content, $author, $category, $tags);
|
||||||
|
|
||||||
@@ -38,33 +37,32 @@ interface ArticleManagerDAO
|
|||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
* @throws UnauthorizedAccessException
|
* @throws UnauthorizedAccessException
|
||||||
*/
|
*/
|
||||||
*/
|
|
||||||
public function updateArticle($id, $article, $author);
|
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 $id
|
||||||
|
* @param $author
|
||||||
* @return void
|
* @return void
|
||||||
*
|
* @throws InternalServerErrorException
|
||||||
* TODO: Exceptions implementieren.
|
* @throws NotFoundException
|
||||||
|
* @throws UnauthorizedAccessException
|
||||||
*/
|
*/
|
||||||
public function deleteArticle($id);
|
public function deleteArticle($id, $author);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Beitrag aufrufen.
|
* Beitrag aufrufen.
|
||||||
* $id ID des Beitrags
|
* $id ID des Beitrags
|
||||||
*
|
*
|
||||||
* @return Article
|
* @return Article
|
||||||
* Mögliche Exceptions:
|
* @throws InternalServerErrorException
|
||||||
* TODO: Exceptions implementieren.
|
|
||||||
*/
|
*/
|
||||||
public function getArticle($id);
|
public function getArticle($id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alle Beiträge aufrufen.
|
* Alle Beiträge aufrufen.
|
||||||
*
|
*
|
||||||
* Mögliche Exceptions:
|
* @throws InternalServerErrorException
|
||||||
* TODO: Exceptions implementieren.
|
|
||||||
*/
|
*/
|
||||||
public function getAllArticles();
|
public function getAllArticles();
|
||||||
|
|
||||||
@@ -72,7 +70,7 @@ 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.
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function getArticlesByAuthor($author);
|
public function getArticlesByAuthor($author);
|
||||||
|
|
||||||
@@ -89,6 +87,7 @@ interface ArticleManagerDAO
|
|||||||
* Gibt alle Beiträge einer gegebenen Kategorie aus.
|
* Gibt alle Beiträge einer gegebenen Kategorie aus.
|
||||||
* @param $category
|
* @param $category
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function getArticlesByCategory($category);
|
public function getArticlesByCategory($category);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,313 @@
|
|||||||
|
<?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 {
|
||||||
|
|
||||||
|
$db = $this->getConnection();
|
||||||
|
|
||||||
|
$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,26 @@
|
|||||||
|
<?php
|
||||||
|
require_once "UserManagerDAO.php";
|
||||||
|
|
||||||
|
class DatabaseUserManager implements UserManagerDAO {
|
||||||
|
|
||||||
|
public function findUser($email)
|
||||||
|
{
|
||||||
|
// TODO: Implement findUser() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addUser($email, $vorname, $nachname, $password)
|
||||||
|
{
|
||||||
|
// TODO: Implement addUser() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null)
|
||||||
|
{
|
||||||
|
// TODO: Implement updateUser() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteUser($email)
|
||||||
|
{
|
||||||
|
// TODO: Implement deleteUser() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
public function updateArticle($id, $article, $author)
|
public function updateArticle($id, $article, $author)
|
||||||
{
|
{
|
||||||
if (empty($article)) {
|
if (empty($article)) {
|
||||||
throw new InternalServerErrorException("internal_error");
|
throw new NotFoundException("not_found_article");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechtigungsprüfung:
|
// Berechtigungsprüfung:
|
||||||
@@ -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();
|
$articles = $this->getAllArticles();
|
||||||
$articleFound = false;
|
$articleFound = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "UserDAOInterface.php";
|
require_once "UserManagerDAO.php";
|
||||||
|
|
||||||
class LocalUserDAO implements UserDAOInterface {
|
class LocalUserManager implements UserManagerDAO {
|
||||||
|
|
||||||
private string $file = "data/users.json";
|
private string $file = "data/users.json";
|
||||||
|
|
||||||
|
public static function getInstance(){
|
||||||
|
// TODO: implement the getIsntance method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lädt alle Benutzer aus der JSON-Datei.
|
||||||
|
*
|
||||||
|
* @return array Liste aller Benutzer
|
||||||
|
* @throws RuntimeException wenn die Datei nicht gelesen werden kann
|
||||||
|
* oder fehlerhafte JSON-Daten enthält
|
||||||
|
*/
|
||||||
private function loadUsers() {
|
private function loadUsers() {
|
||||||
if (!file_exists($this->file)) {
|
if (!file_exists($this->file)) {
|
||||||
return [];
|
return [];
|
||||||
@@ -26,40 +37,35 @@ class LocalUserDAO implements UserDAOInterface {
|
|||||||
return is_array($users) ? $users : [];
|
return is_array($users) ? $users : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert alle Benutzer in die JSON-Datei.
|
||||||
|
*
|
||||||
|
* @param array $users Liste aller Benutzer
|
||||||
|
* @return void
|
||||||
|
* @throws RuntimeException wenn die Daten nicht gespeichert werden können
|
||||||
|
*/
|
||||||
private function saveUsers($users) {
|
private function saveUsers($users) {
|
||||||
$result = file_put_contents(
|
$json = json_encode($users, JSON_PRETTY_PRINT);
|
||||||
$this->file,
|
|
||||||
json_encode($users, JSON_PRETTY_PRINT)
|
if ($json === false) {
|
||||||
);
|
throw new RuntimeException("Benutzerdaten konnten nicht umgewandelt werden.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = file_put_contents($this->file, $json);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
throw new RuntimeException("Benutzerdaten konnten nicht gespeichert werden.");
|
throw new RuntimeException("Benutzerdaten konnten nicht gespeichert werden.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateEmail($email) {
|
/**
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
throw new InvalidArgumentException("Ungültige E-Mail-Adresse.");
|
*
|
||||||
}
|
* @param string $email E-Mail-Adresse des gesuchten Benutzers
|
||||||
}
|
* @return array|null Benutzerdaten oder null, wenn kein Benutzer gefunden wurde
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||||
private function validateName($name, $fieldName) {
|
*/
|
||||||
if (!preg_match("/^[a-zA-ZäöüÄÖÜß -]{2,50}$/", $name)) {
|
|
||||||
throw new InvalidArgumentException(
|
|
||||||
$fieldName . " darf nur Buchstaben, Leerzeichen und Bindestriche enthalten."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function validatePassword($password) {
|
|
||||||
if (empty($password)) {
|
|
||||||
throw new InvalidArgumentException("Passwort darf nicht leer sein.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findUser($email) {
|
public function findUser($email) {
|
||||||
$this->validateEmail($email);
|
|
||||||
|
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
@@ -78,12 +84,18 @@ class LocalUserDAO implements UserDAOInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt einen neuen Benutzer hinzu.
|
||||||
|
*
|
||||||
|
* @param string $email E-Mail-Adresse
|
||||||
|
* @param string $vorname Vorname
|
||||||
|
* @param string $nachname Nachname
|
||||||
|
* @param string $password Passwort-Hash
|
||||||
|
* @return void
|
||||||
|
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
public function addUser($email, $vorname, $nachname, $password) {
|
public function addUser($email, $vorname, $nachname, $password) {
|
||||||
$this->validateEmail($email);
|
|
||||||
$this->validateName($vorname, "Vorname");
|
|
||||||
$this->validateName($nachname, "Nachname");
|
|
||||||
$this->validatePassword($password);
|
|
||||||
|
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
@@ -102,12 +114,19 @@ class LocalUserDAO implements UserDAOInterface {
|
|||||||
$this->saveUsers($users);
|
$this->saveUsers($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert einen bestehenden Benutzer.
|
||||||
|
*
|
||||||
|
* @param string $oldEmail Alte E-Mail-Adresse
|
||||||
|
* @param string $newEmail Neue E-Mail-Adresse
|
||||||
|
* @param string $vorname Neuer Vorname
|
||||||
|
* @param string $nachname Neuer Nachname
|
||||||
|
* @param string|null $password Neues Passwort oder null
|
||||||
|
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||||
|
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) {
|
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null) {
|
||||||
$this->validateEmail($oldEmail);
|
|
||||||
$this->validateEmail($newEmail);
|
|
||||||
$this->validateName($vorname, "Vorname");
|
|
||||||
$this->validateName($nachname, "Nachname");
|
|
||||||
|
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
@@ -140,9 +159,16 @@ class LocalUserDAO implements UserDAOInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Löscht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
|
*
|
||||||
|
* TODO: wenn ein Benutzer gelöscht wird, sollten dann auch seine Beiträge gelöscht werden?
|
||||||
|
*
|
||||||
|
* @param string $email E-Mail-Adresse des zu löschenden Benutzers
|
||||||
|
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||||
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
|
*/
|
||||||
public function deleteUser($email) {
|
public function deleteUser($email) {
|
||||||
$this->validateEmail($email);
|
|
||||||
|
|
||||||
$users = $this->loadUsers();
|
$users = $this->loadUsers();
|
||||||
|
|
||||||
foreach ($users as $i => $user) {
|
foreach ($users as $i => $user) {
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
require_once "UserManagerDAO.php";
|
||||||
|
|
||||||
|
class UserManager extends LocalUserManager{
|
||||||
|
|
||||||
|
public static function getInstance(){
|
||||||
|
// TODO: implement this.
|
||||||
|
// TODO: dummy-user anlegen: - `max.mustermann, test123, mustermann@web.de` (analog zu ArticleManager)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Definiert die Methoden, die jede UserDAO-Implementierung
|
* Definiert die Methoden, die jede UserDAO-Implementierung
|
||||||
* bereitstellen muss.
|
* bereitstellen muss.
|
||||||
*/
|
*/
|
||||||
interface UserDAOInterface {
|
interface UserManagerDAO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
* Sucht einen Benutzer anhand seiner E-Mail-Adresse.
|
||||||
@@ -21,7 +21,6 @@ interface UserDAOInterface {
|
|||||||
* @return array|null Benutzerdaten als Array oder null
|
* @return array|null Benutzerdaten als Array oder null
|
||||||
*
|
*
|
||||||
* Mögliche Fehler:
|
* Mögliche Fehler:
|
||||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse ungültig ist
|
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen werden können
|
||||||
*/
|
*/
|
||||||
public function findUser($email);
|
public function findUser($email);
|
||||||
@@ -43,9 +42,8 @@ interface UserDAOInterface {
|
|||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* Mögliche Fehler:
|
* Mögliche Fehler:
|
||||||
* @throws InvalidArgumentException wenn Eingabedaten ungültig sind
|
* @throws InvalidArgumentException wenn die E-Mail-Adresse bereits verwendet wird
|
||||||
* oder die E-Mail-Adresse bereits verwendet wird
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gespeichert werden können
|
|
||||||
*/
|
*/
|
||||||
public function addUser($email, $vorname, $nachname, $password);
|
public function addUser($email, $vorname, $nachname, $password);
|
||||||
|
|
||||||
@@ -67,10 +65,8 @@ interface UserDAOInterface {
|
|||||||
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
* @return bool true, wenn der Benutzer aktualisiert wurde, sonst false
|
||||||
*
|
*
|
||||||
* Mögliche Fehler:
|
* Mögliche Fehler:
|
||||||
* @throws InvalidArgumentException wenn Eingabedaten ungültig sind
|
* @throws InvalidArgumentException wenn die neue E-Mail-Adresse bereits verwendet wird
|
||||||
* oder die neue E-Mail-Adresse bereits verwendet wird
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen
|
|
||||||
* oder gespeichert werden können
|
|
||||||
*/
|
*/
|
||||||
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null);
|
public function updateUser($oldEmail, $newEmail, $vorname, $nachname, $password = null);
|
||||||
|
|
||||||
@@ -87,9 +83,7 @@ interface UserDAOInterface {
|
|||||||
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
* @return bool true, wenn der Benutzer gelöscht wurde, sonst false
|
||||||
*
|
*
|
||||||
* Mögliche Fehler:
|
* Mögliche Fehler:
|
||||||
* @throws InvalidArgumentException wenn die E-Mail-Adresse ungültig ist
|
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen oder gespeichert werden können
|
||||||
* @throws RuntimeException wenn die Benutzerdaten nicht gelesen
|
|
||||||
* oder gespeichert werden können
|
|
||||||
*/
|
*/
|
||||||
public function deleteUser($email);
|
public function deleteUser($email);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function userNameValidator($name)
|
||||||
|
{
|
||||||
|
$name = trim($name);
|
||||||
|
$namePattern = '/^[a-zA-ZäöüÄÖÜß\s-]{2,50}$/u';
|
||||||
|
|
||||||
|
return preg_match($namePattern, $name) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userEmailValidator($email)
|
||||||
|
{
|
||||||
|
$email = trim($email);
|
||||||
|
|
||||||
|
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false
|
||||||
|
&& mb_strlen($email) <= 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userPasswordValidator($password)
|
||||||
|
{
|
||||||
|
$zeichenAnzahl = mb_strlen($password);
|
||||||
|
|
||||||
|
return $zeichenAnzahl >= 8 && $zeichenAnzahl <= 72;
|
||||||
|
}
|
||||||
|
|
||||||
|
function userOptionalPasswordValidator($password)
|
||||||
|
{
|
||||||
|
if (!isset($password) || $password === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return userPasswordValidator($password);
|
||||||
|
}
|
||||||
@@ -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