File size: 2,553 Bytes
36f2119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
session_start();
require '../db_connect.php';

$error = '';

// Handle logout
if (isset($_GET['logout'])) {
    session_destroy();
    header('Location: login.php');
    exit;
}

// Redirect if already logged in
if (isset($_SESSION['admin_logged_in'])) {
    header('Location: index.php');
    exit;
}

// Handle login
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>