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
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>
|
|
@ -423,6 +423,11 @@ bleiben lediglich für hCaptcha offen, falls es aktiviert wird. Ordner wie
|
|||
> werden die `.htaccess`-Dateien ignoriert. Das mitgelieferte Docker-Image
|
||||
> erledigt das bereits.
|
||||
|
||||
> **Caddy liest keine `.htaccess`.** Läuft das Tool hinter Caddy, müssen die
|
||||
> Regeln in den Caddyfile – eine fertige Vorlage liegt unter
|
||||
> [`docs/Caddyfile.example`](docs/Caddyfile.example). Besonders wichtig ist
|
||||
> dort die Sperre, die PHP-Dateien unterhalb von `uploads/` nicht ausführt.
|
||||
|
||||
Für **Nginx** entspricht das:
|
||||
|
||||
```nginx
|
||||
|
|
@ -476,7 +481,6 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON unifi_voucher.* TO 'unifi_voucher'@'loca
|
|||
|
||||
- Redirect URI in Azure AD prüfen
|
||||
- Client ID, Secret und Tenant ID kontrollieren
|
||||
- Diagnose unter `m365_debug.php` (nur als Admin erreichbar)
|
||||
</details>
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -42,17 +42,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_key'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['toggle']) && isset($_GET['token']) && $auth->validateCsrfToken($_GET['token'])) {
|
||||
$row = $db->fetchOne("SELECT is_active FROM api_keys WHERE id = ?", [(int)$_GET['toggle']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['toggle_key']) && $auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$row = $db->fetchOne("SELECT is_active FROM api_keys WHERE id = ?", [(int)($_POST['key_id'] ?? 0)]);
|
||||
if ($row) {
|
||||
$db->query("UPDATE api_keys SET is_active = ? WHERE id = ?", [$row['is_active'] ? 0 : 1, (int)$_GET['toggle']]);
|
||||
$db->query("UPDATE api_keys SET is_active = ? WHERE id = ?", [$row['is_active'] ? 0 : 1, (int)($_POST['key_id'] ?? 0)]);
|
||||
$success = __('api_status_updated');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['delete']) && isset($_GET['token']) && $auth->validateCsrfToken($_GET['token'])) {
|
||||
$db->query("DELETE FROM api_keys WHERE id = ?", [(int)$_GET['delete']]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'api_key_delete', 'api_key', (int)$_GET['delete'], 'API-Key gelöscht');
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_key']) && $auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$db->query("DELETE FROM api_keys WHERE id = ?", [(int)($_POST['key_id'] ?? 0)]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'api_key_delete', 'api_key', (int)($_POST['key_id'] ?? 0), 'API-Key gelöscht');
|
||||
$success = __('api_deleted');
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +127,12 @@ $adminBase = '';
|
|||
<td class="muted" data-label="<?= __('api_col_last_used') ?>"><?= $k['last_used_at'] ? date('d.m.Y H:i', strtotime($k['last_used_at'])) : '–' ?></td>
|
||||
<td class="muted" data-label="<?= __('api_col_created_by') ?>"><?= htmlspecialchars($k['creator'] ?? '–') ?></td>
|
||||
<td style="text-align:right;white-space:nowrap;">
|
||||
<a class="a-link" href="?toggle=<?= (int)$k['id'] ?>&token=<?= urlencode($csrf) ?>"><?= $k['is_active'] ? __('api_action_block') : __('api_action_unblock') ?></a>
|
||||
<a class="a-link" style="color:var(--danger);" href="?delete=<?= (int)$k['id'] ?>&token=<?= urlencode($csrf) ?>" onclick="return confirm('<?= __('api_delete_confirm') ?>');"><?= __('btn_delete') ?></a>
|
||||
<?= Ui::actionForm('toggle_key', ['key_id' => (int)$k['id']], $csrf,
|
||||
htmlspecialchars($k['is_active'] ? __('api_action_block') : __('api_action_unblock')),
|
||||
'btn btn-secondary btn-sm') ?>
|
||||
<?= Ui::actionForm('delete_key', ['key_id' => (int)$k['id']], $csrf,
|
||||
htmlspecialchars(__('btn_delete')),
|
||||
'btn btn-danger-soft btn-sm', __('api_delete_confirm')) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,12 @@ $oidcScopes = $db->getSetting('oidc_scopes', 'openid profile email');
|
|||
$oidcSecretSet = $db->getSetting('oidc_client_secret', '') !== '';
|
||||
$dailyLimit = (int)$db->getSetting('user_daily_voucher_limit', 0);
|
||||
$trustedProxy = $db->getSetting('trusted_proxy', '');
|
||||
|
||||
// Hinweis, wenn die Anfrage offensichtlich über einen Proxy kam, aber keiner
|
||||
// eingetragen ist: dann zählt das Rate-Limit alle Gäste als eine Adresse.
|
||||
$remoteAddr = (string)($_SERVER['REMOTE_ADDR'] ?? '');
|
||||
$proxyWarning = trim($trustedProxy) === ''
|
||||
&& (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['HTTP_X_REAL_IP']));
|
||||
$webhookEnabled = $db->getSetting('webhook_enabled', '0') === '1';
|
||||
$webhookUrl = $db->getSetting('webhook_url', '');
|
||||
$cleanupExpired = (int)$db->getSetting('cleanup_expired_days', 0);
|
||||
|
|
@ -134,6 +140,15 @@ $adminBase = '';
|
|||
<h2><?= __('int_proxy') ?></h2>
|
||||
<p class="muted"><?= __('int_proxy_hint') ?> <code>X-Forwarded-For</code> <?= __('int_proxy_hint2') ?></p>
|
||||
<input class="input" type="text" name="trusted_proxy" value="<?= htmlspecialchars($trustedProxy) ?>" placeholder="z.B. 10.0.0.1, 172.18.0.1">
|
||||
<?php if ($proxyWarning): ?>
|
||||
<div class="alert alert-warning" style="margin-top:12px;">
|
||||
<i class="fas fa-triangle-exclamation" aria-hidden="true"></i>
|
||||
<span>
|
||||
<?= str_replace('{ip}', htmlspecialchars($remoteAddr), __('int_proxy_warning')) ?><br>
|
||||
<?= __('int_proxy_suggestion') ?> <code><?= htmlspecialchars($remoteAddr) ?></code>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
|
|
|||
|
|
@ -128,15 +128,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['renew_token'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['delete'], $_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$old = $db->fetchOne("SELECT logo_url, background_url FROM kiosks WHERE id = ?", [(int)$_GET['delete']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_kiosk'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$deleteId = (int)($_POST['kiosk_id'] ?? 0);
|
||||
$old = $db->fetchOne("SELECT logo_url, background_url FROM kiosks WHERE id = ?", [$deleteId]);
|
||||
if ($old) {
|
||||
Upload::delete((string)($old['logo_url'] ?? ''));
|
||||
Upload::delete((string)($old['background_url'] ?? ''));
|
||||
}
|
||||
$db->execute("DELETE FROM kiosks WHERE id = ?", [(int)$_GET['delete']]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_deleted', 'kiosk', (int)$_GET['delete'], '');
|
||||
$db->execute("DELETE FROM kiosks WHERE id = ?", [$deleteId]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'kiosk_deleted', 'kiosk', $deleteId, '');
|
||||
$success = __('kiosks_deleted');
|
||||
} else {
|
||||
$error = __('error_csrf');
|
||||
|
|
@ -270,12 +271,9 @@ $adminBase = '';
|
|||
<i class="fas fa-rotate" aria-hidden="true"></i> <?= __('kiosks_renew') ?>
|
||||
</button>
|
||||
</form>
|
||||
<a class="btn btn-danger-soft btn-sm"
|
||||
href="?delete=<?= (int)$k['id'] ?>&token=<?= urlencode($csrf) ?>"
|
||||
onclick="return confirm('<?= __('kiosks_delete_confirm') ?>');"
|
||||
title="<?= __('btn_delete') ?>" aria-label="<?= __('btn_delete') ?>">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('delete_kiosk', ['kiosk_id' => (int)$k['id']], $csrf,
|
||||
'<i class="fas fa-trash" aria-hidden="true"></i>',
|
||||
'btn btn-danger-soft btn-sm', __('kiosks_delete_confirm'), __('btn_delete')) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ require_once __DIR__ . '/../includes/Database.php';
|
|||
require_once __DIR__ . '/../includes/Auth.php';
|
||||
require_once __DIR__ . '/../includes/UniFiController.php';
|
||||
require_once __DIR__ . '/../includes/I18n.php';
|
||||
require_once __DIR__ . '/../includes/Ui.php';
|
||||
|
||||
$auth = new Auth();
|
||||
$auth->requireAdmin();
|
||||
|
|
@ -71,9 +72,9 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['add_site'])) {
|
|||
}
|
||||
|
||||
// Delete site
|
||||
if (isset($_GET['delete']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$delId = (int)$_GET['delete'];
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_site'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$delId = (int)($_POST['site_id'] ?? 0);
|
||||
$db->query("DELETE FROM sites WHERE id=?", [$delId]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'],'site_delete','site',$delId,'Site gelöscht');
|
||||
$success = __('sites_deleted');
|
||||
|
|
@ -81,11 +82,11 @@ if (isset($_GET['delete']) && isset($_GET['token'])) {
|
|||
}
|
||||
|
||||
// Toggle site
|
||||
if (isset($_GET['toggle']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$site = $db->fetchOne("SELECT is_active FROM sites WHERE id=?", [(int)$_GET['toggle']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['toggle_site'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$site = $db->fetchOne("SELECT is_active FROM sites WHERE id=?", [(int)($_POST['site_id'] ?? 0)]);
|
||||
if ($site) {
|
||||
$db->query("UPDATE sites SET is_active=? WHERE id=?", [$site['is_active']?0:1,(int)$_GET['toggle']]);
|
||||
$db->query("UPDATE sites SET is_active=? WHERE id=?", [$site['is_active']?0:1,(int)($_POST['site_id'] ?? 0)]);
|
||||
$success = 'Site-Status aktualisiert!';
|
||||
}
|
||||
} else { $error = __('error_csrf'); }
|
||||
|
|
@ -160,16 +161,12 @@ $currentPage = 'sites';
|
|||
class="btn btn-secondary btn-sm">
|
||||
<i class="fas fa-edit" aria-hidden="true"></i> <?= __('btn_edit') ?>
|
||||
</button>
|
||||
<a href="?toggle=<?= $site['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-secondary btn-sm">
|
||||
<i class="fas fa-<?= $site['is_active'] ? 'pause' : 'play' ?>" aria-hidden="true"></i>
|
||||
<?= $site['is_active'] ? __('sites_deactivate') : __('sites_activate') ?>
|
||||
</a>
|
||||
<a href="?delete=<?= $site['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-danger-soft btn-sm"
|
||||
onclick="return confirm('<?= __('js_confirm_delete_site') ?>')">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('toggle_site', ['site_id' => $site['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-' . ($site['is_active'] ? 'pause' : 'play') . '" aria-hidden="true"></i> '
|
||||
. htmlspecialchars($site['is_active'] ? __('sites_deactivate') : __('sites_activate'))) ?>
|
||||
<?= Ui::actionForm('delete_site', ['site_id' => $site['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-trash" aria-hidden="true"></i>',
|
||||
'btn btn-danger-soft btn-sm', __('js_confirm_delete_site'), __('btn_delete')) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -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/Ui.php';
|
||||
|
||||
$auth = new Auth();
|
||||
$auth->requireAdmin();
|
||||
|
|
@ -79,9 +80,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_template'])) {
|
|||
}
|
||||
|
||||
// Profil löschen
|
||||
if (isset($_GET['delete']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$db->execute("DELETE FROM voucher_templates WHERE id = ?", [(int)$_GET['delete']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_template'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$db->execute("DELETE FROM voucher_templates WHERE id = ?", [(int)($_POST['template_id'] ?? 0)]);
|
||||
$success = __('templates_deleted');
|
||||
} else {
|
||||
$error = __('error_csrf');
|
||||
|
|
@ -175,9 +176,9 @@ $adminBase = '';
|
|||
<td data-label="<?= __('label_actions') ?>">
|
||||
<button onclick="openEditModal(<?= $t['id'] ?>, '<?= htmlspecialchars($t['name'], ENT_QUOTES) ?>', <?= (int)$t['max_uses'] ?>, <?= (int)$t['expire_minutes'] ?>, '<?= htmlspecialchars($t['description'] ?? '', ENT_QUOTES) ?>', <?= (int)$t['is_active'] ?>, <?= (int)($t['qos_rate_max_down'] ?? 0) ?>, <?= (int)($t['qos_rate_max_up'] ?? 0) ?>, <?= (int)($t['qos_usage_quota'] ?? 0) ?>)"
|
||||
class="btn btn-secondary btn-small"><i class="fas fa-edit" aria-hidden="true"></i></button>
|
||||
<a href="?delete=<?= $t['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
onclick="return confirm('<?= __('js_confirm_delete_template') ?>')"
|
||||
class="btn btn-danger-soft btn-small"><i class="fas fa-trash" aria-hidden="true"></i></a>
|
||||
<?= Ui::actionForm('delete_template', ['template_id' => $t['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-trash" aria-hidden="true"></i>',
|
||||
'btn btn-danger-soft btn-small', __('js_confirm_delete_template'), __('btn_delete')) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ require_once __DIR__ . '/../includes/Database.php';
|
|||
require_once __DIR__ . '/../includes/Auth.php';
|
||||
require_once __DIR__ . '/../includes/Mailer.php';
|
||||
require_once __DIR__ . '/../includes/I18n.php';
|
||||
require_once __DIR__ . '/../includes/Ui.php';
|
||||
|
||||
$auth = new Auth();
|
||||
$auth->requireAdmin();
|
||||
|
|
@ -21,9 +22,9 @@ $error = '';
|
|||
$success = '';
|
||||
|
||||
// Send password reset link
|
||||
if (isset($_GET['send_reset']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$targetUser = $db->fetchOne("SELECT * FROM users WHERE id=? AND is_active=1 AND password_hash IS NOT NULL", [(int)$_GET['send_reset']]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['send_reset'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$targetUser = $db->fetchOne("SELECT * FROM users WHERE id=? AND is_active=1 AND password_hash IS NOT NULL", [(int)($_POST['user_id'] ?? 0)]);
|
||||
if ($targetUser) {
|
||||
try {
|
||||
$db->execute("DELETE FROM password_reset_tokens WHERE user_id=?", [$targetUser['id']]);
|
||||
|
|
@ -118,11 +119,11 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['add_user'])) {
|
|||
}
|
||||
|
||||
// Delete user
|
||||
if (isset($_GET['delete']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$deleteId = (int)$_GET['delete'];
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_user'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$deleteId = (int)($_POST['user_id'] ?? 0);
|
||||
if ($deleteId === (int)$_SESSION['user_id']) {
|
||||
$error = 'Sie können sich nicht selbst löschen';
|
||||
$error = __('users_self_delete');
|
||||
} else {
|
||||
$db->query("DELETE FROM users WHERE id=?", [$deleteId]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'], 'user_delete', 'user', $deleteId, 'Benutzer gelöscht');
|
||||
|
|
@ -132,27 +133,27 @@ if (isset($_GET['delete']) && isset($_GET['token'])) {
|
|||
}
|
||||
|
||||
// Toggle user active
|
||||
if (isset($_GET['toggle']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$toggleId = (int)$_GET['toggle'];
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['toggle_user'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$toggleId = (int)($_POST['user_id'] ?? 0);
|
||||
if ($toggleId === (int)$_SESSION['user_id']) {
|
||||
$error = 'Sie können sich nicht selbst deaktivieren';
|
||||
$error = __('users_self_disable');
|
||||
} else {
|
||||
$user = $db->fetchOne("SELECT is_active FROM users WHERE id=?", [$toggleId]);
|
||||
if ($user) {
|
||||
$newStatus = $user['is_active'] ? 0 : 1;
|
||||
$db->query("UPDATE users SET is_active=? WHERE id=?", [$newStatus, $toggleId]);
|
||||
$success = 'Benutzer-Status aktualisiert!';
|
||||
$success = __('users_status_updated');
|
||||
}
|
||||
}
|
||||
} else { $error = __('error_csrf'); }
|
||||
}
|
||||
|
||||
// 2FA eines Benutzers zurücksetzen (Admin-Hilfe bei verlorenem Authenticator)
|
||||
if (isset($_GET['reset_2fa']) && isset($_GET['token'])) {
|
||||
if ($auth->validateCsrfToken($_GET['token'])) {
|
||||
$auth->disableTotp((int)$_GET['reset_2fa']);
|
||||
$success = '2FA des Benutzers wurde zurückgesetzt.';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['reset_2fa'])) {
|
||||
if ($auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||||
$auth->disableTotp((int)($_POST['user_id'] ?? 0));
|
||||
$success = __('users_2fa_reset');
|
||||
} else { $error = __('error_csrf'); }
|
||||
}
|
||||
|
||||
|
|
@ -256,29 +257,27 @@ $currentPage = 'users';
|
|||
<i class="fas fa-edit" aria-hidden="true"></i>
|
||||
</button>
|
||||
<?php if ($user['id'] != $_SESSION['user_id']): ?>
|
||||
<a href="?toggle=<?= $user['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-secondary btn-sm" title="<?= $user['is_active'] ? __('sites_deactivate') : __('sites_activate') ?>">
|
||||
<i class="fas fa-<?= $user['is_active'] ? 'pause' : 'play' ?>" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('toggle_user', ['user_id' => $user['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-' . ($user['is_active'] ? 'pause' : 'play') . '" aria-hidden="true"></i>',
|
||||
'btn btn-secondary btn-sm', '',
|
||||
$user['is_active'] ? __('sites_deactivate') : __('sites_activate')) ?>
|
||||
<?php if ($smtpEnabled && !empty($user['password_hash'])): ?>
|
||||
<a href="?send_reset=<?= $user['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-warning btn-sm" title="<?= __('users_reset_pw') ?>"
|
||||
onclick="return confirm('Passwort-Reset-Link senden an <?= htmlspecialchars($user['email'], ENT_QUOTES) ?>?')">
|
||||
<i class="fas fa-key" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('send_reset', ['user_id' => $user['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-key" aria-hidden="true"></i>',
|
||||
'btn btn-warning btn-sm',
|
||||
str_replace('{email}', $user['email'], __('users_reset_confirm')),
|
||||
__('users_reset_pw')) ?>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($user['totp_enabled'])): ?>
|
||||
<a href="?reset_2fa=<?= $user['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-secondary btn-sm" title="2FA zurücksetzen"
|
||||
onclick="return confirm('2FA für <?= htmlspecialchars($user['email'], ENT_QUOTES) ?> zurücksetzen?')">
|
||||
<i class="fas fa-user-shield" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('reset_2fa', ['user_id' => $user['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-user-shield" aria-hidden="true"></i>',
|
||||
'btn btn-secondary btn-sm',
|
||||
str_replace('{email}', $user['email'], __('users_2fa_confirm')),
|
||||
__('users_2fa_reset_title')) ?>
|
||||
<?php endif; ?>
|
||||
<a href="?delete=<?= $user['id'] ?>&token=<?= $auth->getCsrfToken() ?>"
|
||||
class="btn btn-danger-soft btn-sm" title="<?= __('btn_delete') ?>"
|
||||
onclick="return confirm('<?= __('js_confirm_delete_user') ?>')">
|
||||
<i class="fas fa-trash" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?= Ui::actionForm('delete_user', ['user_id' => $user['id']], $auth->getCsrfToken(),
|
||||
'<i class="fas fa-trash" aria-hidden="true"></i>',
|
||||
'btn btn-danger-soft btn-sm', __('js_confirm_delete_user'), __('btn_delete')) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
47
docs/Caddyfile.example
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Beispiel-Konfiguration für Caddy 2.
|
||||
#
|
||||
# Wichtig: Caddy liest **keine** .htaccess-Dateien. Die Regeln aus der
|
||||
# mitgelieferten .htaccess (Sicherheits-Header, Sperre für interne Ordner,
|
||||
# keine PHP-Ausführung in uploads/) müssen hier stehen, sonst greifen sie nicht.
|
||||
|
||||
wlan.example.com {
|
||||
root * /var/www/unifi-voucher-tool
|
||||
encode zstd gzip
|
||||
|
||||
# --- Sicherheits-Header -------------------------------------------------
|
||||
header {
|
||||
X-Content-Type-Options "nosniff"
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
Referrer-Policy "strict-origin-when-cross-origin"
|
||||
Permissions-Policy "geolocation=(), microphone=(), camera=()"
|
||||
# Alle Assets liegen lokal; externe Quellen nur für hCaptcha,
|
||||
# falls es in den Einstellungen aktiviert wurde.
|
||||
Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://js.hcaptcha.com https://*.hcaptcha.com; style-src 'self' 'unsafe-inline' https://*.hcaptcha.com; img-src 'self' data: https:; font-src 'self'; connect-src 'self' https://*.hcaptcha.com; frame-src https://*.hcaptcha.com; frame-ancestors 'self'; base-uri 'self'; form-action 'self'"
|
||||
-Server
|
||||
}
|
||||
|
||||
# --- Interne Ordner und Dateien nicht ausliefern -------------------------
|
||||
@intern path /includes/* /tools/* /tests/* /updater/storage/* /updater/migrations/* /.git/*
|
||||
respond @intern 404
|
||||
|
||||
@geheim path /config.php /database.sql /composer.json /composer.lock /phpunit.xml.dist /phpstan.neon /VERSION
|
||||
respond @geheim 404
|
||||
|
||||
# --- Hochgeladene Dateien niemals als Programm ausführen -----------------
|
||||
# Ohne diese Regel würde eine als Bild getarnte PHP-Datei ausgeführt.
|
||||
@uploads_php path_regexp ^/uploads/.*\.(php|phtml|phar)$
|
||||
respond @uploads_php 403
|
||||
|
||||
# --- PHP ----------------------------------------------------------------
|
||||
php_fastcgi unix//run/php/php8.3-fpm.sock {
|
||||
# Nur echte PHP-Dateien an FPM geben
|
||||
split .php
|
||||
}
|
||||
|
||||
file_server
|
||||
|
||||
log {
|
||||
output file /var/log/caddy/unifi-voucher-tool.log
|
||||
format json
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 396 KiB After Width: | Height: | Size: 397 KiB |
|
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 390 KiB |
|
Before Width: | Height: | Size: 319 KiB After Width: | Height: | Size: 321 KiB |
|
Before Width: | Height: | Size: 319 KiB After Width: | Height: | Size: 319 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 262 KiB |
|
Before Width: | Height: | Size: 446 KiB After Width: | Height: | Size: 446 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 191 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 285 KiB |
|
Before Width: | Height: | Size: 421 KiB After Width: | Height: | Size: 423 KiB |
|
|
@ -17,17 +17,57 @@ class Database {
|
|||
]
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
die("Datenbankverbindung fehlgeschlagen: " . $e->getMessage());
|
||||
// Details nur ins Log: die Meldung enthaelt Host, Datenbankname
|
||||
// und je nach Treiber weitere Interna.
|
||||
error_log('Datenbankverbindung fehlgeschlagen: ' . $e->getMessage());
|
||||
throw new RuntimeException('database_unavailable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self();
|
||||
try {
|
||||
self::$instance = new self();
|
||||
} catch (RuntimeException $e) {
|
||||
// Auf der Kommandozeile (Cron, Tests) weiterreichen, im Web
|
||||
// eine verstaendliche Seite zeigen statt einer weissen Seite.
|
||||
if (PHP_SAPI === 'cli') {
|
||||
throw $e;
|
||||
}
|
||||
self::renderUnavailable();
|
||||
}
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schlichte Fehlerseite ohne Abhaengigkeiten – zum Zeitpunkt des Aufrufs
|
||||
* steht weder Datenbank noch Spracheinstellung zur Verfuegung.
|
||||
*/
|
||||
private static function renderUnavailable(): void {
|
||||
if (!headers_sent()) {
|
||||
http_response_code(503);
|
||||
header('Retry-After: 30');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
echo '<!DOCTYPE html><html lang="de"><head><meta charset="UTF-8">'
|
||||
. '<meta name="viewport" content="width=device-width, initial-scale=1.0">'
|
||||
. '<title>Dienst vorübergehend nicht verfügbar</title><style>'
|
||||
. 'body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;'
|
||||
. 'font-family:-apple-system,BlinkMacSystemFont,\'Segoe UI\',Roboto,Helvetica,Arial,sans-serif;'
|
||||
. 'background:#f6f7f9;color:#101625;}'
|
||||
. '.box{max-width:440px;padding:36px 32px;text-align:center;background:#fff;border:1px solid #e5e8ee;'
|
||||
. 'border-radius:16px;box-shadow:0 24px 48px -24px rgba(16,24,40,.25);}'
|
||||
. 'h1{margin:0 0 10px;font-size:20px;}p{margin:0;color:#525c6e;font-size:14px;line-height:1.6;}'
|
||||
. '</style></head><body><div class="box">'
|
||||
. '<h1>Dienst vorübergehend nicht verfügbar</h1>'
|
||||
. '<p>Die Datenbank ist gerade nicht erreichbar. Bitte in einem Moment erneut versuchen – '
|
||||
. 'Details stehen im Server-Log.</p>'
|
||||
. '</div></body></html>';
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getConnection() {
|
||||
return $this->pdo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,44 @@ class Ui
|
|||
. '</style>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Kleines Formular für eine verändernde Aktion.
|
||||
*
|
||||
* Löschen und Umschalten liefen früher über Links mit CSRF-Token in der
|
||||
* URL – das landet in Server-Logs, Referer-Headern und der Chronik.
|
||||
* Deshalb POST, auch wenn es im Markup etwas mehr ist.
|
||||
*
|
||||
* @param string $action Name des Submit-Feldes (z. B. 'delete_site')
|
||||
* @param array $fields weitere versteckte Felder, z. B. ['site_id' => 4]
|
||||
* @param string $inner Inhalt des Knopfes (HTML)
|
||||
*/
|
||||
public static function actionForm(
|
||||
string $action,
|
||||
array $fields,
|
||||
string $csrf,
|
||||
string $inner,
|
||||
string $class = 'btn btn-secondary btn-sm',
|
||||
string $confirm = '',
|
||||
string $title = ''
|
||||
): string {
|
||||
$esc = static fn ($text) => htmlspecialchars((string)$text, ENT_QUOTES);
|
||||
|
||||
$hidden = '<input type="hidden" name="csrf_token" value="' . $esc($csrf) . '">';
|
||||
foreach ($fields as $name => $value) {
|
||||
$hidden .= '<input type="hidden" name="' . $esc($name) . '" value="' . $esc($value) . '">';
|
||||
}
|
||||
|
||||
$attr = '';
|
||||
if ($confirm !== '') {
|
||||
$attr = ' onsubmit="return confirm(\'' . str_replace("'", "\\'", $confirm) . '\');"';
|
||||
}
|
||||
$titleAttr = $title !== '' ? ' title="' . $esc($title) . '" aria-label="' . $esc($title) . '"' : '';
|
||||
|
||||
return '<form method="post" style="display:inline;"' . $attr . '>' . $hidden
|
||||
. '<button type="submit" name="' . $esc($action) . '" value="1" class="' . $esc($class) . '"'
|
||||
. $titleAttr . '>' . $inner . '</button></form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildfeld mit Vorschau, Upload und URL-Eingabe.
|
||||
* Wird von den Einstellungen und der Kiosk-Verwaltung genutzt.
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ if ($step === 5 && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||
// .htaccess erstellen (ohne Rewrite Rules die Probleme machen)
|
||||
$htaccess = "# UniFi Voucher System\n\n";
|
||||
$htaccess .= "# Security\n";
|
||||
$htaccess .= "<FilesMatch \"(config\\.php|database\\.sql|install\\.php|test\\.php|m365_debug\\.php|\\.md)$\">\n";
|
||||
$htaccess .= "<FilesMatch \"(config\\.php|database\\.sql|install\\.php|test\\.php|\\.md)$\">\n";
|
||||
$htaccess .= " Order Allow,Deny\n";
|
||||
$htaccess .= " Deny from all\n";
|
||||
$htaccess .= "</FilesMatch>\n\n";
|
||||
|
|
|
|||
12
lang/de.php
|
|
@ -393,7 +393,7 @@ return [
|
|||
'backup_opt_sites' => 'Sites',
|
||||
'backup_opt_templates' => 'Voucher-Profile',
|
||||
'backup_import_confirm' => 'Import jetzt durchführen?',
|
||||
'backup_imported' => 'Import abgeschlossen: {settings} Einstellungen, {sites} Sites, {templates} Profile.',
|
||||
'backup_imported' => 'Import abgeschlossen: {settings} Einstellungen, {sites} Sites, {templates} Profile, {kiosks} Display-Seiten.',
|
||||
'rep_title' => 'Reporting',
|
||||
'rep_subtitle' => 'Auswertungen nach Zeitraum, Site und Benutzer.',
|
||||
'rep_period' => 'Zeitraum',
|
||||
|
|
@ -537,6 +537,16 @@ return [
|
|||
'kiosks_card_light' => 'Hell',
|
||||
'kiosks_card_dark' => 'Dunkel',
|
||||
'kiosks_card_hint' => 'Auf Fotos wirkt die dunkle Karte meist ruhiger.',
|
||||
'backup_opt_kiosks' => 'Display-Seiten',
|
||||
'users_self_delete' => 'Sie können sich nicht selbst löschen.',
|
||||
'users_self_disable' => 'Sie können sich nicht selbst deaktivieren.',
|
||||
'users_status_updated' => 'Benutzer-Status aktualisiert.',
|
||||
'users_2fa_reset' => '2FA des Benutzers wurde zurückgesetzt.',
|
||||
'users_reset_confirm' => 'Passwort-Reset-Link senden an {email}?',
|
||||
'users_2fa_confirm' => '2FA für {email} zurücksetzen?',
|
||||
'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:',
|
||||
'settings_tab_general' => 'Allgemein',
|
||||
'settings_tab_defaults' => 'Voucher-Standards',
|
||||
'settings_tab_cron' => 'Cron-Sync',
|
||||
|
|
|
|||
12
lang/en.php
|
|
@ -393,7 +393,7 @@ return [
|
|||
'backup_opt_sites' => 'Sites',
|
||||
'backup_opt_templates' => 'Voucher profiles',
|
||||
'backup_import_confirm' => 'Run the import now?',
|
||||
'backup_imported' => 'Import finished: {settings} settings, {sites} sites, {templates} profiles.',
|
||||
'backup_imported' => 'Import finished: {settings} settings, {sites} sites, {templates} profiles, {kiosks} display pages.',
|
||||
'rep_title' => 'Reporting',
|
||||
'rep_subtitle' => 'Analytics by period, site and user.',
|
||||
'rep_period' => 'Period',
|
||||
|
|
@ -537,6 +537,16 @@ return [
|
|||
'kiosks_card_light' => 'Light',
|
||||
'kiosks_card_dark' => 'Dark',
|
||||
'kiosks_card_hint' => 'On photos the dark card usually looks calmer.',
|
||||
'backup_opt_kiosks' => 'Display pages',
|
||||
'users_self_delete' => 'You cannot delete your own account.',
|
||||
'users_self_disable' => 'You cannot deactivate your own account.',
|
||||
'users_status_updated' => 'User status updated.',
|
||||
'users_2fa_reset' => 'Two-factor authentication has been reset for this user.',
|
||||
'users_reset_confirm' => 'Send a password reset link to {email}?',
|
||||
'users_2fa_confirm' => 'Reset two-factor authentication for {email}?',
|
||||
'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:',
|
||||
'settings_tab_general' => 'General',
|
||||
'settings_tab_defaults' => 'Voucher Defaults',
|
||||
'settings_tab_cron' => 'Cron Sync',
|
||||
|
|
|
|||
186
login_simple.php
|
|
@ -1,186 +0,0 @@
|
|||
<?php
|
||||
// Umfassendes Error Reporting
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
|
||||
// Versuche Dateien zu laden
|
||||
$loadErrors = [];
|
||||
|
||||
try {
|
||||
if (!file_exists(__DIR__ . '/config.php')) {
|
||||
throw new Exception('config.php nicht gefunden');
|
||||
}
|
||||
require_once __DIR__ . '/config.php';
|
||||
} catch (Exception $e) {
|
||||
$loadErrors[] = "Config: " . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
if (!file_exists(__DIR__ . '/includes/Database.php')) {
|
||||
throw new Exception('includes/Database.php nicht gefunden');
|
||||
}
|
||||
require_once __DIR__ . '/includes/Database.php';
|
||||
} catch (Exception $e) {
|
||||
$loadErrors[] = "Database: " . $e->getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
if (!file_exists(__DIR__ . '/includes/Auth.php')) {
|
||||
throw new Exception('includes/Auth.php nicht gefunden');
|
||||
}
|
||||
require_once __DIR__ . '/includes/Auth.php';
|
||||
require_once __DIR__ . '/includes/Ui.php';
|
||||
} catch (Exception $e) {
|
||||
$loadErrors[] = "Auth: " . $e->getMessage();
|
||||
}
|
||||
|
||||
// Wenn Ladefehler aufgetreten sind, zeige sie an
|
||||
if (!empty($loadErrors)) {
|
||||
die('<h1>Fehler beim Laden der Dateien</h1><ul><li>' . implode('</li><li>', $loadErrors) . '</li></ul>');
|
||||
}
|
||||
|
||||
// Ab hier normal weiter
|
||||
try {
|
||||
$auth = new Auth();
|
||||
} catch (Exception $e) {
|
||||
die('<h1>Fehler bei Auth-Initialisierung</h1><p>' . $e->getMessage() . '</p>');
|
||||
}
|
||||
|
||||
// Wenn bereits eingeloggt, weiterleiten
|
||||
if ($auth->isLoggedIn()) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
// Login-Verarbeitung
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
try {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (empty($email) || empty($password)) {
|
||||
$error = 'Bitte E-Mail und Passwort eingeben';
|
||||
} elseif ($auth->login($email, $password)) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Ungültige E-Mail oder Passwort';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$error = 'Login-Fehler: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$appTitle = $db->getSetting('app_title', 'UniFi Voucher System');
|
||||
$logoUrl = $db->getSetting('logo_url', '');
|
||||
$m365Enabled = !empty($db->getSetting('m365_client_id')) &&
|
||||
!empty($db->getSetting('m365_client_secret')) &&
|
||||
!empty($db->getSetting('m365_tenant_id'));
|
||||
$publicAccess = $db->getSetting('public_access', 0);
|
||||
|
||||
// M365 OAuth URL generieren falls aktiviert
|
||||
$m365LoginUrl = '';
|
||||
if ($m365Enabled) {
|
||||
$clientId = $db->getSetting('m365_client_id');
|
||||
$tenantId = $db->getSetting('m365_tenant_id');
|
||||
|
||||
// Dynamische Redirect URI basierend auf aktuellem Pfad
|
||||
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
||||
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
||||
$redirectUri = $protocol . '://' . $host . $scriptPath . '/m365_callback.php';
|
||||
|
||||
$params = [
|
||||
'client_id' => $clientId,
|
||||
'response_type' => 'code',
|
||||
'redirect_uri' => $redirectUri,
|
||||
'response_mode' => 'query',
|
||||
'scope' => 'openid profile email User.Read',
|
||||
'state' => bin2hex(random_bytes(16))
|
||||
];
|
||||
|
||||
$_SESSION['m365_state'] = $params['state'];
|
||||
|
||||
$m365LoginUrl = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/authorize?" . http_build_query($params);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
die('<h1>Datenbankfehler</h1><p>' . $e->getMessage() . '</p>');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - <?= htmlspecialchars($appTitle) ?></title>
|
||||
<?= Ui::head($db) ?>
|
||||
<style>
|
||||
/* Diagnose-Ausgabe am Seitenende */
|
||||
.debug-info {
|
||||
margin-top: 22px; padding: 14px;
|
||||
background: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: var(--r-md);
|
||||
font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="app-body focus-page">
|
||||
<div class="focus-card card login-container">
|
||||
<?php if ($logoUrl): ?>
|
||||
<img src="<?= htmlspecialchars(Ui::mediaUrl($logoUrl)) ?>" alt="Logo" class="logo">
|
||||
<?php else: ?>
|
||||
<h1><?= htmlspecialchars($appTitle) ?></h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="subtitle">Melden Sie sich an, um fortzufahren</p>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-error"><?= htmlspecialchars($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success"><?= htmlspecialchars($success) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="">
|
||||
<div class="form-group">
|
||||
<label for="email">E-Mail</label>
|
||||
<input type="email" id="email" name="email" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">Passwort</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-lg btn-block">Anmelden</button>
|
||||
</form>
|
||||
|
||||
<?php if ($m365Enabled): ?>
|
||||
<div class="divider"><span>oder</span></div>
|
||||
<a href="<?= htmlspecialchars($m365LoginUrl) ?>" class="btn btn-microsoft">
|
||||
<i class="fab fa-microsoft" aria-hidden="true"></i> Mit Microsoft 365 anmelden
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($publicAccess): ?>
|
||||
<div class="auth-links"><a href="index.php" class="back-link"><i class="fas fa-arrow-left" aria-hidden="true"></i> Zurück zur Code-Erstellung</a></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Debug Info (kann nach erfolgreicher Einrichtung entfernt werden) -->
|
||||
<div class="debug-info">
|
||||
<strong>System-Status:</strong><br>
|
||||
PHP Version: <?= phpversion() ?><br>
|
||||
Session Status: <?= session_status() === PHP_SESSION_ACTIVE ? 'Aktiv' : 'Inaktiv' ?><br>
|
||||
Eingeloggt: <?= $auth->isLoggedIn() ? 'Ja' : 'Nein' ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
require_once __DIR__ . '/includes/Database.php';
|
||||
require_once __DIR__ . '/includes/Auth.php';
|
||||
|
||||
// Diagnose-Seite nur fuer angemeldete Admins (leakt sonst M365-Konfiguration)
|
||||
$auth = new Auth();
|
||||
$auth->requireAdmin();
|
||||
|
||||
$db = Database::getInstance();
|
||||
|
||||
// M365 Einstellungen abrufen
|
||||
$clientId = $db->getSetting('m365_client_id', '');
|
||||
$clientSecret = $db->getSetting('m365_client_secret', '');
|
||||
$tenantId = $db->getSetting('m365_tenant_id', '');
|
||||
|
||||
// Dynamische URLs
|
||||
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
||||
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
||||
$redirectUri = $protocol . '://' . $host . $scriptPath . '/m365_callback.php';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>M365 Debug</title>
|
||||
<?php require_once __DIR__ . '/includes/Ui.php'; ?>
|
||||
<?= Ui::head($db ?? null) ?>
|
||||
<style>
|
||||
body { padding: 32px 20px; }
|
||||
.section { max-width: 820px; margin: 0 auto 18px; padding: 20px; background: var(--bg-card);
|
||||
border: 1px solid var(--border-color); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
|
||||
.section h2 { font-size: 15px; margin-bottom: 12px; }
|
||||
.ok { color: var(--success); font-weight: 600; }
|
||||
.error { color: var(--danger); font-weight: 600; }
|
||||
.info { color: var(--text-muted); }
|
||||
.url { padding: 10px 12px; background: var(--bg-subtle); border: 1px solid var(--border-color);
|
||||
border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12.5px; word-break: break-all; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="app-body">
|
||||
<h1>🔍 Microsoft 365 OAuth Debug</h1>
|
||||
|
||||
<div class="section">
|
||||
<h2>1. Konfiguration Status</h2>
|
||||
<p>Client ID: <?= !empty($clientId) ? '<span class="ok">✓ Gesetzt</span>' : '<span class="error">✗ Fehlt</span>' ?></p>
|
||||
<p>Client Secret: <?= !empty($clientSecret) ? '<span class="ok">✓ Gesetzt</span>' : '<span class="error">✗ Fehlt</span>' ?></p>
|
||||
<p>Tenant ID: <?= !empty($tenantId) ? '<span class="ok">✓ Gesetzt</span>' : '<span class="error">✗ Fehlt</span>' ?></p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>2. Redirect URI</h2>
|
||||
<p>Diese URI muss exakt in der Azure-App-Registrierung hinterlegt sein:</p>
|
||||
<div class="url"><?= htmlspecialchars($redirectUri) ?></div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>3. Hinweise</h2>
|
||||
<ul>
|
||||
<li>Alle drei Werte (Client ID, Client Secret, Tenant ID) müssen gesetzt sein.</li>
|
||||
<li>Die Redirect URI in Azure AD muss exakt mit der obigen übereinstimmen.</li>
|
||||
<li>Benötigte API-Berechtigungen: <code>openid</code>, <code>profile</code>, <code>email</code>, <code>User.Read</code>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||