1.1.0
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ $name = $_POST["name"] ?? '';
|
||||
$link = $_POST["link"] ?? '';
|
||||
$price = $_POST["price"] ?? '';
|
||||
|
||||
$jsonFile = '../wishes.json';
|
||||
$jsonFile = '../assets/data.json';
|
||||
|
||||
$wishes = [];
|
||||
if (file_exists($jsonFile)) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
$id = intval($_GET["id"]);
|
||||
|
||||
$jsonFile = '../wishes.json';
|
||||
$jsonFile = '../assets/data.json';
|
||||
|
||||
if (file_exists($jsonFile)) {
|
||||
$wishes = json_decode(file_get_contents($jsonFile), true);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ $link = $_POST["link"];
|
||||
$price = $_POST["price"];
|
||||
$id = intval($_POST["id"]);
|
||||
|
||||
$jsonFile = '../wishes.json';
|
||||
$jsonFile = '../assets/data.json';
|
||||
|
||||
if (file_exists($jsonFile)) {
|
||||
$wishes = json_decode(file_get_contents($jsonFile), true);
|
||||
|
||||
+94
-59
@@ -1,67 +1,102 @@
|
||||
<?php
|
||||
require_once '../config.php';
|
||||
|
||||
ini_set("display_errors", 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$jsonFile = '../assets/data.json';
|
||||
$wishes = [];
|
||||
|
||||
if (file_exists($jsonFile)) {
|
||||
$jsonData = file_get_contents($jsonFile);
|
||||
$wishes = json_decode($jsonData, true);
|
||||
if (!$wishes) $wishes = [];
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Wunschliste von <?php include '../config.php'; echo $page_name; ?> [ADMIN]</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (isset($_GET["error"])) {
|
||||
echo '<div class="alert alert-danger" role="alert">
|
||||
Dateisystem Fehler (Schreibrechte prüfen!).
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
<div class="container py-5">
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
||||
<?php
|
||||
ini_set("display_errors", 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$jsonFile = '../wishes.json';
|
||||
$wishes = [];
|
||||
|
||||
if (file_exists($jsonFile)) {
|
||||
$jsonData = file_get_contents($jsonFile);
|
||||
$wishes = json_decode($jsonData, true);
|
||||
if (!$wishes) $wishes = [];
|
||||
}
|
||||
|
||||
foreach ($wishes as $row) {
|
||||
echo '
|
||||
<div class="col">
|
||||
<div class="card link-card h-100">
|
||||
<div class="card-body">
|
||||
<form action="edit.php" method="post">
|
||||
<input type="hidden" name="id" value="' . $row["id"] . '">
|
||||
<input type="text" name="name" class="form-control mb-2" value="' . htmlspecialchars($row["name"]) . '">
|
||||
<input type="text" name="link" class="form-control mb-2" value="' . htmlspecialchars($row["link"]) . '">
|
||||
<input type="text" name="price" class="form-control mb-2" value="' . htmlspecialchars($row["price"]) . '">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
<a href="delete.php?id=' . $row["id"] . '" class="btn btn-danger float-end">Löschen</a>
|
||||
</form>
|
||||
</div>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Wunschliste von <?= htmlspecialchars($page_name) ?> [ADMIN]</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<style>
|
||||
:root {
|
||||
--bg: <?= $color_bg_light ?>;
|
||||
--fg: <?= $color_fg_light ?>;
|
||||
--accent: <?= $color_accent_light ?>;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: <?= $color_bg_dark ?>;
|
||||
--fg: <?= $color_fg_dark ?>;
|
||||
--accent: <?= $color_accent_dark ?>;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="min-h-screen bg-[var(--bg)] text-[var(--fg)] transition-colors">
|
||||
<div class="max-w-5xl mx-auto px-4 py-10">
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-center mb-8">
|
||||
Wunschliste von <?= htmlspecialchars($page_name) ?> [ADMIN]
|
||||
</h1>
|
||||
|
||||
<?php if (isset($_GET["error"])): ?>
|
||||
<div class="mb-6 rounded-lg border border-red-300 bg-red-50 text-red-700 px-4 py-3 text-sm">
|
||||
Dateisystem Fehler (Schreibrechte prüfen!).
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<?php foreach ($wishes as $row):
|
||||
$id = $row["id"] ?? '';
|
||||
$name = $row["name"] ?? '';
|
||||
$link = $row["link"] ?? '';
|
||||
$price = $row["price"] ?? '';
|
||||
?>
|
||||
<div class="bg-[var(--bg)] border border-[var(--fg)]/10 rounded-xl shadow-sm p-5">
|
||||
<form action="edit.php" method="post" class="space-y-2">
|
||||
<input type="hidden" name="id" value="<?= htmlspecialchars($id) ?>">
|
||||
<input type="text" name="name" value="<?= htmlspecialchars($name) ?>"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<input type="text" name="link" value="<?= htmlspecialchars($link) ?>"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<input type="text" name="price" value="<?= htmlspecialchars($price) ?>"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<div class="flex items-center justify-between pt-1">
|
||||
<button type="submit"
|
||||
class="rounded-lg bg-[var(--accent)] text-white px-4 py-2 text-sm font-medium hover:opacity-90 transition-opacity">
|
||||
Speichern
|
||||
</button>
|
||||
<a href="delete.php?id=<?= urlencode($id) ?>"
|
||||
class="rounded-lg border border-red-300 text-red-600 px-4 py-2 text-sm font-medium hover:bg-red-50 transition-colors">
|
||||
Löschen
|
||||
</a>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
<div class="col">
|
||||
<div class="card link-card h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Neuer Wunsch</h5>
|
||||
<form action="add.php" method="post">
|
||||
<input type="text" name="name" class="form-control mb-2" placeholder="Name">
|
||||
<input type="text" name="link" class="form-control mb-2" placeholder="URL">
|
||||
<input type="text" name="price" class="form-control mb-2" placeholder="Preis">
|
||||
<button type="submit" class="btn btn-primary">Hinzufügen</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div class="bg-[var(--bg)] border border-[var(--fg)]/10 rounded-xl shadow-sm p-5">
|
||||
<h2 class="font-semibold mb-3">Neuer Wunsch</h2>
|
||||
<form action="add.php" method="post" class="space-y-2">
|
||||
<input type="text" name="name" placeholder="Name"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<input type="text" name="link" placeholder="URL"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<input type="text" name="price" placeholder="Preis"
|
||||
class="w-full rounded-lg border border-[var(--fg)]/20 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--accent)]">
|
||||
<button type="submit"
|
||||
class="w-full rounded-lg bg-[var(--accent)] text-white px-4 py-2 text-sm font-medium hover:opacity-90 transition-opacity">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user