Härtung: Backup vollständig, Caddy-Konfiguration, POST statt GET
All checks were successful
CI / PHP Lint (pull_request) Successful in 35s
CI / PHP Lint-1 (pull_request) Successful in 34s
CI / Unit Tests & Static Analysis (pull_request) Successful in 38s
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 32s
CI / Unit Tests & Static Analysis (push) Successful in 36s
All checks were successful
CI / PHP Lint (pull_request) Successful in 35s
CI / PHP Lint-1 (pull_request) Successful in 34s
CI / Unit Tests & Static Analysis (pull_request) Successful in 38s
CI / PHP Lint (push) Successful in 34s
CI / PHP Lint-1 (push) Successful in 32s
CI / Unit Tests & Static Analysis (push) Successful in 36s
Backup (das war eine echte Lücke): admin/backup.php sicherte nur Einstellungen, Sites und Profile – die Display-Seiten fehlten. Nach einem Restore wären alle Kiosk-Links weg gewesen und aufgehängte QR-Codes hätten ins Leere gezeigt. Sie werden jetzt mitgesichert, inklusive Token, damit vorhandene Aufkleber weiter funktionieren; Site und Profil werden über den Namen verknüpft, weil die IDs auf der Zielinstallation andere sind. Caddy: die mitgelieferte .htaccess wird von Caddy nicht gelesen – damit griffen weder die Sicherheits-Header noch die Sperre, die PHP unterhalb von uploads/ verbietet. docs/Caddyfile.example enthält beides, die README verweist darauf. Verändernde Aktionen laufen jetzt über POST statt über Links mit CSRF-Token in der URL (Sites, Benutzer, Profile, API-Schlüssel, Display- Seiten). Token in URLs landen in Server-Logs, Referer-Headern und der Browser-Chronik. Neuer Helfer Ui::actionForm() hält das Markup kurz. Entfernt: login_simple.php und m365_debug.php. login_simple.php war eine zweite Login-Implementierung, die den Rückgabewert von Auth::login() als Boolean behandelte – 'totp_required' und 'rate_limited' sind truthy, also wurde auf index.php weitergeleitet, ohne dass eine Sitzung bestand. Kein Bypass (setUserSession lief nicht), aber genau die Art Altlast, aus der später einer wird. Database::getInstance() bricht nicht mehr mit die() samt PDO-Meldung ab (die Host und Datenbanknamen enthält), sondern zeigt im Web eine schlichte 503-Seite und wirft auf der Kommandozeile weiter. Neu: Warnung im Tab "Integration & Wartung", wenn eine Anfrage über einen Proxy kam, aber kein vertrauenswürdiger Proxy eingetragen ist – dann sehen Rate-Limit und Audit-Log für alle Gäste dieselbe IP. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3a09e35097
commit
f26684b128
27 changed files with 381 additions and 423 deletions
|
|
@ -7,6 +7,7 @@ require_once __DIR__ . '/../config.php';
|
|||
require_once __DIR__ . '/../includes/Database.php';
|
||||
require_once __DIR__ . '/../includes/Auth.php';
|
||||
require_once __DIR__ . '/../includes/I18n.php';
|
||||
require_once __DIR__ . '/../includes/Kiosk.php';
|
||||
|
||||
$auth = new Auth();
|
||||
$auth->requireAdmin();
|
||||
|
|
@ -23,13 +24,25 @@ if (isset($_GET['export']) && isset($_GET['token']) && $auth->validateCsrfToken(
|
|||
$export = [
|
||||
'meta' => [
|
||||
'app' => 'unifi-voucher-tool',
|
||||
'version' => '2.2.0',
|
||||
'version' => trim((string)@file_get_contents(dirname(__DIR__) . '/VERSION')),
|
||||
'exported_at'=> date('c'),
|
||||
'note' => 'Site-Passwörter sind mit dem APP_KEY dieser Installation verschlüsselt.',
|
||||
],
|
||||
'settings' => $db->fetchAll("SELECT setting_key, setting_value FROM settings"),
|
||||
'sites' => $db->fetchAll("SELECT name, site_id, unifi_controller_url, unifi_username, unifi_password, is_active, public_access FROM sites"),
|
||||
'voucher_templates' => $db->fetchAll("SELECT name, max_uses, expire_minutes, description, qos_rate_max_down, qos_rate_max_up, qos_usage_quota, is_active FROM voucher_templates"),
|
||||
// Display-Seiten samt Token: sonst zeigen aufgehängte QR-Codes nach
|
||||
// einem Restore ins Leere. Site und Profil werden über den Namen
|
||||
// verknüpft, weil die IDs auf der Zielinstallation andere sind.
|
||||
'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,
|
||||
s.name AS site_name, t.name AS template_name
|
||||
FROM kiosks k
|
||||
INNER JOIN sites s ON s.id = k.site_id
|
||||
LEFT JOIN voucher_templates t ON t.id = k.template_id"
|
||||
),
|
||||
];
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'config_export', 'config', null, 'Konfiguration exportiert');
|
||||
header('Content-Type: application/json');
|
||||
|
|
@ -53,7 +66,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import'])) {
|
|||
$importSites = isset($_POST['import_sites']);
|
||||
$importTemplates = isset($_POST['import_templates']);
|
||||
$importSettings = isset($_POST['import_settings']);
|
||||
$counts = ['settings' => 0, 'sites' => 0, 'templates' => 0];
|
||||
$importKiosks = isset($_POST['import_kiosks']);
|
||||
$counts = ['settings' => 0, 'sites' => 0, 'templates' => 0, 'kiosks' => 0];
|
||||
|
||||
try {
|
||||
if ($importSettings && !empty($data['settings'])) {
|
||||
|
|
@ -94,9 +108,49 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import'])) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($importKiosks && !empty($data['kiosks'])) {
|
||||
foreach ($data['kiosks'] as $k) {
|
||||
$site = $db->fetchOne("SELECT id FROM sites WHERE name = ?", [$k['site_name'] ?? '']);
|
||||
if (!$site) {
|
||||
continue; // ohne passende Site ergibt die Display-Seite keinen Sinn
|
||||
}
|
||||
$templateId = null;
|
||||
if (!empty($k['template_name'])) {
|
||||
$tpl = $db->fetchOne("SELECT id FROM voucher_templates WHERE name = ?", [$k['template_name']]);
|
||||
$templateId = $tpl['id'] ?? null;
|
||||
}
|
||||
|
||||
$exists = $db->fetchOne("SELECT id FROM kiosks WHERE token = ?", [$k['token'] ?? '']);
|
||||
$values = [
|
||||
(int)$site['id'], $templateId, $k['name'], $k['headline'] ?? null, $k['subline'] ?? null,
|
||||
$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),
|
||||
];
|
||||
|
||||
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=?",
|
||||
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,
|
||||
is_active, token, created_by)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
array_merge($values, [$k['token'] ?? Kiosk::newToken(), $_SESSION['user_id'] ?? null])
|
||||
);
|
||||
}
|
||||
$counts['kiosks']++;
|
||||
}
|
||||
}
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'config_import', 'config', null, 'Konfiguration importiert');
|
||||
$success = str_replace(['{settings}', '{sites}', '{templates}'],
|
||||
[(string)$counts['settings'], (string)$counts['sites'], (string)$counts['templates']],
|
||||
$success = str_replace(['{settings}', '{sites}', '{templates}', '{kiosks}'],
|
||||
[(string)$counts['settings'], (string)$counts['sites'], (string)$counts['templates'], (string)$counts['kiosks']],
|
||||
__('backup_imported'));
|
||||
} catch (Exception $e) {
|
||||
$error = 'Import-Fehler: ' . $e->getMessage();
|
||||
|
|
@ -141,6 +195,7 @@ $adminBase = '';
|
|||
<label class="chk"><input type="checkbox" name="import_settings" checked> <?= __('backup_opt_settings') ?></label>
|
||||
<label class="chk"><input type="checkbox" name="import_sites" checked> <?= __('backup_opt_sites') ?></label>
|
||||
<label class="chk"><input type="checkbox" name="import_templates" checked> <?= __('backup_opt_templates') ?></label>
|
||||
<label class="chk"><input type="checkbox" name="import_kiosks" checked> <?= __('backup_opt_kiosks') ?></label>
|
||||
<button class="btn btn-primary" type="submit" name="import" style="margin-top:12px;" onclick="return confirm('<?= __('backup_import_confirm') ?>');"><?= __('import_submit') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue