37254-vm/login.php
Flatlogic Bot 6908213cbc init
2026-02-15 21:17:22 +00:00

64 lines
2.6 KiB
PHP

<?php
session_start();
require_once __DIR__ . '/cls/class.pef.php';
if (isset($_SESSION['user'])) {
header('Location: index.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pef = new Pef();
$user = $pef->login($_POST['username'] ?? '', $_POST['password'] ?? '');
if ($user) {
$_SESSION['user'] = $user;
header('Location: index.php');
exit;
} else {
$error = 'Invalid username or password.';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Construction & Education CMS</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; background: #f8fafc; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
.login-card { background: white; padding: 2.5rem; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); width: 100%; max-width: 400px; }
h1 { margin-top: 0; font-size: 1.5rem; color: #1e293b; text-align: center; }
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.875rem; font-weight: 500; color: #64748b; margin-bottom: 0.5rem; }
input { width: 100%; padding: 0.75rem; border: 1px solid #e2e8f0; border-radius: 6px; box-sizing: border-box; }
button { width: 100%; padding: 0.75rem; background: #3b82f6; color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; margin-top: 1rem; }
button:hover { background: #2563eb; }
.error { color: #ef4444; font-size: 0.875rem; text-align: center; margin-bottom: 1rem; }
.footer-note { text-align: center; margin-top: 1.5rem; font-size: 0.75rem; color: #94a3b8; }
</style>
</head>
<body>
<div class="login-card">
<h1>CMS Login</h1>
<?php if ($error): ?>
<div class="error"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" required autofocus>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" required>
</div>
<button type="submit">Sign In</button>
</form>
<div class="footer-note">Default: admin / admin123</div>
</div>
</body>
</html>