Design-Tab (Administration → Einstellungen → Design): - Akzentfarbe für Hell- und Dark-Mode, Markenverlauf und Eckenradius - abgeleitete Töne (Hover, weiche Flächen, Fokusring) werden per color-mix aus der Grundfarbe berechnet – eine Farbe genügt - Live-Vorschau mit Button, Badge, Chip, Logo-Kachel und Link - Ausgabe als schlanker :root-Override über Ui::brandingStyle(), greift auf allen Seiten inklusive Login und Installer Uploads (includes/Upload.php): - Logo, Favicon, Login-Logo und Login-Hintergrund lassen sich jetzt hochladen; das URL-Feld bleibt als Alternative bestehen - Whitelist nach Endung, 3-MB-Grenze, getimagesize-Prüfung für Raster, SVGs werden von Skripten, Event-Handlern und externen Verweisen befreit - Zufällige Dateinamen in uploads/, dort sperrt eine .htaccess die Ausführung von PHP; beim Ersetzen wird die alte Datei gelöscht Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
186 lines
No EOL
6.4 KiB
PHP
186 lines
No EOL
6.4 KiB
PHP
<?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"></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"></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>
|