wl
This commit is contained in:
207
wishlist.php
207
wishlist.php
@@ -1,13 +1,3 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
$redirect = urlencode($_SERVER['REQUEST_URI']);
|
||||
header("Location: login.php?redirect=$redirect");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require __DIR__ . '/data/db.php';
|
||||
@@ -15,19 +5,22 @@ require __DIR__ . '/functions/logging.php';
|
||||
require __DIR__ . '/auth/ldap.php';
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header('Location: login.php'); // redirect naar login
|
||||
$redirect = urlencode($_SERVER['REQUEST_URI']);
|
||||
header("Location: login.php?redirect=$redirect");
|
||||
exit;
|
||||
}
|
||||
|
||||
$username = $_SESSION['user']['username'];
|
||||
$displayName = $_SESSION['user']['displayName'] ?? $username;
|
||||
$message = '';
|
||||
$isSuccess = true;
|
||||
|
||||
// Uitloggen knop
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['logout'])) {
|
||||
log_action($pdo, $username, 'Uitloggen via wishlist', 'Wishlist script');
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -36,13 +29,12 @@ if (isset($_POST['delete'])) {
|
||||
$stmt = $pdo->prepare("DELETE FROM wishlist WHERE id = ? AND username = ?");
|
||||
$stmt->execute([$_POST['delete'], $username]);
|
||||
log_action($pdo, $username, 'Wishlist item verwijderd', 'Wishlist script');
|
||||
$message = "Item verwijderd!";
|
||||
$message = "Je verlanglijstje is verwijderd.";
|
||||
}
|
||||
|
||||
// Opslaan / bijwerken
|
||||
if (isset($_POST['save'])) {
|
||||
$content = $_POST['content'] ?? '';
|
||||
// Check of er al een wishlist is
|
||||
$content = trim($_POST['content'] ?? '');
|
||||
$stmt = $pdo->prepare("SELECT id FROM wishlist WHERE username = ?");
|
||||
$stmt->execute([$username]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
@@ -50,12 +42,12 @@ if (isset($_POST['save'])) {
|
||||
$stmtUpdate = $pdo->prepare("UPDATE wishlist SET content = ? WHERE id = ?");
|
||||
$stmtUpdate->execute([$content, $row['id']]);
|
||||
log_action($pdo, $username, 'Wishlist geüpdatet', 'Wishlist script');
|
||||
$message = "Wishlist geüpdatet!";
|
||||
$message = "Je verlanglijstje is bijgewerkt.";
|
||||
} else {
|
||||
$stmtInsert = $pdo->prepare("INSERT INTO wishlist (username, content) VALUES (?, ?)");
|
||||
$stmtInsert->execute([$username, $content]);
|
||||
log_action($pdo, $username, 'Wishlist aangemaakt', 'Wishlist script');
|
||||
$message = "Wishlist aangemaakt!";
|
||||
$message = "Je verlanglijstje is aangemaakt!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,34 +57,178 @@ $stmt->execute([$username]);
|
||||
$wishlist = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$content = $wishlist['content'] ?? '';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Verlanglijstje</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Mijn Verlanglijstje</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary: #4c8bf5;
|
||||
--accent: #2e6ae3;
|
||||
--background: #f7f9fc;
|
||||
--card-bg: #fff;
|
||||
--border: #ddd;
|
||||
--text: #333;
|
||||
--muted: #666;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Segoe UI", Roboto, sans-serif;
|
||||
background: var(--background);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
header {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 800px;
|
||||
margin: 30px auto;
|
||||
background: var(--card-bg);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
||||
padding: 30px 40px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: var(--primary);
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border);
|
||||
padding: 10px;
|
||||
font-size: 1em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 8px 14px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
button.save {
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
}
|
||||
button.save:hover {
|
||||
background: #255bc7;
|
||||
}
|
||||
|
||||
button.delete {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
}
|
||||
button.delete:hover {
|
||||
background: #c0392b;
|
||||
}
|
||||
|
||||
button.logout {
|
||||
background: white;
|
||||
color: var(--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
button.logout:hover {
|
||||
background: #eef3ff;
|
||||
}
|
||||
|
||||
a.back {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
a.back:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 10px 14px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
.message.success {
|
||||
background: #e8f5e9;
|
||||
color: #256029;
|
||||
border: 1px solid #a5d6a7;
|
||||
}
|
||||
.message.error {
|
||||
background: #fdecea;
|
||||
color: #b71c1c;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
color: var(--muted);
|
||||
padding: 20px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Verlanglijstje van <?= htmlspecialchars($username) ?></h2>
|
||||
<form method="post">
|
||||
<button type="submit" name="logout">Uitloggen</button>
|
||||
</form>
|
||||
<header>
|
||||
<h1>🎁 Mijn Verlanglijstje</h1>
|
||||
<form method="post">
|
||||
<button type="submit" name="logout" class="logout">Afmelden</button>
|
||||
</form>
|
||||
</header>
|
||||
|
||||
<?php if($message): ?>
|
||||
<p style="color:green;"><?= htmlspecialchars($message) ?></p>
|
||||
<?php endif; ?>
|
||||
<main>
|
||||
<a href="index.php" class="back">← Terug naar overzicht</a>
|
||||
|
||||
<form method="post">
|
||||
<textarea id="content" name="content"><?= htmlspecialchars($content) ?></textarea><br>
|
||||
<button type="submit" name="save">Opslaan / Bijwerken</button>
|
||||
</form>
|
||||
<h2>Welkom, <?= htmlspecialchars($displayName) ?>!</h2>
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div class="message <?= $isSuccess ? 'success' : 'error' ?>">
|
||||
<?= htmlspecialchars($message) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post">
|
||||
<textarea id="content" name="content"><?= htmlspecialchars($content) ?></textarea><br><br>
|
||||
<button type="submit" name="save" class="save">💾 Opslaan / Bijwerken</button>
|
||||
</form>
|
||||
|
||||
<?php if ($wishlist): ?>
|
||||
<form method="post" style="margin-top:15px;">
|
||||
<button type="submit" name="delete" value="<?= $wishlist['id'] ?>" class="delete" onclick="return confirm('Weet je zeker dat je je verlanglijstje wilt verwijderen?');">
|
||||
🗑 Verwijderen
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
© <?= date('Y') ?> Lootjes Trekking — Alles voor een gezellige kerst 🎄
|
||||
</footer>
|
||||
|
||||
<?php if ($wishlist): ?>
|
||||
<form method="post" style="margin-top:10px;">
|
||||
<button type="submit" name="delete" value="<?= $wishlist['id'] ?>" onclick="return confirm('Weet je het zeker?');">Verwijderen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<script src="js/tinymce/tinymce.min.js"></script>
|
||||
<script>
|
||||
tinymce.init({
|
||||
@@ -106,4 +242,3 @@ tinymce.init({
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user