Some checks failed
CI / PHP Lint (push) Waiting to run
CI / PHP Lint-1 (push) Waiting to run
CI / Unit Tests & Static Analysis (push) Waiting to run
CI / PHP Lint (pull_request) Has been cancelled
CI / PHP Lint-1 (pull_request) Has been cancelled
CI / Unit Tests & Static Analysis (pull_request) Has been cancelled
Frontend, Login/Installer/Updater und der komplette Admin-Bereich nutzen jetzt ein einziges Stylesheet (assets/global.css) statt pro Seite dupliziertem Inline-CSS. Design-System - Tokens für Flächen, Text, Linien, Marke, Status, Radien, Schatten und Layout-Maße; Dark Mode ausschließlich über Tokens (keine !important- Overrides mehr) - Komponenten: Buttons, Formularfelder, Cards, Tabellen, Badges, Alerts, Tabs, Pagination, Modals, Toasts, Statistik-Kacheln, Empty States - Schrift Inter mit System-Fallback Oberfläche - Admin-Shell neu: durchgehende Sidebar mit Marke, gruppierter Navigation und Benutzerbereich; schlanke Topbar mit Breadcrumb - Dashboard: ruhige KPI-Kacheln mit Icon-Chips, Charts an Theme-Farben gekoppelt - Öffentliche Voucher-Seite: App-Topbar, klare Formularstruktur und Ticket-Darstellung des erstellten Codes inkl. QR-Code - Login/Passwort/2FA: zweispaltiges Auth-Layout bzw. Fokus-Karten - Updater und Wartungsmodus im gleichen Look (Wartungsseite bleibt bewusst eigenständig ohne externe Abhängigkeiten) - Emoji-Icons in der UI durch Font-Awesome-Icons ersetzt Nebenbei behoben - Falscher SRI-Hash blockierte qrcode.min.js – QR-Codes wurden auf der Voucher-Seite und bei der 2FA-Einrichtung nie gerendert - assets/global.css wurde in mehreren Admin-Seiten über einen falschen Pfad eingebunden ($adminBase = '' statt '../') - TinyMCE lädt ohne API-Key jetzt die GPL-Variante von cdnjs – kein "valid API key required"-Banner mehr im Einstellungs-Editor - Tabellen in Cards scrollen horizontal statt zu überlaufen Screenshots in docs/screenshots neu erstellt, README aktualisiert (neuer Abschnitt "Design-System", Version 2.5.0). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
125 lines
5.2 KiB
PHP
125 lines
5.2 KiB
PHP
<?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';
|
||
require_once __DIR__ . '/includes/Mailer.php';
|
||
require_once __DIR__ . '/includes/I18n.php';
|
||
|
||
$auth = new Auth();
|
||
if ($auth->isLoggedIn()) { header('Location: index.php'); exit; }
|
||
I18n::init();
|
||
|
||
$db = Database::getInstance();
|
||
$appTitle = $db->getSetting('app_title', 'UniFi Voucher System');
|
||
$logoUrl = $db->getSetting('logo_url', '');
|
||
$systemUrl = rtrim($db->getSetting('system_url', ''), '/');
|
||
|
||
$error = '';
|
||
$success = '';
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
$email = trim($_POST['email'] ?? '');
|
||
|
||
// Einfacher Throttle: max. 3 Anfragen pro 15 Minuten je Session (gegen Spam)
|
||
$now = time();
|
||
$rl = array_values(array_filter($_SESSION['pwreset_times'] ?? [], fn($t) => ($now - $t) < 900));
|
||
if (count($rl) >= 3) {
|
||
$error = 'Zu viele Anfragen. Bitte warten Sie einige Minuten.';
|
||
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||
$error = __('error_email_invalid');
|
||
} else {
|
||
$rl[] = $now;
|
||
$_SESSION['pwreset_times'] = $rl;
|
||
$user = $db->fetchOne("SELECT * FROM users WHERE email = ? AND is_active = 1 AND password_hash IS NOT NULL", [$email]);
|
||
|
||
// Always show success (don't reveal whether email exists)
|
||
if ($user) {
|
||
try {
|
||
// Delete old tokens for this user
|
||
$db->execute("DELETE FROM password_reset_tokens WHERE user_id = ?", [$user['id']]);
|
||
|
||
// Generate token
|
||
$token = bin2hex(random_bytes(32));
|
||
$expiresAt = date('Y-m-d H:i:s', strtotime('+1 hour'));
|
||
|
||
$db->execute(
|
||
"INSERT INTO password_reset_tokens (user_id, token, expires_at) VALUES (?, ?, ?)",
|
||
[$user['id'], $token, $expiresAt]
|
||
);
|
||
|
||
// Send email
|
||
$resetUrl = $systemUrl . '/reset_password.php?token=' . $token;
|
||
$mailer = new Mailer();
|
||
$subject = $appTitle . ' – Passwort zurücksetzen';
|
||
$body = "Hallo {$user['name']},\n\n" .
|
||
"Sie haben eine Passwort-Rücksetzung angefordert.\n\n" .
|
||
"Klicken Sie auf den folgenden Link, um Ihr Passwort zurückzusetzen (gültig für 1 Stunde):\n\n" .
|
||
$resetUrl . "\n\n" .
|
||
"Falls Sie dies nicht angefordert haben, ignorieren Sie diese E-Mail.\n\n" .
|
||
$appTitle;
|
||
$mailer->sendRaw($user['email'], $subject, $body);
|
||
|
||
// Audit log
|
||
$db->execute(
|
||
"INSERT INTO audit_log (user_id, action, entity_type, entity_id, details, ip_address) VALUES (?, 'password_reset', 'user', ?, 'Reset-Link angefordert', ?)",
|
||
[$user['id'], $user['id'], $_SERVER['REMOTE_ADDR'] ?? '']
|
||
);
|
||
} catch (Exception $e) {
|
||
// Silent – don't reveal errors to user
|
||
}
|
||
}
|
||
|
||
$success = __('reset_success');
|
||
}
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= I18n::getLanguage() ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?= __('reset_title') ?> – <?= htmlspecialchars($appTitle) ?></title>
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap">
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||
<link rel="stylesheet" href="assets/global.css">
|
||
<script>(function(){ const t=localStorage.getItem('theme')||'light'; document.documentElement.setAttribute('data-theme',t); })();</script>
|
||
</head>
|
||
<body class="app-body focus-page">
|
||
<div class="focus-card card">
|
||
<?php if ($logoUrl): ?>
|
||
<img src="<?= htmlspecialchars($logoUrl) ?>" alt="Logo" class="logo">
|
||
<?php else: ?>
|
||
<h1><?= htmlspecialchars($appTitle) ?></h1>
|
||
<?php endif; ?>
|
||
|
||
<h1><?= __('reset_title') ?></h1>
|
||
<p class="subtitle"><?= __('reset_subtitle') ?></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; ?>
|
||
|
||
<?php if (!$success): ?>
|
||
<form method="post">
|
||
<div class="form-group">
|
||
<label for="email"><?= __('reset_email_label') ?></label>
|
||
<input type="email" id="email" name="email" required autofocus placeholder="name@example.com">
|
||
</div>
|
||
<button type="submit" class="btn btn-primary btn-lg btn-block"><?= __('reset_send_btn') ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
|
||
<div class="auth-links"><a href="login.php" class="back-link"><i class="fas fa-arrow-left"></i> <?= __('reset_back_login') ?></a></div>
|
||
</div>
|
||
<script src="assets/global.js"></script>
|
||
</body>
|
||
</html>
|