48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php $app = require '../../app/inc.php';
|
|
|
|
// TODO: refactor
|
|
|
|
$cardreader = $app->model('Cardreader');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
|
{
|
|
if (isset($_POST['cardnumber']) && strlen($_POST['cardnumber']) !== 0)
|
|
{
|
|
$cardnumber = $_POST['cardnumber'];
|
|
|
|
if (!(strlen($cardnumber) > 32)) {
|
|
|
|
$code = $cardreader->receive($cardnumber, 30);
|
|
switch ($code) {
|
|
case 0:
|
|
$app->session->flash('Opprettet nytt lag', 'success');
|
|
break;
|
|
|
|
case 1:
|
|
$app->session->flash('Startet telling', 'success');
|
|
break;
|
|
|
|
case 2:
|
|
$app->session->flash('Passerte en runde', 'success');
|
|
break;
|
|
|
|
case 3:
|
|
$app->session->flash('Runde gikk for fort!', 'danger');
|
|
break;
|
|
|
|
default:
|
|
$app->session->flash('Uhhh?? Dette skulle ikke skje', 'danger');
|
|
break;
|
|
}
|
|
|
|
} else {
|
|
$app->session->flash('Kortnummer for langt!', 'danger');
|
|
}
|
|
} else {
|
|
$app->session->flash('Kortnummer kan ikke være tom!', 'danger');
|
|
}
|
|
}
|
|
|
|
$app->view('template/header', ['title' => 'Simulator']);
|
|
$app->view('pages/race/simulator');
|
|
$app->view('template/footer'); |