Display-Seiten: Betriebszeiten, PIN, Gerätesperre, Sprache und Vorschau #11
19
Readme.md
|
|
@ -10,7 +10,7 @@ Entwickelt von **[Loheide.eu](https://loheide.eu)**
|
|||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://git.loheide.cloud/friloo/Unifi-Voucher-Tool)
|
||||
|
||||
|
|
@ -248,6 +248,10 @@ Personal am Tresen.
|
|||
| Überschrift / Text | was auf dem Bildschirm steht |
|
||||
| Codes pro Tag | Obergrenze je Kalendertag (0 = unbegrenzt) |
|
||||
| Wartezeit | Abstand zwischen zwei Codes an diesem Display |
|
||||
| Wartezeit je Gerät | zusätzliche Sperre pro Browser (Cookie) – gegen das Leerziehen durch eine Person |
|
||||
| Servicezeiten | z. B. 06:00–23:00; außerhalb erscheint ein Hinweis statt des Knopfes. Fenster über Mitternacht möglich |
|
||||
| PIN | optionale Eingabe, sinnvoll bei frei zugänglichen Bildschirmen |
|
||||
| Sprache | feste Sprache des Displays oder automatisch nach Browsersprache |
|
||||
| Anzeigedauer | danach springt der Bildschirm automatisch zurück |
|
||||
|
||||
Jede Seite hat einen **eigenen, geheimen Link** (`kiosk.php?k=…`). Er lässt sich
|
||||
|
|
@ -276,9 +280,14 @@ Logo und Hintergrund lassen sich direkt hochladen (PNG, JPG, WEBP, GIF, SVG bis
|
|||
3 MB) oder als URL hinterlegen; beim Löschen einer Display-Seite verschwinden
|
||||
die hochgeladenen Dateien mit.
|
||||
|
||||
Die ausgegebenen Codes erscheinen normal in *Live Vouchers*, im *Reporting* und
|
||||
im *Audit-Log* (Aktion „Voucher am Display geholt"), sodass jederzeit
|
||||
nachvollziehbar bleibt, woher ein Zugang stammt.
|
||||
Die ausgegebenen Codes erscheinen normal in *Live Vouchers*, im *Reporting* –
|
||||
dort gibt es eine eigene Auswertung **„Pro Display-Seite"** – und im *Audit-Log*
|
||||
(Aktion „Voucher am Display geholt"), sodass jederzeit nachvollziehbar bleibt,
|
||||
woher ein Zugang stammt.
|
||||
|
||||
In der Verwaltung zeigt **„Vorschau"** die Seite direkt im Admin-Bereich, ohne
|
||||
den Tab zu wechseln. Gäste können die Sprache unten auf dem Display selbst
|
||||
umschalten.
|
||||
|
||||
> Display-Seiten funktionieren unabhängig vom globalen öffentlichen Modus – der
|
||||
> geheime Link ist der Zugang. Webhook-Benachrichtigungen werden für diese Codes
|
||||
|
|
@ -702,7 +711,7 @@ dem Git-Hoster.
|
|||
|
||||
<div align="center">
|
||||
|
||||
**Version 2.8.0** · Autor: **Friederich Loheide** · Lizenz: **MIT**
|
||||
**Version 2.9.0** · Autor: **Friederich Loheide** · Lizenz: **MIT**
|
||||
|
||||
Entwickelt von **[Loheide.eu](https://loheide.eu)**
|
||||
|
||||
|
|
|
|||
2
VERSION
|
|
@ -1 +1 @@
|
|||
2.8.0
|
||||
2.9.0
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ if (isset($_GET['export']) && isset($_GET['token']) && $auth->validateCsrfToken(
|
|||
'kiosks' => $db->fetchAll(
|
||||
"SELECT k.name, k.token, k.headline, k.subline, k.logo_url, k.background_url,
|
||||
k.bg_overlay, k.accent_color, k.card_style, k.daily_limit,
|
||||
k.cooldown_seconds, k.display_seconds, k.is_active,
|
||||
k.cooldown_seconds, k.display_seconds, k.active_from, k.active_to,
|
||||
k.device_cooldown_seconds, k.pin, k.language, k.is_active,
|
||||
s.name AS site_name, t.name AS template_name
|
||||
FROM kiosks k
|
||||
INNER JOIN sites s ON s.id = k.site_id
|
||||
|
|
@ -126,22 +127,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import'])) {
|
|||
$k['logo_url'] ?? null, $k['background_url'] ?? null, (int)($k['bg_overlay'] ?? 45),
|
||||
$k['accent_color'] ?? null, ($k['card_style'] ?? 'light') === 'dark' ? 'dark' : 'light',
|
||||
(int)($k['daily_limit'] ?? 100), (int)($k['cooldown_seconds'] ?? 20),
|
||||
(int)($k['display_seconds'] ?? 90), (int)($k['is_active'] ?? 1),
|
||||
(int)($k['display_seconds'] ?? 90),
|
||||
$k['active_from'] ?? null, $k['active_to'] ?? null,
|
||||
(int)($k['device_cooldown_seconds'] ?? 0),
|
||||
$k['pin'] ?? null, $k['language'] ?? null,
|
||||
(int)($k['is_active'] ?? 1),
|
||||
];
|
||||
|
||||
if ($exists) {
|
||||
$db->query(
|
||||
"UPDATE kiosks SET site_id=?, template_id=?, name=?, headline=?, subline=?, logo_url=?,
|
||||
background_url=?, bg_overlay=?, accent_color=?, card_style=?, daily_limit=?,
|
||||
cooldown_seconds=?, display_seconds=?, is_active=? WHERE id=?",
|
||||
cooldown_seconds=?, display_seconds=?, active_from=?, active_to=?,
|
||||
device_cooldown_seconds=?, pin=?, language=?, is_active=? WHERE id=?",
|
||||
array_merge($values, [(int)$exists['id']])
|
||||
);
|
||||
} else {
|
||||
$db->query(
|
||||
"INSERT INTO kiosks (site_id, template_id, name, headline, subline, logo_url, background_url,
|
||||
bg_overlay, accent_color, card_style, daily_limit, cooldown_seconds, display_seconds,
|
||||
active_from, active_to, device_cooldown_seconds, pin, language,
|
||||
is_active, token, created_by)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
array_merge($values, [$k['token'] ?? Kiosk::newToken(), $_SESSION['user_id'] ?? null])
|
||||
);
|
||||
}
|
||||
|
|
|
|||
117
admin/kiosks.php
|
|
@ -44,9 +44,22 @@ function kioskInput(): array
|
|||
'bg_overlay' => max(0, min(90, (int)($_POST['bg_overlay'] ?? 45))),
|
||||
'accent_color' => self_accent($_POST['accent_color'] ?? ''),
|
||||
'card_style' => ($_POST['card_style'] ?? 'light') === 'dark' ? 'dark' : 'light',
|
||||
'active_from' => self_time($_POST['active_from'] ?? ''),
|
||||
'active_to' => self_time($_POST['active_to'] ?? ''),
|
||||
'device_cooldown_seconds' => max(0, min(86400, (int)($_POST['device_cooldown_seconds'] ?? 0))),
|
||||
'pin' => preg_replace('/[^0-9A-Za-z]/', '', (string)($_POST['pin'] ?? '')) ?: null,
|
||||
'language' => in_array($_POST['language'] ?? '', ['de', 'en'], true) ? $_POST['language'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
/** Uhrzeit im Format HH:MM oder nichts. */
|
||||
function self_time($value): ?string
|
||||
{
|
||||
$value = trim((string)$value);
|
||||
|
||||
return preg_match('/^([01]\d|2[0-3]):[0-5]\d$/', $value) ? $value : null;
|
||||
}
|
||||
|
||||
/** Nur echte Hex-Farben durchlassen – der Wert landet in einem style-Attribut. */
|
||||
function self_accent($value): ?string
|
||||
{
|
||||
|
|
@ -70,12 +83,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_kiosk'])) {
|
|||
$db->execute(
|
||||
"INSERT INTO kiosks (site_id, template_id, name, token, headline, subline,
|
||||
logo_url, background_url, bg_overlay, accent_color, card_style,
|
||||
daily_limit, cooldown_seconds, display_seconds, is_active, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?)",
|
||||
daily_limit, cooldown_seconds, display_seconds,
|
||||
active_from, active_to, device_cooldown_seconds, pin, language,
|
||||
is_active, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?)",
|
||||
[$in['site_id'], $in['template_id'], $in['name'], Kiosk::newToken(),
|
||||
$in['headline'], $in['subline'], $logo, $bg, $in['bg_overlay'],
|
||||
$in['accent_color'], $in['card_style'], $in['daily_limit'],
|
||||
$in['cooldown_seconds'], $in['display_seconds'], $_SESSION['user_id']]
|
||||
$in['cooldown_seconds'], $in['display_seconds'],
|
||||
$in['active_from'], $in['active_to'], $in['device_cooldown_seconds'],
|
||||
$in['pin'], $in['language'], $_SESSION['user_id']]
|
||||
);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_created', 'kiosk', null, $in['name']);
|
||||
$success = __('kiosks_added');
|
||||
|
|
@ -102,11 +119,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_kiosk'])) {
|
|||
$db->execute(
|
||||
"UPDATE kiosks SET site_id=?, template_id=?, name=?, headline=?, subline=?,
|
||||
logo_url=?, background_url=?, bg_overlay=?, accent_color=?, card_style=?,
|
||||
daily_limit=?, cooldown_seconds=?, display_seconds=?, is_active=?
|
||||
daily_limit=?, cooldown_seconds=?, display_seconds=?,
|
||||
active_from=?, active_to=?, device_cooldown_seconds=?, pin=?, language=?,
|
||||
is_active=?
|
||||
WHERE id=?",
|
||||
[$in['site_id'], $in['template_id'], $in['name'], $in['headline'], $in['subline'],
|
||||
$logo, $bg, $in['bg_overlay'], $in['accent_color'], $in['card_style'],
|
||||
$in['daily_limit'], $in['cooldown_seconds'], $in['display_seconds'], $in['is_active'], $id]
|
||||
$in['daily_limit'], $in['cooldown_seconds'], $in['display_seconds'],
|
||||
$in['active_from'], $in['active_to'], $in['device_cooldown_seconds'],
|
||||
$in['pin'], $in['language'], $in['is_active'], $id]
|
||||
);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_updated', 'kiosk', $id, $in['name']);
|
||||
$success = __('kiosks_updated');
|
||||
|
|
@ -227,6 +248,18 @@ $adminBase = '';
|
|||
<i class="fas fa-ticket" aria-hidden="true"></i>
|
||||
<?= (int)$k['total_vouchers'] ?> <?= __('kiosks_total') ?>
|
||||
</div>
|
||||
<?php if (!empty($k['active_from']) && !empty($k['active_to'])): ?>
|
||||
<div class="site-info-item">
|
||||
<i class="fas fa-clock" aria-hidden="true"></i>
|
||||
<?= htmlspecialchars(substr((string)$k['active_from'], 0, 5)) ?>–<?= htmlspecialchars(substr((string)$k['active_to'], 0, 5)) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($k['pin'])): ?>
|
||||
<div class="site-info-item">
|
||||
<i class="fas fa-lock" aria-hidden="true"></i>
|
||||
<?= __('kiosks_pin') ?>: <code><?= htmlspecialchars($k['pin']) ?></code>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<label class="muted" style="display:block;margin-bottom:6px;"><?= __('kiosks_link') ?></label>
|
||||
|
|
@ -248,6 +281,10 @@ $adminBase = '';
|
|||
onclick="showQr('<?= htmlspecialchars($url, ENT_QUOTES) ?>', '<?= htmlspecialchars($k['name'], ENT_QUOTES) ?>')">
|
||||
<i class="fas fa-qrcode" aria-hidden="true"></i> <?= __('kiosks_qr') ?>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" type="button"
|
||||
onclick="showPreview('<?= htmlspecialchars($url, ENT_QUOTES) ?>', '<?= htmlspecialchars($k['name'], ENT_QUOTES) ?>')">
|
||||
<i class="fas fa-eye" aria-hidden="true"></i> <?= __('kiosks_preview') ?>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" type="button"
|
||||
onclick='openEditModal(<?= json_encode([
|
||||
"id" => (int)$k["id"], "site_id" => (int)$k["site_id"],
|
||||
|
|
@ -256,6 +293,10 @@ $adminBase = '';
|
|||
"logo_url" => $k["logo_url"], "background_url" => $k["background_url"],
|
||||
"bg_overlay" => (int)$k["bg_overlay"], "accent_color" => $k["accent_color"],
|
||||
"card_style" => $k["card_style"],
|
||||
"active_from" => $k["active_from"] ? substr((string)$k["active_from"], 0, 5) : "",
|
||||
"active_to" => $k["active_to"] ? substr((string)$k["active_to"], 0, 5) : "",
|
||||
"device_cooldown_seconds" => (int)$k["device_cooldown_seconds"],
|
||||
"pin" => $k["pin"], "language" => $k["language"],
|
||||
"daily_limit" => (int)$k["daily_limit"],
|
||||
"cooldown_seconds" => (int)$k["cooldown_seconds"],
|
||||
"display_seconds" => (int)$k["display_seconds"],
|
||||
|
|
@ -384,6 +425,41 @@ $adminBase = '';
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="active_from"><?= __('kiosks_schedule') ?></label>
|
||||
<div style="display:flex;gap:8px;align-items:center;">
|
||||
<span class="muted"><?= __('kiosks_schedule_from') ?></span>
|
||||
<input type="time" id="active_from" name="active_from">
|
||||
<span class="muted"><?= __('kiosks_schedule_to') ?></span>
|
||||
<input type="time" id="active_to" name="active_to">
|
||||
</div>
|
||||
<div class="help-text"><?= __('kiosks_schedule_hint') ?></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="device_cooldown_seconds"><?= __('kiosks_device_cooldown') ?></label>
|
||||
<input type="number" id="device_cooldown_seconds" name="device_cooldown_seconds" min="0" max="86400" value="0">
|
||||
<div class="help-text"><?= __('kiosks_device_cooldown_hint') ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="pin"><?= __('kiosks_pin') ?></label>
|
||||
<input type="text" id="pin" name="pin" maxlength="12" autocomplete="off">
|
||||
<div class="help-text"><?= __('kiosks_pin_hint') ?></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="language"><?= __('kiosks_language') ?></label>
|
||||
<select id="language" name="language">
|
||||
<option value=""><?= __('kiosks_language_auto') ?></option>
|
||||
<?php foreach (I18n::getAvailable() as $code => $label): ?>
|
||||
<option value="<?= $code ?>"><?= htmlspecialchars($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkbox-group" id="activeRow" style="display:none;">
|
||||
<input type="checkbox" id="is_active" name="is_active" checked>
|
||||
<label for="is_active"><?= __('kiosks_active') ?></label>
|
||||
|
|
@ -402,6 +478,20 @@ $adminBase = '';
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vorschau der Display-Seite -->
|
||||
<div class="modal" id="previewModal">
|
||||
<div class="modal-content" style="max-width:900px;" role="dialog" aria-modal="true">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title" id="previewTitle"><?= __('kiosks_preview') ?></h2>
|
||||
<button class="modal-close" type="button" onclick="closePreview()" aria-label="<?= __('btn_cancel') ?>">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<iframe id="previewFrame" class="kiosk-preview-frame" title="<?= __('kiosks_preview') ?>" src="about:blank"></iframe>
|
||||
<p class="help-text" style="margin-top:12px;"><?= __('kiosks_preview_hint') ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- QR-Code des Links -->
|
||||
<div class="modal" id="qrModal">
|
||||
<div class="modal-content" style="max-width:420px;" role="dialog" aria-modal="true">
|
||||
|
|
@ -441,6 +531,11 @@ function openEditModal(data) {
|
|||
document.getElementById('template_id').value = data.template_id || 0;
|
||||
document.getElementById('headline').value = data.headline || '';
|
||||
document.getElementById('subline').value = data.subline || '';
|
||||
document.getElementById('active_from').value = data.active_from || '';
|
||||
document.getElementById('active_to').value = data.active_to || '';
|
||||
document.getElementById('device_cooldown_seconds').value = data.device_cooldown_seconds;
|
||||
document.getElementById('pin').value = data.pin || '';
|
||||
document.getElementById('language').value = data.language || '';
|
||||
document.getElementById('bg_overlay').value = data.bg_overlay;
|
||||
document.getElementById('accent_color').value = data.accent_color || '';
|
||||
document.getElementById('card_style').value = data.card_style || 'light';
|
||||
|
|
@ -487,6 +582,18 @@ function showQr(url, name) {
|
|||
|
||||
function closeQr() { document.getElementById('qrModal').classList.remove('active'); }
|
||||
|
||||
function showPreview(url, name) {
|
||||
document.getElementById('previewTitle').textContent = name;
|
||||
// cache-buster, damit Änderungen sofort sichtbar sind
|
||||
document.getElementById('previewFrame').src = url + '&preview=' + Date.now();
|
||||
document.getElementById('previewModal').classList.add('active');
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
document.getElementById('previewModal').classList.remove('active');
|
||||
document.getElementById('previewFrame').src = 'about:blank';
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') { closeModal(); closeQr(); }
|
||||
});
|
||||
|
|
|
|||
|
|
@ -88,6 +88,24 @@ $chartLabels = array_map(fn($r) => date('d.m', strtotime($r['d'])), $daily);
|
|||
$chartData = array_map(fn($r) => (int)$r['c'], $daily);
|
||||
|
||||
$csrf = $auth->getCsrfToken();
|
||||
// Auswertung der Display-Seiten: woher kommen die Codes?
|
||||
try {
|
||||
$perKiosk = $db->fetchAll(
|
||||
"SELECT k.name, s.name AS site_name,
|
||||
COUNT(v.id) AS total,
|
||||
SUM(CASE WHEN v.created_at >= DATE_SUB(NOW(), INTERVAL ? DAY) THEN 1 ELSE 0 END) AS in_period
|
||||
FROM kiosks k
|
||||
INNER JOIN sites s ON s.id = k.site_id
|
||||
LEFT JOIN vouchers v ON v.kiosk_id = k.id
|
||||
GROUP BY k.id, k.name, s.name
|
||||
HAVING total > 0
|
||||
ORDER BY in_period DESC, total DESC",
|
||||
[$days]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$perKiosk = []; // Tabelle fehlt auf alten Installationen
|
||||
}
|
||||
|
||||
$currentPage = 'reports';
|
||||
$adminBase = '';
|
||||
?>
|
||||
|
|
@ -142,6 +160,19 @@ $adminBase = '';
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2><?= __('rep_per_kiosk') ?></h2>
|
||||
<?php if (empty($perKiosk)): ?>
|
||||
<p class="muted"><?= __('rep_kiosk_none') ?></p>
|
||||
<?php else: ?>
|
||||
<table><tr><th><?= __('kiosks_name') ?></th><th><?= __('label_site') ?></th><th><?= str_replace('{days}', (string)$days, __('rep_in_period')) ?></th><th><?= __('label_total') ?></th></tr>
|
||||
<?php foreach ($perKiosk as $r): ?>
|
||||
<tr><td><?= htmlspecialchars($r['name']) ?></td><td><?= htmlspecialchars($r['site_name']) ?></td><td><?= (int)$r['in_period'] ?></td><td><?= (int)$r['total'] ?></td></tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2><?= __('rep_top_users') ?></h2>
|
||||
<table><tr><th><?= __('label_user') ?></th><th><?= __('rep_col_created') ?></th></tr>
|
||||
|
|
|
|||
|
|
@ -1768,6 +1768,34 @@ input.search-bar, .site-selector .search-bar { min-width: 240px; width: auto; fl
|
|||
.kiosk-qr-label { margin-top: 14px; font-size: 15px; color: var(--text-secondary); }
|
||||
.kiosk-countdown { margin: 18px 0 22px; font-size: 13.5px; color: var(--text-muted); }
|
||||
.kiosk-footer { padding: 0 24px 22px; text-align: center; }
|
||||
.kiosk-pin { margin-top: 26px; text-align: left; }
|
||||
.kiosk-pin label { font-size: 14px; }
|
||||
.kiosk-langs { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
|
||||
.kiosk-lang {
|
||||
padding: 5px 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--r-pill);
|
||||
background: var(--bg-card);
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px; font-weight: 650; letter-spacing: .03em;
|
||||
text-decoration: none;
|
||||
}
|
||||
.kiosk-lang.active { background: var(--accent); border-color: var(--accent); color: #fff; }
|
||||
.kiosk-body.has-background .kiosk-lang {
|
||||
background: rgba(255,255,255,.14);
|
||||
border-color: rgba(255,255,255,.22);
|
||||
color: rgba(255,255,255,.9);
|
||||
}
|
||||
.kiosk-body.has-background .kiosk-lang.active { background: var(--accent); border-color: var(--accent); }
|
||||
|
||||
/* Vorschau der Display-Seite in der Verwaltung */
|
||||
.kiosk-preview-frame {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
/* Link-Zeile in der Kiosk-Verwaltung */
|
||||
.kiosk-link-row { display: flex; gap: 8px; align-items: center; }
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ CREATE TABLE IF NOT EXISTS `kiosks` (
|
|||
`daily_limit` INT NOT NULL DEFAULT 100,
|
||||
`cooldown_seconds` INT NOT NULL DEFAULT 20,
|
||||
`display_seconds` INT NOT NULL DEFAULT 90,
|
||||
`active_from` TIME NULL,
|
||||
`active_to` TIME NULL,
|
||||
`device_cooldown_seconds` INT NOT NULL DEFAULT 0,
|
||||
`pin` VARCHAR(12) NULL,
|
||||
`language` VARCHAR(5) NULL,
|
||||
`last_used_at` TIMESTAMP NULL,
|
||||
`created_by` INT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 397 KiB After Width: | Height: | Size: 397 KiB |
|
Before Width: | Height: | Size: 390 KiB After Width: | Height: | Size: 390 KiB |
|
Before Width: | Height: | Size: 321 KiB After Width: | Height: | Size: 321 KiB |
|
Before Width: | Height: | Size: 319 KiB After Width: | Height: | Size: 319 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 242 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 290 KiB |
|
Before Width: | Height: | Size: 446 KiB After Width: | Height: | Size: 447 KiB |
|
Before Width: | Height: | Size: 191 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 423 KiB After Width: | Height: | Size: 420 KiB |
|
|
@ -16,7 +16,9 @@ class I18n {
|
|||
$_SESSION['language'] = $_GET['set_lang'];
|
||||
}
|
||||
|
||||
self::$language = $_SESSION['language'] ?? 'de';
|
||||
// Ohne Auswahl die Sprache des Browsers verwenden – am Display stehen
|
||||
// oft Gäste, die kein Deutsch lesen.
|
||||
self::$language = $_SESSION['language'] ?? self::browserLanguage();
|
||||
|
||||
$langFile = __DIR__ . '/../lang/' . self::$language . '.php';
|
||||
if (file_exists($langFile)) {
|
||||
|
|
@ -31,6 +33,20 @@ class I18n {
|
|||
self::$initialized = true;
|
||||
}
|
||||
|
||||
/** Erste unterstützte Sprache aus dem Accept-Language-Header. */
|
||||
private static function browserLanguage(): string
|
||||
{
|
||||
$header = strtolower((string)($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? ''));
|
||||
foreach (explode(',', $header) as $part) {
|
||||
$code = substr(trim(explode(';', $part)[0]), 0, 2);
|
||||
if (in_array($code, ['de', 'en'], true)) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
return 'de';
|
||||
}
|
||||
|
||||
public static function t(string $key, array $replace = []): string {
|
||||
// Fehlt eine Übersetzung, lieber den deutschen Text zeigen als den
|
||||
// technischen Schlüssel – erst wenn auch der fehlt, den Schlüssel.
|
||||
|
|
|
|||
|
|
@ -67,14 +67,87 @@ class Kiosk
|
|||
return (int)($row['c'] ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liegt der aktuelle Zeitpunkt im Betriebsfenster der Display-Seite?
|
||||
* Ohne gesetzte Zeiten gilt: immer offen. Ein Fenster über Mitternacht
|
||||
* (z. B. 18:00–02:00) wird unterstützt.
|
||||
*/
|
||||
public static function withinSchedule(array $kiosk, ?int $now = null): bool
|
||||
{
|
||||
$from = trim((string)($kiosk['active_from'] ?? ''));
|
||||
$to = trim((string)($kiosk['active_to'] ?? ''));
|
||||
if ($from === '' || $to === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$now = $now ?? time();
|
||||
$minutes = (int)date('G', $now) * 60 + (int)date('i', $now);
|
||||
$start = self::toMinutes($from);
|
||||
$end = self::toMinutes($to);
|
||||
|
||||
if ($start === $end) {
|
||||
return true; // 24 Stunden
|
||||
}
|
||||
if ($start < $end) {
|
||||
return $minutes >= $start && $minutes < $end;
|
||||
}
|
||||
|
||||
return $minutes >= $start || $minutes < $end; // über Mitternacht
|
||||
}
|
||||
|
||||
private static function toMinutes(string $time): int
|
||||
{
|
||||
$parts = explode(':', $time);
|
||||
|
||||
return ((int)($parts[0] ?? 0)) * 60 + ((int)($parts[1] ?? 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wartezeit dieses Geräts: das Display merkt sich den letzten Bezug in
|
||||
* einem Cookie. Verhindert, dass eine Person am Handy im Takt der
|
||||
* globalen Wartezeit das Tageskontingent leerzieht.
|
||||
*
|
||||
* @param int|null $lastSeen Zeitstempel aus dem Cookie
|
||||
* @return int verbleibende Sekunden (0 = frei)
|
||||
*/
|
||||
public static function deviceCooldownLeft(array $kiosk, ?int $lastSeen, ?int $now = null): int
|
||||
{
|
||||
$cooldown = max(0, (int)($kiosk['device_cooldown_seconds'] ?? 0));
|
||||
if ($cooldown === 0 || !$lastSeen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$elapsed = ($now ?? time()) - $lastSeen;
|
||||
if ($elapsed < 0 || $elapsed >= $cooldown) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $cooldown - $elapsed;
|
||||
}
|
||||
|
||||
/** Stimmt die eingegebene PIN? Ohne hinterlegte PIN entfällt die Prüfung. */
|
||||
public static function pinMatches(array $kiosk, ?string $input): bool
|
||||
{
|
||||
$pin = trim((string)($kiosk['pin'] ?? ''));
|
||||
if ($pin === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return hash_equals($pin, trim((string)$input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Darf gerade ein Code geholt werden?
|
||||
*
|
||||
* @return array{allowed:bool,reason:string,wait:int}
|
||||
* reason: '' | 'cooldown' | 'daily_limit'
|
||||
* reason: '' | 'closed' | 'cooldown' | 'daily_limit'
|
||||
*/
|
||||
public static function checkLimits($db, array $kiosk): array
|
||||
{
|
||||
if (!self::withinSchedule($kiosk)) {
|
||||
return ['allowed' => false, 'reason' => 'closed', 'wait' => 0];
|
||||
}
|
||||
|
||||
$cooldown = max(0, (int)$kiosk['cooldown_seconds']);
|
||||
if ($cooldown > 0 && !empty($kiosk['last_used_at'])) {
|
||||
$elapsed = time() - strtotime((string)$kiosk['last_used_at']);
|
||||
|
|
|
|||
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>
|
||||
|
|
|
|||
18
lang/de.php
|
|
@ -547,6 +547,24 @@ return [
|
|||
'users_2fa_reset_title' => '2FA zurücksetzen',
|
||||
'int_proxy_warning' => 'Diese Anfrage kam über einen Proxy, es ist aber kein vertrauenswürdiger Proxy eingetragen. Rate-Limits und Audit-Log sehen dadurch für alle Gäste dieselbe IP-Adresse ({ip}).',
|
||||
'int_proxy_suggestion' => 'Vorschlag anhand dieser Anfrage:',
|
||||
'kiosk_error_closed' => 'Außerhalb der Servicezeiten. Bitte wenden Sie sich an den Empfang.',
|
||||
'kiosk_error_device' => 'Sie haben gerade einen Code erhalten. Bitte {seconds} Sekunden warten.',
|
||||
'kiosk_error_pin' => 'PIN stimmt nicht.',
|
||||
'kiosk_pin_label' => 'PIN vom Empfang',
|
||||
'kiosks_schedule' => 'Servicezeiten',
|
||||
'kiosks_schedule_from' => 'von',
|
||||
'kiosks_schedule_to' => 'bis',
|
||||
'kiosks_schedule_hint' => 'Leer = rund um die Uhr. Ein Fenster über Mitternacht ist möglich.',
|
||||
'kiosks_device_cooldown' => 'Wartezeit je Gerät (Sekunden)',
|
||||
'kiosks_device_cooldown_hint' => '0 = aus. Verhindert, dass eine Person nacheinander viele Codes zieht.',
|
||||
'kiosks_pin' => 'PIN (optional)',
|
||||
'kiosks_pin_hint' => 'Gäste müssen die PIN eingeben – sinnvoll, wenn der Bildschirm frei zugänglich ist.',
|
||||
'kiosks_language' => 'Sprache des Displays',
|
||||
'kiosks_language_auto' => 'Automatisch (Browsersprache)',
|
||||
'kiosks_preview' => 'Vorschau',
|
||||
'kiosks_preview_hint' => 'So sieht die Seite auf dem Bildschirm aus.',
|
||||
'rep_per_kiosk' => 'Pro Display-Seite',
|
||||
'rep_kiosk_none' => 'Noch keine Codes über Display-Seiten ausgegeben.',
|
||||
'settings_tab_general' => 'Allgemein',
|
||||
'settings_tab_defaults' => 'Voucher-Standards',
|
||||
'settings_tab_cron' => 'Cron-Sync',
|
||||
|
|
|
|||
18
lang/en.php
|
|
@ -547,6 +547,24 @@ return [
|
|||
'users_2fa_reset_title' => 'Reset two-factor authentication',
|
||||
'int_proxy_warning' => 'This request arrived through a proxy, but no trusted proxy is configured. Rate limits and the audit log therefore see the same IP address for every guest ({ip}).',
|
||||
'int_proxy_suggestion' => 'Suggestion based on this request:',
|
||||
'kiosk_error_closed' => 'Outside service hours. Please ask at the reception desk.',
|
||||
'kiosk_error_device' => 'You just received a code. Please wait {seconds} seconds.',
|
||||
'kiosk_error_pin' => 'The PIN is not correct.',
|
||||
'kiosk_pin_label' => 'PIN from the reception desk',
|
||||
'kiosks_schedule' => 'Service hours',
|
||||
'kiosks_schedule_from' => 'from',
|
||||
'kiosks_schedule_to' => 'to',
|
||||
'kiosks_schedule_hint' => 'Empty = around the clock. A window across midnight works.',
|
||||
'kiosks_device_cooldown' => 'Cooldown per device (seconds)',
|
||||
'kiosks_device_cooldown_hint' => '0 = off. Stops one person from pulling many codes in a row.',
|
||||
'kiosks_pin' => 'PIN (optional)',
|
||||
'kiosks_pin_hint' => 'Guests have to enter the PIN – useful if the screen is freely accessible.',
|
||||
'kiosks_language' => 'Display language',
|
||||
'kiosks_language_auto' => 'Automatic (browser language)',
|
||||
'kiosks_preview' => 'Preview',
|
||||
'kiosks_preview_hint' => 'This is how the page looks on screen.',
|
||||
'rep_per_kiosk' => 'Per display page',
|
||||
'rep_kiosk_none' => 'No codes issued via display pages yet.',
|
||||
'settings_tab_general' => 'General',
|
||||
'settings_tab_defaults' => 'Voucher Defaults',
|
||||
'settings_tab_cron' => 'Cron Sync',
|
||||
|
|
|
|||
|
|
@ -193,6 +193,73 @@ class KioskTest extends TestCase
|
|||
$this->assertSame(0.0, \Kiosk::appearance($db, $this->kiosk(['bg_overlay' => -10]))['overlay']);
|
||||
}
|
||||
|
||||
// --- Betriebszeiten ---------------------------------------------------
|
||||
|
||||
public function testScheduleOpenWithoutTimes(): void
|
||||
{
|
||||
$this->assertTrue(\Kiosk::withinSchedule($this->kiosk()));
|
||||
}
|
||||
|
||||
public function testScheduleDuringTheDay(): void
|
||||
{
|
||||
$kiosk = $this->kiosk(['active_from' => '06:00', 'active_to' => '23:00']);
|
||||
|
||||
$this->assertTrue(\Kiosk::withinSchedule($kiosk, mktime(9, 30)));
|
||||
$this->assertFalse(\Kiosk::withinSchedule($kiosk, mktime(3, 0)));
|
||||
$this->assertFalse(\Kiosk::withinSchedule($kiosk, mktime(23, 30)));
|
||||
}
|
||||
|
||||
public function testScheduleAcrossMidnight(): void
|
||||
{
|
||||
$kiosk = $this->kiosk(['active_from' => '18:00', 'active_to' => '02:00']);
|
||||
|
||||
$this->assertTrue(\Kiosk::withinSchedule($kiosk, mktime(20, 0)));
|
||||
$this->assertTrue(\Kiosk::withinSchedule($kiosk, mktime(1, 0)));
|
||||
$this->assertFalse(\Kiosk::withinSchedule($kiosk, mktime(12, 0)));
|
||||
}
|
||||
|
||||
public function testClosedKioskReportsReason(): void
|
||||
{
|
||||
$db = new FakeKioskDb();
|
||||
$kiosk = $this->kiosk(['active_from' => '00:00', 'active_to' => '00:01']);
|
||||
|
||||
$result = \Kiosk::checkLimits($db, $kiosk);
|
||||
|
||||
// Nur ausserhalb des Fensters – die Minute nach Mitternacht trifft es
|
||||
// sonst zufaellig; deshalb hier nur die Struktur pruefen.
|
||||
$this->assertContains($result['reason'], ['', 'closed']);
|
||||
}
|
||||
|
||||
// --- Wartezeit je Gerät ----------------------------------------------
|
||||
|
||||
public function testDeviceCooldownCountsDown(): void
|
||||
{
|
||||
$kiosk = $this->kiosk(['device_cooldown_seconds' => 300]);
|
||||
$now = time();
|
||||
|
||||
$this->assertSame(0, \Kiosk::deviceCooldownLeft($kiosk, null, $now), 'Ohne Cookie keine Sperre');
|
||||
$this->assertSame(240, \Kiosk::deviceCooldownLeft($kiosk, $now - 60, $now));
|
||||
$this->assertSame(0, \Kiosk::deviceCooldownLeft($kiosk, $now - 600, $now), 'Abgelaufen');
|
||||
}
|
||||
|
||||
public function testDeviceCooldownDisabled(): void
|
||||
{
|
||||
$kiosk = $this->kiosk(['device_cooldown_seconds' => 0]);
|
||||
|
||||
$this->assertSame(0, \Kiosk::deviceCooldownLeft($kiosk, time()));
|
||||
}
|
||||
|
||||
// --- PIN --------------------------------------------------------------
|
||||
|
||||
public function testPinOnlyCheckedWhenSet(): void
|
||||
{
|
||||
$this->assertTrue(\Kiosk::pinMatches($this->kiosk(), ''), 'Ohne PIN darf nichts blockieren');
|
||||
$this->assertTrue(\Kiosk::pinMatches($this->kiosk(['pin' => '4711']), '4711'));
|
||||
$this->assertTrue(\Kiosk::pinMatches($this->kiosk(['pin' => '4711']), ' 4711 '));
|
||||
$this->assertFalse(\Kiosk::pinMatches($this->kiosk(['pin' => '4711']), '1234'));
|
||||
$this->assertFalse(\Kiosk::pinMatches($this->kiosk(['pin' => '4711']), ''));
|
||||
}
|
||||
|
||||
public function testPublicUrl(): void
|
||||
{
|
||||
$token = \Kiosk::newToken();
|
||||
|
|
|
|||
|
|
@ -58,13 +58,20 @@ class Database {
|
|||
public function fetchAll($sql, $params = []) {
|
||||
$s = preg_replace('/\s+/', ' ', strtolower($sql));
|
||||
|
||||
if (str_contains($s, 'from kiosks')) {
|
||||
if (str_contains($s, 'left join vouchers v on v.kiosk_id')) {
|
||||
return [
|
||||
['name'=>'Empfang Erdgeschoss','site_name'=>'Hauptstandort Nord','total'=>412,'in_period'=>96],
|
||||
['name'=>'Tagungsraum West','site_name'=>'Campus West','total'=>87,'in_period'=>14],
|
||||
];
|
||||
}
|
||||
if (str_contains($s, 'from kiosks')) {
|
||||
$rows = [
|
||||
['id'=>1,'site_id'=>1,'template_id'=>1,'name'=>'Empfang Erdgeschoss','token'=>'a1b2c3d4e5f60718293a4b5c6d7e8f90',
|
||||
'headline'=>'Willkommen im Hotel Seeblick','subline'=>'Tippen Sie auf den Knopf – Ihr WLAN-Code erscheint sofort.',
|
||||
'logo_url'=>'/demo-assets/logo.svg','background_url'=>'/demo-assets/background.svg',
|
||||
'bg_overlay'=>55,'accent_color'=>'#0f766e','card_style'=>'dark',
|
||||
'is_active'=>1,'daily_limit'=>150,'cooldown_seconds'=>15,'display_seconds'=>90,'last_used_at'=>null,
|
||||
'active_from'=>'06:00','active_to'=>'23:00','device_cooldown_seconds'=>300,'pin'=>null,'language'=>null,
|
||||
'site_name'=>'Hauptstandort Nord','site_active'=>1,'template_name'=>'Tagesgast',
|
||||
'tpl_max_uses'=>2,'tpl_expire_minutes'=>480,'qos_rate_max_down'=>20000,'qos_rate_max_up'=>5000,'qos_usage_quota'=>0,
|
||||
'total_vouchers'=>412,'today_vouchers'=>23,'created_at'=>'2026-06-01 10:00:00'],
|
||||
|
|
@ -72,10 +79,19 @@ class Database {
|
|||
'headline'=>'','subline'=>'','logo_url'=>null,'background_url'=>null,'bg_overlay'=>45,
|
||||
'accent_color'=>null,'card_style'=>'light',
|
||||
'is_active'=>1,'daily_limit'=>0,'cooldown_seconds'=>30,'display_seconds'=>60,
|
||||
'active_from'=>null,'active_to'=>null,'device_cooldown_seconds'=>0,'pin'=>'4711','language'=>'en',
|
||||
'last_used_at'=>null,'site_name'=>'Campus West','site_active'=>1,'template_name'=>null,
|
||||
'tpl_max_uses'=>0,'tpl_expire_minutes'=>0,'qos_rate_max_down'=>0,'qos_rate_max_up'=>0,'qos_usage_quota'=>0,
|
||||
'total_vouchers'=>87,'today_vouchers'=>4,'created_at'=>'2026-07-12 09:30:00'],
|
||||
];
|
||||
|
||||
// Token-Abfrage: nur den passenden Kiosk liefern, sonst zeigt die
|
||||
// Demo immer die erste Seite.
|
||||
if (str_contains($s, 'k.token = ?') && isset($params[0])) {
|
||||
$rows = array_values(array_filter($rows, fn ($r) => $r['token'] === $params[0]));
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
if (str_contains($s, 'count(*) as count from sites')) return [['count'=>4]];
|
||||
|
|
|
|||
8
updater/migrations/0007_kiosk_controls.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- Display-Seiten: Betriebszeiten, PIN und eine Wartezeit je Gerät.
|
||||
-- Der Link ist öffentlich; diese Werte begrenzen, was damit möglich ist.
|
||||
|
||||
ALTER TABLE `kiosks` ADD COLUMN `active_from` TIME NULL AFTER `display_seconds`;
|
||||
ALTER TABLE `kiosks` ADD COLUMN `active_to` TIME NULL AFTER `active_from`;
|
||||
ALTER TABLE `kiosks` ADD COLUMN `device_cooldown_seconds` INT NOT NULL DEFAULT 0 AFTER `active_to`;
|
||||
ALTER TABLE `kiosks` ADD COLUMN `pin` VARCHAR(12) NULL AFTER `device_cooldown_seconds`;
|
||||
ALTER TABLE `kiosks` ADD COLUMN `language` VARCHAR(5) NULL AFTER `pin`;
|
||||