From 6b5f9abec75ac0950bc5f002b8e6976c6896d9d6 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 12 Nov 2025 10:17:30 +0100 Subject: [PATCH] 1e versie --- config/config.php | 26 +++++++++++++++++++++++++ includes/db.php | 14 ++++++++++++++ includes/functions.php | 44 ++++++++++++++++++++++++++++++++++++++++++ includes/ldap.php | 23 ++++++++++++++++++++++ public/admin.php | 31 +++++++++++++++++++++++++++++ public/dashboard.php | 34 ++++++++++++++++++++++++++++++++ public/index.php | 10 ++++++++++ public/login.php | 33 +++++++++++++++++++++++++++++++ public/logout.php | 6 ++++++ public/wishlist.php | 34 ++++++++++++++++++++++++++++++++ 10 files changed, 255 insertions(+) create mode 100644 config/config.php create mode 100644 includes/db.php create mode 100644 includes/functions.php create mode 100644 includes/ldap.php create mode 100644 public/admin.php create mode 100644 public/dashboard.php create mode 100644 public/index.php create mode 100644 public/login.php create mode 100644 public/logout.php create mode 100644 public/wishlist.php diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..f9abea4 --- /dev/null +++ b/config/config.php @@ -0,0 +1,26 @@ + [ + 'server' => 'ldap://jouw-ldap-server.local', + 'base_dn' => 'dc=voorbeeld,dc=nl', + 'user_dn' => 'ou=users,dc=voorbeeld,dc=nl' + ], + + 'db' => [ + 'host' => 'localhost', + 'name' => 'lootjesapp', + 'user' => 'lootjes', + 'pass' => 'lootjesIsGek12#' + ], + + // deelnemerslijst (alleen gebruikt bij initialisatie) + 'deelnemers' => [ + 'monica', + 'thomas', + 'emmy', + 'jozefien' + ], + + 'admin_users' => ['thomas'] // LDAP-gebruikersnaam van beheerder +]; + diff --git a/includes/db.php b/includes/db.php new file mode 100644 index 0000000..c666123 --- /dev/null +++ b/includes/db.php @@ -0,0 +1,14 @@ + PDO::ERRMODE_EXCEPTION] + ); +} catch (PDOException $e) { + die("Databaseverbinding mislukt: " . $e->getMessage()); +} + diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..80301bc --- /dev/null +++ b/includes/functions.php @@ -0,0 +1,44 @@ + $trekker) { + $getrokken[$trekker] = $targets[$i]; + } + + // Oude ronde archiveren + $archiefBestand = __DIR__ . '/../data/archief/' . date('Ymd_His') . '_lootjes.json'; + if (file_exists(__DIR__ . '/../data/lootjes.json')) { + rename(__DIR__ . '/../data/lootjes.json', $archiefBestand); + } + + file_put_contents(__DIR__ . '/../data/lootjes.json', json_encode($getrokken, JSON_PRETTY_PRINT)); + return $getrokken; +} + +function getLootjeVoor($gebruiker) +{ + $path = __DIR__ . '/../data/lootjes.json'; + if (!file_exists($path)) return null; + + $lootjes = json_decode(file_get_contents($path), true); + return $lootjes[$gebruiker] ?? null; +} + +function isAdmin($username) +{ + $config = require __DIR__ . '/../config/config.php'; + return in_array($username, $config['admin_users']); +} + diff --git a/includes/ldap.php b/includes/ldap.php new file mode 100644 index 0000000..a1d0fe0 --- /dev/null +++ b/includes/ldap.php @@ -0,0 +1,23 @@ + + + +Beheer + +

Beheerpagina

+

+ +
+ +
+ +

Terug

+ + + diff --git a/public/dashboard.php b/public/dashboard.php new file mode 100644 index 0000000..ed9cfa9 --- /dev/null +++ b/public/dashboard.php @@ -0,0 +1,34 @@ + + + +Dashboard + +

Welkom,

+ + +

Je hebt getrokken:

+ +

Er is nog geen ronde gestart.

+ + +

Mijn verlanglijstje

+ + +

Beheerpagina

+ + +

Uitloggen

+ + + diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..ecf72be --- /dev/null +++ b/public/index.php @@ -0,0 +1,10 @@ + + + +Login + +

Login

+
+
+
+ +
+

+ + + diff --git a/public/logout.php b/public/logout.php new file mode 100644 index 0000000..27487a8 --- /dev/null +++ b/public/logout.php @@ -0,0 +1,6 @@ +prepare("REPLACE INTO wishlists (user, wensen) VALUES (?, ?)"); + $stmt->execute([$gebruiker, $wensen]); +} + +$stmt = $pdo->prepare("SELECT wensen FROM wishlists WHERE user = ?"); +$stmt->execute([$gebruiker]); +$wensen = $stmt->fetchColumn(); +?> + + +Verlanglijstje + +

Mijn verlanglijstje

+
+
+ +
+

Terug

+ + +