Upload via GUI (452 Dateien)

This commit is contained in:
2026-11-05 21:21:52 +00:00
parent 10578475f0
commit 32f5e780d6
23 changed files with 1397 additions and 601 deletions
+20 -2
View File
@@ -1,13 +1,20 @@
<?php
require_once __DIR__ . '/../includes/bootstrap.php';
$admin = require_admin();
require_once __DIR__ . '/../includes/webauthn.php';
$admin = require_admin_or_permission('view_login_guard');
$pdo = get_db();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
$action = (string) ($_POST['action'] ?? '');
if (in_array($action, ['save', 'purge'], true) && $admin['role'] !== 'admin') {
// Einstellungen und Protokoll leeren bleiben echten Administratoren vorbehalten (Passkeys, Sperrzeiten)
flash('error', 'Einstellungen ändern und das Protokoll leeren dürfen nur Administratoren.');
redirect('/staff/login_log.php');
}
if ($action === 'save') {
set_setting('login_guard', !empty($_POST['login_guard']) ? '1' : '0');
set_setting('passkeys_enabled', !empty($_POST['passkeys_enabled']) ? '1' : '0');
set_setting('login_guard_warn_place', !empty($_POST['login_guard_warn_place']) ? '1' : '0');
set_setting('login_guard_notify_admins', !empty($_POST['login_guard_notify_admins']) ? '1' : '0');
set_setting('login_guard_max_attempts', (string) max(3, min(20, (int) ($_POST['login_guard_max_attempts'] ?? 5))));
@@ -19,6 +26,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$n = $pdo->exec('DELETE FROM login_events');
audit_log($admin['id'], 'Anmelde-Wächter: Protokoll geleert (' . (int) $n . ' Einträge)');
flash('success', 'Protokoll geleert.');
} elseif ($action === 'unlock') {
$sid = (int) ($_POST['staff_id'] ?? 0);
if ($sid > 0) {
login_guard_unlock($pdo, $sid, (int) $admin['id']);
flash('success', 'Die Anmeldesperre ist aufgehoben.');
}
} elseif ($action === 'forget_devices') {
$sid = (int) ($_POST['staff_id'] ?? 0);
if ($sid > 0) {
@@ -51,7 +64,7 @@ foreach ($cnt->fetchAll() as $r) $counts[$r['event']] = (int) $r['n'];
$pageTitle = 'Anmelde-Wächter';
$activePage = 'login_log';
$colors = ['success' => '#15803d', 'new_device' => '#b45309', 'new_place' => '#b45309', 'failed' => '#b91c1c', 'locked' => '#b91c1c', 'revoked' => '#7c3aed'];
$colors = ['success' => '#15803d', 'new_device' => '#b45309', 'new_place' => '#b45309', 'failed' => '#b91c1c', 'locked' => '#b91c1c', 'revoked' => '#7c3aed', 'signout' => '#7c3aed', 'unlocked' => '#15803d'];
require __DIR__ . '/_header.php';
?>
<h1>Anmelde-Wächter</h1>
@@ -67,6 +80,8 @@ require __DIR__ . '/_header.php';
<h3 style="margin-top:0">Einstellungen</h3>
<label style="display:flex;gap:8px;align-items:flex-start;font-weight:400"><input type="checkbox" name="login_guard" value="1" style="width:auto;margin-top:3px" <?= login_guard_enabled() ? 'checked' : '' ?>>
<span><strong>Anmelde-Wächter einschalten</strong> (Geräte merken, bei Neuem warnen, Protokoll führen)</span></label>
<label style="display:flex;gap:8px;align-items:flex-start;font-weight:400;margin-top:8px"><input type="checkbox" name="passkeys_enabled" value="1" style="width:auto;margin-top:3px" <?= webauthn_enabled() ? 'checked' : '' ?>>
<span><strong>Passkeys erlauben</strong> (Anmeldung ohne Passwort per Fingerabdruck, Gesicht oder PIN). Ausgeschaltet verschwindet „Mit Passkey anmelden“ und vorhandene Passkeys gelten nicht mehr; sie bleiben gespeichert und gelten wieder, sobald ihr es einschaltet. Den Passkey eines einzelnen Mitarbeiters entfernt ihr unter <a href="/staff/staff_manage.php">Mitarbeiter</a>.</span></label>
<label style="display:flex;gap:8px;align-items:flex-start;font-weight:400;margin-top:8px"><input type="checkbox" name="login_guard_warn_place" value="1" style="width:auto;margin-top:3px" <?= get_setting('login_guard_warn_place', '1') === '1' ? 'checked' : '' ?>>
<span>Auch bei einem <strong>neuen Ort</strong> warnen (vom bekannten Gerät, z. B. unterwegs mit dem Handy). Ausgeschaltet warnt nur ein neues Gerät.</span></label>
<label style="display:flex;gap:8px;align-items:flex-start;font-weight:400;margin-top:8px"><input type="checkbox" name="login_guard_notify_admins" value="1" style="width:auto;margin-top:3px" <?= get_setting('login_guard_notify_admins', '1') === '1' ? 'checked' : '' ?>>
@@ -104,6 +119,9 @@ require __DIR__ . '/_header.php';
<td style="font-size:.85rem"><?= e($r['place']) ?><div class="muted" style="font-size:.76rem"><?= e($r['ip']) ?></div></td>
<td style="font-size:.82rem"><?= e($r['detail']) ?></td>
<td>
<?php if ($r['staff_id'] && $r['event'] === 'locked' && login_guard_is_locked($pdo, (string) $r['email'])): ?>
<form method="post"><?= csrf_field() ?><input type="hidden" name="action" value="unlock"><input type="hidden" name="staff_id" value="<?= (int) $r['staff_id'] ?>"><button class="btn secondary" type="submit" style="padding:2px 9px;font-size:.76rem">Sperre aufheben</button></form>
<?php endif; ?>
<?php if ($r['staff_id'] && in_array($r['event'], ['new_device', 'new_place', 'revoked'], true)): ?>
<form method="post" onsubmit="return confirm('Alle gemerkten Geräte und Orte dieses Mitarbeiters vergessen?')"><?= csrf_field() ?><input type="hidden" name="action" value="forget_devices"><input type="hidden" name="staff_id" value="<?= (int) $r['staff_id'] ?>"><button class="btn secondary" type="submit" style="padding:3px 8px;font-size:.74rem">Geräte vergessen</button></form>
<?php endif; ?>