Some checks failed
CI / PHP Lint-1 (push) Successful in 43s
CI / PHP Lint (push) Successful in 45s
CI / PHP Lint (pull_request) Successful in 38s
CI / Unit Tests & Static Analysis (push) Failing after 43s
CI / PHP Lint-1 (pull_request) Successful in 40s
CI / Unit Tests & Static Analysis (pull_request) Failing after 41s
Aktualisierung per Klick im Administrationsbereich, ohne Zugang zum Server. Der bisherige Updater lud ein ZIP und entpackte es ungeprüft über die Produktion; das ist vollständig ersetzt. Neu in updater/: - Version: Release-Version als Konstante, installierter Commit-SHA in storage/.version (Datei, nicht Datenbank - der Updater muss den Stand auch bei hängender Datenbank lesen können) - Progress: Fortschrittsdatei mit eigenem Fehlerzustand (pct = -1) und Verfallszeit, damit ein abgestürzter Lauf den nächsten nicht blockiert - Maintenance: Wartungsmarkierung mit Ablauf, die sich beim Prüfen selbst aufräumt - ProxyClient: nur HTTPS, Zertifikatsprüfung an, begrenzte Weiterleitungen, 503 mirror_pending/not_released als Bitte um Geduld - Updater: Prüfsumme gegen X-Content-Sha256, zweistufiger ZIP-Slip-Schutz, geschützte Pfade, atomares Schreiben je Datei, nie löschen - AutoMigrate: zieht Migrationen beim ersten Seitenaufruf nach, nur bei geändertem Fingerabdruck und mit Sperre gegen Parallellauf - guard.php: Wartungs-Wächter für die Einstiegsseiten, JSON für die Schnittstellen; ausgenommen bleiben Update-Seite, Anmeldung und Health-Check - Changelog: zerlegt CHANGELOG.md und rendert Markdown ohne unsichere Links Oberfläche: Seite "Aktualisierung" mit Stand, Kanal, Suche, Fortschritt, Migrationsliste und Versionsgeschichte. Der Datenschutzhinweis steht dauerhaft neben der Schaltfläche, nicht in einem Dialog. Fehlt changelog_preview in der Antwort, bleibt es bei "neue Fassung verfügbar" - kein leerer Kasten, kein erfundener Ersatztext. Commit-Texte werden nirgends angezeigt. Außerdem (Punkt 2 der Liste): - cron_test.php entfernt: ohne jede Anmeldung erreichbar, meldete Datenbankfehler samt Meldung und die Spalten der vouchers-Tabelle - test.php verweigert ohne config.php die Auskunft; bisher lief die Diagnose auf einer frisch entpackten Installation ohne Anmeldung PHPStan prüft jetzt den gesamten updater/-Ordner. 18 neue Tests (93 Tests, 243 Assertions), Ablauf gegen den echten Update-Dienst durchgespielt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
138 lines
4.9 KiB
PHP
138 lines
4.9 KiB
PHP
<?php
|
||
// Waehrend eines Updates antwortet der Waechter mit einer Wartungsseite.
|
||
require_once __DIR__ . '/updater/guard.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/Ui.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', '');
|
||
|
||
$token = trim($_GET['token'] ?? '');
|
||
$error = '';
|
||
$success = '';
|
||
$valid = false;
|
||
$tokenRow = null;
|
||
|
||
if (empty($token)) {
|
||
$error = __('reset_invalid');
|
||
} else {
|
||
$tokenRow = $db->fetchOne(
|
||
"SELECT prt.*, u.email, u.name FROM password_reset_tokens prt
|
||
JOIN users u ON prt.user_id = u.id
|
||
WHERE prt.token = ? AND prt.used = 0 AND prt.expires_at > NOW()",
|
||
[$token]
|
||
);
|
||
if (!$tokenRow) {
|
||
$error = __('reset_invalid');
|
||
} else {
|
||
$valid = true;
|
||
}
|
||
}
|
||
|
||
if ($valid && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
$newPw = $_POST['new_password'] ?? '';
|
||
$confirm= $_POST['confirm_password'] ?? '';
|
||
|
||
if (strlen($newPw) < 8) {
|
||
$error = __('settings_pw_minlength');
|
||
$valid = true; // keep form visible
|
||
} elseif ($newPw !== $confirm) {
|
||
$error = 'Passwörter stimmen nicht überein';
|
||
$valid = true;
|
||
} else {
|
||
$hash = password_hash($newPw, PASSWORD_DEFAULT);
|
||
$db->execute("UPDATE users SET password_hash = ? WHERE id = ?", [$hash, $tokenRow['user_id']]);
|
||
$db->execute("UPDATE password_reset_tokens SET used = 1 WHERE token = ?", [$token]);
|
||
|
||
$db->execute(
|
||
"INSERT INTO audit_log (user_id, action, entity_type, entity_id, details, ip_address) VALUES (?, 'password_reset', 'user', ?, 'Passwort erfolgreich geändert', ?)",
|
||
[$tokenRow['user_id'], $tokenRow['user_id'], $_SERVER['REMOTE_ADDR'] ?? '']
|
||
);
|
||
|
||
$success = __('reset_done');
|
||
$valid = false;
|
||
}
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= I18n::getLanguage() ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?= __('reset_new_pw') ?> – <?= htmlspecialchars($appTitle) ?></title>
|
||
<?= Ui::head($db) ?>
|
||
<style>
|
||
.pw-strength { height: 4px; border-radius: var(--r-pill); margin-top: 8px; background: var(--border-color); transition: width .3s, background-color .3s; }
|
||
.pw-strength.weak { background: var(--danger); width: 30%; }
|
||
.pw-strength.medium { background: var(--warning); width: 65%; }
|
||
.pw-strength.strong { background: var(--success); width: 100%; }
|
||
</style>
|
||
</head>
|
||
<body class="app-body focus-page">
|
||
<div class="focus-card card">
|
||
<?php if ($logoUrl): ?>
|
||
<img src="<?= htmlspecialchars(Ui::mediaUrl($logoUrl)) ?>" alt="Logo" class="logo">
|
||
<?php else: ?>
|
||
<div class="focus-icon" style="margin-bottom:14px;"><i class="fas fa-key" aria-hidden="true"></i></div>
|
||
<?php endif; ?>
|
||
|
||
<h1><?= __('reset_new_pw') ?></h1>
|
||
|
||
<?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 ($valid): ?>
|
||
<p class="subtitle">Für <strong><?= htmlspecialchars($tokenRow['email']) ?></strong></p>
|
||
<form method="post" action="reset_password.php?token=<?= htmlspecialchars($token) ?>">
|
||
<div class="form-group">
|
||
<label><?= __('reset_new_pw_label') ?></label>
|
||
<input type="password" name="new_password" id="pw" required minlength="8" oninput="checkPw(this.value)">
|
||
<div class="pw-strength" id="pwBar"></div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label><?= __('reset_confirm_label') ?></label>
|
||
<input type="password" name="confirm_password" required>
|
||
</div>
|
||
<button type="submit" class="btn btn-primary btn-lg btn-block"><?= __('reset_set_btn') ?></button>
|
||
</form>
|
||
<?php elseif ($success): ?>
|
||
<a href="login.php" class="btn btn-primary btn-lg btn-block"><?= __('btn_login') ?></a>
|
||
<?php endif; ?>
|
||
|
||
<a href="login.php" class="back-link"><?= __('reset_back_login') ?></a>
|
||
</div>
|
||
|
||
<script>
|
||
function checkPw(val) {
|
||
const bar = document.getElementById('pwBar');
|
||
if (!bar) return;
|
||
if (val.length >= 12 && /[A-Z]/.test(val) && /[0-9]/.test(val)) {
|
||
bar.className = 'pw-strength strong';
|
||
} else if (val.length >= 8) {
|
||
bar.className = 'pw-strength medium';
|
||
} else if (val.length > 0) {
|
||
bar.className = 'pw-strength weak';
|
||
} else {
|
||
bar.className = 'pw-strength';
|
||
}
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|