45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?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']);
|
|
}
|
|
|