index.php

This commit is contained in:
2025-11-12 14:51:36 +01:00
parent 3cf4360017
commit 3ac6f07662

99
index.php Normal file
View File

@@ -0,0 +1,99 @@
<?php
session_start();
require __DIR__ . '/data/db.php';
require __DIR__ . '/functions/logging.php';
require __DIR__ . '/auth/ldap.php';
require __DIR__ . '/functions/ldap_groups.php';
$config = require __DIR__ . '/config/config.php';
if (!isset($_SESSION['user'])) {
header('Location: login.php');
exit;
}
$username = $_SESSION['user']['username'];
$message = '';
// Uitloggen
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['logout'])) {
log_action($pdo, $username, 'Uitloggen via index', 'Index pagina');
session_unset();
session_destroy();
header('Location: login.php');
exit;
}
// Huidige actieve ronde ophalen
$stmt = $pdo->prepare("SELECT * FROM lootjes_rondes WHERE status='open' ORDER BY created_at DESC LIMIT 1");
$stmt->execute();
$current_round = $stmt->fetch(PDO::FETCH_ASSOC);
// Lootje voor deze gebruiker ophalen
$lootje = null;
$ontvanger_wishlist = null;
if ($current_round) {
$stmtLootje = $pdo->prepare("SELECT ontvanger FROM lootjes WHERE ronde_id=? AND gever=?");
$stmtLootje->execute([$current_round['id'], $username]);
$lootje = $stmtLootje->fetchColumn();
if ($lootje) {
// Wishlist van de ontvanger ophalen
$stmtWishlist = $pdo->prepare("SELECT content FROM wishlist WHERE username=?");
$stmtWishlist->execute([$lootje]);
$ontvanger_wishlist = $stmtWishlist->fetchColumn();
}
}
?>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<title>Mijn Lootje</title>
<style>
body { font-family: Arial, sans-serif; }
h2 { color: #333; }
button { padding: 5px 10px; margin-top: 5px; }
textarea { width: 100%; height: 150px; }
.wishlist-box { border: 1px solid #ccc; padding: 10px; margin-top: 10px; }
</style>
</head>
<body>
<h2>Welkom, <?= htmlspecialchars($_SESSION['user']['displayName']) ?>!</h2>
<form method="post">
<button type="submit" name="logout">Uitloggen</button>
</form>
<?php if (!$current_round): ?>
<p>Er is momenteel geen actieve trekking.</p>
<?php else: ?>
<h3>Actieve ronde: <?= htmlspecialchars($current_round['naam']) ?></h3>
<?php if (!$lootje): ?>
<p>Je lootje is nog niet toegewezen.</p>
<?php else: ?>
<div class="wishlist-box">
<p><strong>Jij trekt voor:</strong> <?= htmlspecialchars($lootje) ?></p>
<?php if ($ontvanger_wishlist): ?>
<p><strong>Verlanglijstje van <?= htmlspecialchars($lootje) ?>:</strong></p>
<div style="border:1px solid #ddd; padding:10px; background:#f9f9f9;">
<?= nl2br(htmlspecialchars($ontvanger_wishlist)) ?>
</div>
<?php else: ?>
<p>Deze gebruiker heeft nog geen verlanglijstje ingevuld.</p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<p>
<a href="wishlist.php">Mijn eigen verlanglijstje aanpassen</a>
</p>
</body>
</html>