Display-Seiten: Betriebszeiten, PIN, Gerätesperre, Sprache und Vorschau
All checks were successful
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 39s
CI / Unit Tests & Static Analysis (push) Successful in 38s
CI / PHP Lint (pull_request) Successful in 41s
CI / PHP Lint-1 (pull_request) Successful in 49s
CI / Unit Tests & Static Analysis (pull_request) Successful in 41s
All checks were successful
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 39s
CI / Unit Tests & Static Analysis (push) Successful in 38s
CI / PHP Lint (pull_request) Successful in 41s
CI / PHP Lint-1 (pull_request) Successful in 49s
CI / Unit Tests & Static Analysis (pull_request) Successful in 41s
Die Display-Seiten hängen an öffentlichen Links, deshalb bekommen sie Regler, mit denen sich der Missbrauch begrenzen lässt, und ein paar Komfortfunktionen für den Betrieb: - Betriebszeiten je Seite (auch über Mitternacht hinweg); außerhalb zeigt die Seite einen Hinweis statt des Buttons - Optionale PIN von der Rezeption, geprüft mit hash_equals - Wartezeit je Gerät über ein Cookie, zusätzlich zum globalen Cooldown - Feste Sprache je Seite, sonst Browsersprache; Gäste können unten umschalten - Reporting zeigt die Ausgabe pro Display-Seite - Vorschau der Seite direkt in der Administration - Backup exportiert und importiert die neuen Felder mit Migration 0007, 16 neue Sprachschlüssel, 7 zusätzliche Tests (69 Tests, 152 Assertions). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
88f40a3d21
commit
dd8e805e27
28 changed files with 478 additions and 26 deletions
65
kiosk.php
65
kiosk.php
|
|
@ -20,8 +20,6 @@ require_once __DIR__ . '/includes/Ui.php';
|
|||
require_once __DIR__ . '/includes/Kiosk.php';
|
||||
require_once __DIR__ . '/includes/VoucherService.php';
|
||||
|
||||
I18n::init();
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$auth = new Auth();
|
||||
|
|
@ -30,9 +28,22 @@ try {
|
|||
die('Datenbankfehler');
|
||||
}
|
||||
|
||||
$token = Kiosk::sanitizeToken($_GET['k'] ?? '');
|
||||
|
||||
// Sprache bestimmen, bevor Texte gebraucht werden: Auswahl des Gastes,
|
||||
// sonst die Vorgabe der Display-Seite, sonst die Browsersprache.
|
||||
if (!isset($_SESSION)) {
|
||||
if (session_status() === PHP_SESSION_NONE) { @session_start(); }
|
||||
}
|
||||
$kioskRow = $token !== '' ? Kiosk::findByToken($db, $token) : null;
|
||||
if (!isset($_GET['set_lang']) && $kioskRow && !empty($kioskRow['language'])) {
|
||||
$_SESSION['language'] = in_array($kioskRow['language'], ['de', 'en'], true) ? $kioskRow['language'] : 'de';
|
||||
}
|
||||
|
||||
I18n::init();
|
||||
|
||||
$appTitle = $db->getSetting('app_title', 'UniFi Voucher System');
|
||||
$token = Kiosk::sanitizeToken($_GET['k'] ?? '');
|
||||
$kiosk = $token !== '' ? Kiosk::findByToken($db, $token) : null;
|
||||
$kiosk = $kioskRow;
|
||||
|
||||
if (!$kiosk) {
|
||||
http_response_code(404);
|
||||
|
|
@ -46,15 +57,28 @@ $error = '';
|
|||
$waitSecs = 0;
|
||||
|
||||
if (!$notFound && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$cookieName = 'kiosk_' . (int)$kiosk['id'];
|
||||
$deviceLast = isset($_COOKIE[$cookieName]) ? (int)$_COOKIE[$cookieName] : null;
|
||||
$deviceWait = Kiosk::deviceCooldownLeft($kiosk, $deviceLast);
|
||||
|
||||
if (!$auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$error = __('error_csrf');
|
||||
} elseif (!Kiosk::pinMatches($kiosk, $_POST['pin'] ?? '')) {
|
||||
$error = __('kiosk_error_pin');
|
||||
} elseif ($deviceWait > 0) {
|
||||
$waitSecs = $deviceWait;
|
||||
$error = str_replace('{seconds}', (string)$deviceWait, __('kiosk_error_device'));
|
||||
} else {
|
||||
$limits = Kiosk::checkLimits($db, $kiosk);
|
||||
if (!$limits['allowed']) {
|
||||
$waitSecs = (int)$limits['wait'];
|
||||
$error = $limits['reason'] === 'cooldown'
|
||||
? str_replace('{seconds}', (string)$waitSecs, __('kiosk_error_cooldown'))
|
||||
: __('kiosk_error_limit');
|
||||
if ($limits['reason'] === 'cooldown') {
|
||||
$error = str_replace('{seconds}', (string)$waitSecs, __('kiosk_error_cooldown'));
|
||||
} elseif ($limits['reason'] === 'closed') {
|
||||
$error = __('kiosk_error_closed');
|
||||
} else {
|
||||
$error = __('kiosk_error_limit');
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$site = $db->fetchOne("SELECT * FROM sites WHERE id = ? AND is_active = 1", [(int)$kiosk['site_id']]);
|
||||
|
|
@ -75,6 +99,14 @@ if (!$notFound && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
);
|
||||
|
||||
Kiosk::markUsed($db, (int)$kiosk['id']);
|
||||
if ((int)($kiosk['device_cooldown_seconds'] ?? 0) > 0 && !headers_sent()) {
|
||||
setcookie($cookieName, (string)time(), [
|
||||
'expires' => time() + (int)$kiosk['device_cooldown_seconds'],
|
||||
'path' => '/',
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
}
|
||||
$auth->writeAuditLog(null, 'voucher_kiosk', 'kiosk', (int)$kiosk['id'],
|
||||
$kiosk['name'] . ' · ' . $voucher['code']);
|
||||
} catch (Exception $e) {
|
||||
|
|
@ -176,6 +208,13 @@ if ($look['accent'] !== '') {
|
|||
|
||||
<form method="post" id="kioskForm">
|
||||
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($auth->getCsrfToken()) ?>">
|
||||
<?php if (trim((string)($kiosk['pin'] ?? '')) !== ''): ?>
|
||||
<div class="kiosk-pin">
|
||||
<label for="pin"><?= __('kiosk_pin_label') ?></label>
|
||||
<input type="text" id="pin" name="pin" class="code-input" inputmode="numeric"
|
||||
autocomplete="off" maxlength="12" required>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<button type="submit" class="btn btn-primary kiosk-button" id="kioskButton"
|
||||
<?= $waitSecs > 0 ? 'disabled' : '' ?>>
|
||||
<i class="fas fa-wifi" aria-hidden="true"></i>
|
||||
|
|
@ -191,7 +230,17 @@ if ($look['accent'] !== '') {
|
|||
</main>
|
||||
<?php endif; ?>
|
||||
|
||||
<footer class="kiosk-footer"><?= Ui::credit() ?></footer>
|
||||
<footer class="kiosk-footer">
|
||||
<?php if (!$notFound): ?>
|
||||
<div class="kiosk-langs" role="group" aria-label="<?= __('a11y_language') ?>">
|
||||
<?php foreach (I18n::getAvailable() as $code => $label): ?>
|
||||
<a class="kiosk-lang <?= I18n::getLanguage() === $code ? 'active' : '' ?>"
|
||||
href="?k=<?= htmlspecialchars($kiosk['token']) ?>&set_lang=<?= $code ?>"><?= strtoupper($code) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?= Ui::credit() ?>
|
||||
</footer>
|
||||
|
||||
<?php if (!$notFound): ?>
|
||||
<script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue