| <?php
|
| session_start();
|
| require '../db_connect.php';
|
|
|
| $error = '';
|
|
|
|
|
| if (isset($_GET['logout'])) {
|
| session_destroy();
|
| header('Location: login.php');
|
| exit;
|
| }
|
|
|
|
|
| if (isset($_SESSION['admin_logged_in'])) {
|
| header('Location: index.php');
|
| exit;
|
| }
|
|
|
|
|
| if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
| $password = $_POST['password'] ?? '';
|
|
|
| try {
|
| $stmt = $db->prepare("SELECT value_text FROM config WHERE key_name = 'admin_password'");
|
| $stmt->execute();
|
| $stored = $stmt->fetchColumn();
|
|
|
| if ($stored && password_verify($password, $stored)) {
|
| $_SESSION['admin_logged_in'] = true;
|
| header('Location: index.php');
|
| exit;
|
| } else {
|
| $error = 'Password non corretta';
|
| }
|
| } catch (Exception $e) {
|
| $error = 'Errore di sistema';
|
| }
|
| }
|
| ?>
|
| <!DOCTYPE html>
|
| <html lang="it">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>Login Admin — OFT MGMT</title>
|
| <link href="style.css" rel="stylesheet">
|
| <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
| </head>
|
| <body>
|
|
|
| <div class="login-page">
|
| <div class="login-card">
|
| <div class="brand" style="justify-content:center; margin-bottom:30px; font-size:24px">
|
| <span>⚡</span> OFT Admin
|
| </div>
|
|
|
| <?php if ($error): ?>
|
| <div style="background:rgba(239,68,68,0.1); color:var(--danger); padding:12px; border-radius:8px; font-size:14px; margin-bottom:20px; text-align:center; border:1px solid var(--danger)">
|
| <?php echo htmlspecialchars($error); ?>
|
| </div>
|
| <?php endif; ?>
|
|
|
| <form method="POST">
|
| <div class="form-group">
|
| <label>Password Amministratore</label>
|
| <input type="password" name="password" required placeholder="••••••••" style="text-align:center; letter-spacing:2px" autofocus>
|
| </div>
|
| <button type="submit" class="btn" style="width:100%; justify-content:center">Accedi</button>
|
| </form>
|
|
|
| <div style="text-align:center; margin-top:24px">
|
| <a href="../index.php" style="font-size:13px; color:var(--muted)">Torna al sito</a>
|
| </div>
|
| </div>
|
| </div>
|
|
|
| </body>
|
| </html>
|
| |