| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- require_once __DIR__ . '/../config.php';
- require_once __DIR__ . '/../includes/functions.php';
- // Handle logout
- if (isset($_GET['logout'])) {
- $_SESSION['admin_logged_in'] = false;
- session_destroy();
- header('Location: login.php');
- exit;
- }
- $error = '';
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $username = sanitize($_POST['username'] ?? '');
- $password = $_POST['password'] ?? '';
-
- $users = defined('ADMIN_USERS') ? ADMIN_USERS : [];
- if (isset($users[$username]) && password_verify($password, $users[$username])) {
- $_SESSION['admin_logged_in'] = true;
- 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>Admin Login - <?php echo SITE_NAME; ?></title>
- <link rel="stylesheet" href="<?php echo SITE_URL; ?>/assets/css/style.css">
- </head>
- <body>
- <header>
- <div class="container">
- <h1><?php echo SITE_NAME; ?> - Admin</h1>
- </div>
- </header>
- <main>
- <div class="container" style="max-width: 400px; margin-top: 4rem;">
- <h2>Admin Login</h2>
-
- <?php if ($error): ?>
- <div class="alert alert-error">
- <?php echo htmlspecialchars($error); ?>
- </div>
- <?php endif; ?>
-
- <form method="POST" class="panel" style="padding: 2rem;">
- <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" style="width: 100%;">Anmelden</button>
- </form>
-
- <div style="text-align: center; margin-top: 1rem;">
- <a href="<?php echo SITE_URL; ?>/index.php">Zurück zum Shop</a>
- </div>
- </div>
- </main>
- </body>
- </html>
|