50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php $app = require '../../../app/inc.php';
|
|
|
|
// uh oh.. stinky
|
|
|
|
$baton_reader = $app->model('BatonReader');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
|
{
|
|
if (isset($_POST['cardnumber']) && strlen((string)$_POST['cardnumber']) !== 0)
|
|
{
|
|
$cardnumber = (string)$_POST['cardnumber'];
|
|
|
|
try {
|
|
$code = $baton_reader->receive($cardnumber, $app->config['baton_cooldown']);
|
|
switch ($code) {
|
|
case 0:
|
|
$app->session->flash('Opprettet nytt lag', 'success');
|
|
break;
|
|
|
|
case 1:
|
|
$app->session->flash('Startet telling', 'info');
|
|
break;
|
|
|
|
case 2:
|
|
$app->session->flash('Runde gikk for fort!', 'danger');
|
|
break;
|
|
|
|
case 3:
|
|
$app->session->flash('Passerte en runde', 'info');
|
|
break;
|
|
|
|
case 4:
|
|
$app->session->flash('Passerte en runde, ny rekord!', 'success');
|
|
break;
|
|
|
|
default:
|
|
$app->session->flash('Uhhh?? Dette skulle ikke skje', 'danger');
|
|
break;
|
|
}
|
|
} catch (InvalidArgumentException $e) {
|
|
$app->session->flash("Noe gikk galt: {$e->getMessage()}", "danger");
|
|
}
|
|
} else {
|
|
$app->session->flash('Kortnummer kan ikke være tom!', 'danger');
|
|
}
|
|
}
|
|
|
|
$app->view('template/header', ['title' => 'Simulator']);
|
|
$app->view('pages/race/configure/simulator');
|
|
$app->view('template/footer'); |