Files
Deploymentcenter/public/login.php
T

250 lines
7.4 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../src/Core/Db.php';
require_once __DIR__ . '/../src/Core/Auth.php';
use Deploymentcenter\Core\Db;
use Deploymentcenter\Core\Auth;
Auth::startSession();
if (Auth::isLoggedIn()) {
header('Location: /index.php');
exit;
}
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = trim($_POST['password'] ?? '');
if (!empty($username) && !empty($password)) {
try {
$config = require __DIR__ . '/../config/config.php';
$pdo = Db::init($config);
if (Auth::login($pdo, $username, $password)) {
header('Location: /index.php');
exit;
} else {
$error = 'Ungültige Anmeldedaten. Bitte überprüfen Sie Benutzername und Passwort.';
}
} catch (\Throwable $e) {
$error = 'Datenbankverbindung fehlgeschlagen: ' . $e->getMessage();
}
} else {
$error = 'Bitte füllen Sie alle Felder aus.';
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anmeldung - Deploymentcenter</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
--card-bg: rgba(30, 41, 59, 0.7);
--card-border: rgba(255, 255, 255, 0.1);
--primary: #6366f1;
--primary-hover: #4f46e5;
--text-main: #f8fafc;
--text-muted: #94a3b8;
--danger-bg: rgba(239, 68, 68, 0.15);
--danger-border: rgba(239, 68, 68, 0.3);
--danger-text: #fca5a5;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background: var(--bg-gradient);
color: var(--text-main);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 1.5rem;
}
.login-card {
background: var(--card-bg);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid var(--card-border);
border-radius: 20px;
padding: 2.5rem;
width: 100%;
max-width: 420px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
.brand-header {
text-align: center;
margin-bottom: 2rem;
}
.brand-logo {
width: 56px;
height: 56px;
background: linear-gradient(135deg, #6366f1, #a855f7);
border-radius: 14px;
display: inline-flex;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
}
.brand-logo svg {
width: 30px;
height: 30px;
fill: none;
stroke: #ffffff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.brand-title {
font-size: 1.5rem;
font-weight: 700;
letter-spacing: -0.025em;
background: linear-gradient(to right, #ffffff, #cbd5e1);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.brand-subtitle {
font-size: 0.875rem;
color: var(--text-muted);
margin-top: 0.25rem;
}
.alert-danger {
background: var(--danger-bg);
border: 1px solid var(--danger-border);
color: var(--danger-text);
padding: 0.875rem 1rem;
border-radius: 10px;
font-size: 0.875rem;
margin-bottom: 1.5rem;
}
.form-group {
margin-bottom: 1.25rem;
}
.form-label {
display: block;
font-size: 0.875rem;
font-weight: 500;
color: var(--text-muted);
margin-bottom: 0.5rem;
}
.form-control {
width: 100%;
background: rgba(15, 23, 42, 0.6);
border: 1px solid var(--card-border);
border-radius: 10px;
padding: 0.75rem 1rem;
font-size: 0.95rem;
color: var(--text-main);
outline: none;
transition: all 0.2s ease;
}
.form-control:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.btn-submit {
width: 100%;
background: linear-gradient(135deg, var(--primary), #4f46e5);
color: #ffffff;
border: none;
border-radius: 10px;
padding: 0.875rem;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
margin-top: 0.5rem;
}
.btn-submit:hover {
transform: translateY(-1px);
box-shadow: 0 15px 25px -5px rgba(99, 102, 241, 0.5);
}
.btn-submit:active {
transform: translateY(0);
}
.footer-note {
text-align: center;
font-size: 0.75rem;
color: var(--text-muted);
margin-top: 2rem;
}
</style>
</head>
<body>
<div class="login-card">
<div class="brand-header">
<div class="brand-logo">
<svg viewBox="0 0 24 24">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path>
</svg>
</div>
<h1 class="brand-title">Deploymentcenter</h1>
<p class="brand-subtitle">Bitte melden Sie sich an, um fortzufahren</p>
</div>
<?php if ($error): ?>
<div class="alert-danger"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST" action="login.php">
<div class="form-group">
<label for="username" class="form-label">Benutzername</label>
<input type="text" id="username" name="username" class="form-control" required autofocus placeholder="z. B. admin">
</div>
<div class="form-group">
<label for="password" class="form-label">Passwort</label>
<input type="password" id="password" name="password" class="form-control" required placeholder="••••••••">
</div>
<button type="submit" class="btn-submit">Anmelden</button>
</form>
<div class="footer-note">
Deploymentcenter &copy; <?= date('Y') ?> &bull; Unified License & Monitoring Platform
</div>
</div>
</body>
</html>