Compare commits

...

27 Commits

Author SHA1 Message Date
viratex 12facddcd5 PDF vom Datenschema 2026-06-10 17:09:24 +02:00
NOrtmann1 9f9c92385d Update ArticleManager.php 2026-06-10 16:18:01 +02:00
NOrtmann1 9ecfc3b6f8 Pfadanpassungen 2026-06-10 16:16:40 +02:00
niklas.ortmann d00f2d9d53 Merge pull request 'DatabaseUserManager' (#25) from DatabaseUserManager into dev
Reviewed-on: #25
Reviewed-by: niklas.ortmann <ortmann.niklas@yahoo.de>
2026-06-10 16:15:38 +02:00
NOrtmann1 37a032aa9f Merge branch 'dev' of https://git.gigaworld.ddns.net/niklas.ortmann/webprogrammierung into dev 2026-06-10 16:15:11 +02:00
NOrtmann1 fd8e13eaa9 Update LocalArticleManager.php 2026-06-10 16:14:59 +02:00
niklas.ortmann b5d1e08d22 Merge pull request 'bugfix_updateArticle_missingID & updateArticle Leerzeichen im content' (#28) from bugfix_updateArticle_missingID into dev
Reviewed-on: #28
2026-06-10 16:08:08 +02:00
NOrtmann1 23321f90c2 Update createArticle.php 2026-06-10 16:05:07 +02:00
NOrtmann1 90c6f67c24 Update updateArticle.php 2026-06-10 16:04:06 +02:00
NOrtmann1 7e2b29bfb0 Update updateArticle.php 2026-06-10 16:00:01 +02:00
NOrtmann1 cd6aa80f59 Update updateArticle.php 2026-06-10 15:54:12 +02:00
NOrtmann1 d5fdc9383f Update updateArticle.php 2026-06-10 15:52:12 +02:00
NOrtmann1 53865efc78 redo 2026-06-09 19:06:30 +02:00
NOrtmann1 8cbd442371 unset der Eingaben verschoben 2026-06-09 19:05:04 +02:00
NOrtmann1 f54cf58dc2 Update updateArticle-controller.php 2026-06-09 18:57:26 +02:00
NOrtmann1 ede8e1cb21 Fehlermeldungsweiterleitung setzt nun die id 2026-06-09 18:55:09 +02:00
NOrtmann1 aaff15ee8c Update updateArticle-controller.php 2026-06-09 18:49:14 +02:00
NOrtmann1 bb7c85d770 .idea 2026-06-09 18:49:07 +02:00
NOrtmann1 b7160f4df6 .idea 2026-06-09 15:32:06 +02:00
NOrtmann1 a6b57bc352 Merge branch 'DatabaseArticleManager' into dev 2026-06-09 15:31:59 +02:00
NOrtmann1 70f7e05fe1 Update DatabaseArticleManager.php 2026-06-09 15:30:05 +02:00
NOrtmann1 15f17b7af4 .idea 2026-06-09 15:29:53 +02:00
niklas.ortmann 3c14df129d Create data_sources_history.xml 2026-06-08 12:04:56 +02:00
niklas.ortmann 5660f8d59d .idea 2026-06-08 11:15:42 +02:00
niklas.ortmann 198fefbdf5 Update LocalUserManager.php 2026-06-05 10:35:33 +02:00
niklas.ortmann 135bd7b9cd Update updateArticle.php 2026-06-05 10:33:21 +02:00
niklas.ortmann 4cd0383322 deleteArticle -> Autorisierungsprüfung 2026-06-05 10:31:09 +02:00
11 changed files with 77 additions and 43 deletions
+18
View File
@@ -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>&quot;</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>
+12
View File
@@ -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>
+2 -3
View File
@@ -53,9 +53,8 @@ if (!isset($_SESSION["user"])) {
<input type="text" id="title" name="title"
value="<?php echo htmlspecialchars($_SESSION['old_title'] ?? ''); unset($_SESSION['old_title']); ?>"
placeholder="Titel hier eingeben" required>
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
<?php echo htmlspecialchars($_SESSION['old_content'] ?? ''); unset($_SESSION['old_content']); ?>
</textarea>
<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>
</main>
<!-- Seitenleiste -->
+13 -13
View File
@@ -58,28 +58,27 @@ include_once 'php/controller/showArticle-controller.php';
Sie sind nicht berechtigt, diesen Beitrag zu bearbeiten.
</p>
<?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
unset($_SESSION["message"]);
?>
<input type="text" id="title" name="title"
value="<?php
if (isset($title) && !empty($title)){echo htmlspecialchars($title);
}elseif (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
if (isset($_SESSION['old_title']) && !empty($_SESSION['old_title'])){
echo htmlspecialchars($_SESSION['old_title']);
unset($_SESSION['old_title']);
}elseif (isset($title) && !empty($title)){
echo htmlspecialchars($title);
}
?>"
placeholder="Titel hier eingeben" required>
<textarea id="content" name="content" placeholder="Schreibe deinen Beitrag...">
<?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>
<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>
</main>
<!-- Seitenleiste -->
@@ -138,10 +137,11 @@ include_once 'php/controller/showArticle-controller.php';
<label for="tags">Schlagwörter</label>
<input type="text" id="tags" name="tags"
value="<?php
if (isset($tags) && !empty($tags)){echo htmlspecialchars($tags);
} elseif (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
if (isset($_SESSION['old_tags']) && !empty($_SESSION['old_tags'])){
echo htmlspecialchars($_SESSION['old_tags']);
unset($_SESSION['old_tags']);
} elseif (isset($tags) && !empty($tags)){
echo htmlspecialchars($tags);
}
?>"
placeholder="z.B. Technik, IT (mit Komma trennen)">
+2 -2
View File
@@ -17,12 +17,12 @@ if ($pfad === "register") {
}
if ($pfad === "logout") {
include_once "content/logout-controller.php";
include_once "php/controller/logout-controller.php";
exit();
}
if ($pfad === "deleteAccount") {
include_once "content/deleteAccount-controller.php";
include_once "php/controller/deleteAccount-controller.php";
exit();
}
?>
+7 -7
View File
@@ -21,7 +21,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
$_SESSION["message"] = "missing_parameters";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}else{
$title = $_POST["title"];
@@ -33,31 +33,31 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
// -------------------------------- Validierung der Daten: -------------------------
if (!articleAuthorValidator($author)) {
$_SESSION["message"] = "author_not_valid";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}
if (!articleTitleValidator($title)) {
$_SESSION["message"] = "invalid_title";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}
if (!articleContentValidator($content)) {
$_SESSION["message"] = "invalid_content";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}
if (!articleCategoryValidator($category)) {
$_SESSION["message"] = "invalid_category";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}
if (!articleTagValidator($tags)) {
$_SESSION["message"] = "invalid_tags";
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
} else {
$cleanedTags = [];
@@ -83,7 +83,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$articleManager->updateArticle($id ,$article, $author);
} catch (Exception $e){
$_SESSION["message"] = $e->getMessage();
header("location: ../../index.php?pfad=updateArticle");
header("location: ../../index.php?pfad=updateArticle&id=$id");
exit();
}
$_SESSION["message"] = "article_updated";
+3 -3
View File
@@ -19,7 +19,7 @@ class ArticleManager
$articleManager->addArticle(
"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",
"mustermann@web.de",
"mathe",
"Dreiecke, Dreiecksseiten berechnen"
);
@@ -28,7 +28,7 @@ class ArticleManager
$articleManager->addArticle(
"Tunneleffekt",
"Der Tunneleffekt ist ein quantenmechanisches Phänomen, bei dem Teilchen...",
"max.mustermann",
"mustermann@web.de",
"physik",
"Quantenphysik, Energie"
);
@@ -37,7 +37,7 @@ class ArticleManager
$articleManager->addArticle(
"Datenschutz vs Datensicherheit",
"Datenschutz ist in unserer digital vernetzten Welt allgegenwärtig...",
"max.mustermann",
"mustermann@web.de",
"informatik",
"Daten, DSGVO"
);
+2 -4
View File
@@ -20,10 +20,8 @@ class DatabaseArticleManager implements ArticleManagerDAO {
{
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 = $this->getConnection();
$db->exec("
CREATE TABLE articles (
+8 -3
View File
@@ -36,14 +36,19 @@ class LocalArticleManager implements ArticleManagerDAO {
* Speichert alle Artikel/Beiträge in der Datei.
* @param $articles
* @return void
* TODO: Exceptions implementieren.
* @throws InternalServerErrorException
*/
public function saveArticle($articles)
private function saveArticle($articles)
{
try{
file_put_contents(
$this->file,
json_encode($articles, JSON_PRETTY_PRINT)
);
}catch (Exception $e){
throw new InternalServerErrorException($e->getMessage());
}
}
public function addArticle($title, $content, $author, $category, $tags)
@@ -66,7 +71,7 @@ class LocalArticleManager implements ArticleManagerDAO {
public function updateArticle($id, $article, $author)
{
if (empty($article)) {
throw new InternalServerErrorException("internal_error");
throw new NotFoundException("not_found_article");
}
// Berechtigungsprüfung:
+2
View File
@@ -162,6 +162,8 @@ class LocalUserManager implements UserManagerDAO {
/**
* 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
Binary file not shown.