| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- require_once __DIR__ . '/../config.php';
- require_once __DIR__ . '/../includes/functions.php';
- // Handle logout
- if (isset($_GET['logout'])) {
- $_SESSION['admin_logged_in'] = false;
- unset($_SESSION['admin_username']);
- session_destroy();
- header('Location: login.php');
- exit;
- }
- $error = '';
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $username = normalizeAdminUsername($_POST['username'] ?? '');
- $password = $_POST['password'] ?? '';
-
- $users = getAdminUsers();
- if (isset($users[$username]) && password_verify($password, $users[$username])) {
- $_SESSION['admin_logged_in'] = true;
- $_SESSION['admin_username'] = $username;
- header('Location: index.php');
- exit;
- } else {
- $error = 'Benutzername oder Passwort falsch.';
- }
- }
- // Redirect if already logged in
- if (isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in']) {
- header('Location: index.php');
- exit;
- }
- ?>
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Administration - <?php echo escape(SITE_FULL_NAME); ?></title>
- <link rel="stylesheet" href="<?php echo escape(SITE_URL); ?>/assets/css/style.css">
- </head>
- <body class="admin-page">
- <header class="site-header">
- <div class="container header-inner">
- <a class="brand" href="<?php echo escape(SITE_URL); ?>/index.php">
- <img class="brand-logo" src="<?php echo escape(SITE_URL); ?>/assets/branding/stadt-freising-logo.png" alt="Wappen der Stadt Freising">
- <div class="brand-text">
- <span class="brand-title"><?php echo escape(SITE_NAME); ?></span>
- <span class="brand-subtitle"><?php echo escape(SITE_SERVICE_HEADER); ?></span>
- </div>
- </a>
- <a href="<?php echo escape(SITE_URL); ?>/index.php" class="btn btn-secondary">Zurück zu <?php echo escape(SITE_SERVICE_NAME); ?></a>
- </div>
- </header>
- <main>
- <div class="container container-narrow page-top-gap">
- <h2>Administration</h2>
-
- <?php if ($error): ?>
- <div class="alert alert-error">
- <?php echo htmlspecialchars($error); ?>
- </div>
- <?php endif; ?>
-
- <form method="POST" class="panel panel-lg">
- <div class="form-group">
- <label for="username">Benutzername:</label>
- <input type="text" id="username" name="username" 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-block">Anmelden</button>
- </form>
-
- <div class="text-center mt-2">
- <a href="<?php echo escape(SITE_URL); ?>/index.php">Zurück zu <?php echo escape(SITE_SERVICE_NAME); ?></a>
- </div>
- </div>
- </main>
- </body>
- </html>
|