1e versie

This commit is contained in:
2025-11-12 10:17:30 +01:00
commit 6b5f9abec7
10 changed files with 255 additions and 0 deletions

44
includes/functions.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
function startNieuweRonde($pdo)
{
$config = require __DIR__ . '/../config/config.php';
$deelnemers = $config['deelnemers'];
$getrokken = [];
$targets = $deelnemers;
shuffle($targets);
// Zorg dat niemand zichzelf krijgt
do {
shuffle($targets);
} while (array_intersect_assoc($deelnemers, $targets));
foreach ($deelnemers as $i => $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']);
}