62 lines
2.4 KiB
PHP
62 lines
2.4 KiB
PHP
<?php
|
|
require_once '../init.php';
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$password = $_POST['password'] ?? '';
|
|
if ($password === ADMIN_PASSWORD) {
|
|
$_SESSION['admin_logged_in'] = true;
|
|
logAction($pdo, 'Login', 'Admin logged in successfully');
|
|
header("Location: index.php");
|
|
exit;
|
|
} else {
|
|
$error = 'รหัสผ่านไม่ถูกต้อง';
|
|
logAction($pdo, 'Login Failed', 'Failed login attempt with incorrect password');
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>เข้าสู่ระบบจัดการ - <?= htmlspecialchars($globalSettings['site_name'] ?? 'ศูนย์รวมเว็บหน่วยงาน') ?></title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
</head>
|
|
<body class="antialiased min-h-screen flex items-center justify-center p-4">
|
|
|
|
<div class="w-full max-w-md glass-container">
|
|
|
|
<div class="text-center mb-8">
|
|
<h1 class="text-2xl font-bold text-gray-800 mb-2">ระบบจัดการหลังบ้าน</h1>
|
|
<p class="text-gray-600">กรุณาระบุรหัสผ่านเพื่อเข้าใช้งาน</p>
|
|
</div>
|
|
|
|
<?php if($error): ?>
|
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4 text-center">
|
|
<?= $error ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" action="">
|
|
<div class="mb-6">
|
|
<input type="password" name="password" class="magic-input" placeholder="รหัสผ่าน" required autofocus>
|
|
</div>
|
|
<button type="submit" class="magic-btn w-full">
|
|
<i class="fa-solid fa-right-to-bracket mr-2"></i> เข้าสู่ระบบ
|
|
</button>
|
|
</form>
|
|
|
|
<div class="mt-6 text-center">
|
|
<a href="../index.php" class="text-emerald-600 hover:text-emerald-800 text-sm">
|
|
<i class="fa-solid fa-arrow-left mr-1"></i> กลับไปหน้าหลัก
|
|
</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|