false, 'player' => null, ]; $personRequested = (string) ($_GET['p'] ?? ''); foreach ($persons as $hash => $person) { if ($personRequested === (string) $hash) { $_['player'] = $person; $_['hash'] = $personRequested; } } if ($_['player']) { $_['result'] = getData('result.'.$_['player']); $_['canPlay'] = empty($_['result']); $in = getData('in', $persons); $out = getData('out', []); if ($_['canPlay'] && isset($_GET['go'])) { $result = null; while ($result === null) { $key = array_rand($in); $value = $in[$key]; $ok = $value !== $_['player']; foreach ($restrictions as $restriction) { if (in_array($value, $restriction) && in_array($_['player'], $restriction)) { $ok = false; } } if ($ok) { $result = $value; setData('result.'.$_['player'], $result); unset($in[$key]); $out[] = $value; $_['canPlay'] = false; $_['result'] = $result; } } setData('in', $in); setData('out', $out); saveDatabase(); } } require __DIR__.'/../template/index.php';