From f40dacb11c9b1338c5a38fc3b48f4269996596e2 Mon Sep 17 00:00:00 2001 From: jaki48 Date: Mon, 28 Sep 2026 19:37:14 +0200 Subject: [PATCH] init --- README.md | 14 +++++++++- admin/add.php | 44 ++++++++++++++++++++++++++++++ admin/delete.php | 23 ++++++++++++++++ admin/edit.php | 31 ++++++++++++++++++++++ admin/index.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++ config.php | 13 +++++++++ index.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ wishes.json | 14 ++++++++++ 8 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 admin/add.php create mode 100644 admin/delete.php create mode 100644 admin/edit.php create mode 100644 admin/index.php create mode 100644 config.php create mode 100644 index.php create mode 100644 wishes.json diff --git a/README.md b/README.md index 9085e09..dbd8f60 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # Wunschliste -Eine simple PHP Wunschliste \ No newline at end of file +Dies ist eine einfache Wunschliste gemacht mit PHP! + + +## Installation + +Du installierst es einfach in dem du die ZIP Datei von den Releases Herunterlädst und es in dein Webserver mit PHP Hochlädst. + +Du kannst außerdem in der config.php deinen Namen angeben der Dan überall steht. + +Mit in /admin befindet sich das Admin Panel wo die die einträge verwalten kanst. + +> [!Warning] +> Die /admin Seite ist Standardmäßig nicht geschützt! Bitte schütze diese mit z.b. einem Login über den Webserver \ No newline at end of file diff --git a/admin/add.php b/admin/add.php new file mode 100644 index 0000000..f2734b8 --- /dev/null +++ b/admin/add.php @@ -0,0 +1,44 @@ + $newId, + 'name' => $name, + 'link' => $link, + 'price' => $price +]; + +$wishes[] = $newWish; + +if (file_put_contents($jsonFile, json_encode($wishes, JSON_PRETTY_PRINT)) !== false) { + header("Location: ."); +} else { + header("Location: .?error=write_failed"); +} +exit; +?> \ No newline at end of file diff --git a/admin/delete.php b/admin/delete.php new file mode 100644 index 0000000..54de54a --- /dev/null +++ b/admin/delete.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/admin/edit.php b/admin/edit.php new file mode 100644 index 0000000..0eb40e7 --- /dev/null +++ b/admin/edit.php @@ -0,0 +1,31 @@ + $wish) { + if ($wish['id'] == $id) { + $wishes[$key]['name'] = $name; + $wishes[$key]['link'] = $link; + $wishes[$key]['price'] = $price; + $found = true; + break; + } + } + + if ($found && file_put_contents($jsonFile, json_encode($wishes, JSON_PRETTY_PRINT))) { + header("Location: ."); + exit; + } +} + +header("Location: .?error=true"); +exit; +?> \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..b7b0756 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,67 @@ + + + + + + Wunschliste von <?php include '../config.php'; echo $page_name; ?> [ADMIN] + + + + + Dateisystem Fehler (Schreibrechte prüfen!). + '; + } + ?> +
+
+ + +
'; + } + ?> +
+ +
+
+ + + + \ No newline at end of file diff --git a/config.php b/config.php new file mode 100644 index 0000000..1fc6825 --- /dev/null +++ b/config.php @@ -0,0 +1,13 @@ + + + + + + Wunschliste von <?php include 'config.php'; echo $page_name; ?> + + + + +

Wunschliste von 🎁

+
+ +
+

+ +

+
+
Zum Produkt, ' . htmlspecialchars($price) . '
+
+
+
'; + } + ?> + + + + diff --git a/wishes.json b/wishes.json new file mode 100644 index 0000000..d2af85c --- /dev/null +++ b/wishes.json @@ -0,0 +1,14 @@ +[ + { + "id": 1, + "name": "Wunsch 1", + "link": "https:\/\/jakob48.de", + "price": "10 EUR" + }, + { + "id": 2, + "name": "Wunsch 1", + "link": "https:\/\/jakob48.de", + "price": "12 EUR" + } +] \ No newline at end of file