39199-vm/admin_login.php
Flatlogic Bot 270903d716 roni
2026-03-15 02:57:10 +00:00

90 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/includes/flash.php';
if (is_admin_logged_in()) {
header('Location: admin_dashboard.php');
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = trim($_POST['password'] ?? '');
if (login_admin($username, $password)) {
flash_set('success', 'Login berhasil. Selamat datang admin.');
header('Location: admin_dashboard.php');
exit;
}
flash_set('danger', 'Username atau password salah.');
header('Location: admin_login.php');
exit;
}
$flash = flash_get();
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Login Admin</title>
<?php if ($projectDescription): ?>
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
</head>
<body class="app-body">
<div class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-5">
<div class="card shadow-sm border-0">
<div class="card-body">
<h1 class="h4 fw-semibold mb-3">Login Admin</h1>
<p class="text-muted small">Gunakan kredensial admin untuk mengakses laporan pendaftar.</p>
<?php if ($flash): ?>
<div class="alert alert-<?= htmlspecialchars($flash['type']) ?> border-0 small">
<?= htmlspecialchars($flash['message']) ?>
</div>
<?php endif; ?>
<form method="post" class="needs-validation" novalidate>
<div class="mb-3">
<label class="form-label" for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
<div class="invalid-feedback">Username wajib diisi.</div>
</div>
<div class="mb-3">
<label class="form-label" for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
<div class="invalid-feedback">Password wajib diisi.</div>
</div>
<button type="submit" class="btn btn-dark w-100">Masuk</button>
</form>
<div class="border-top pt-3 mt-4 small text-muted">
Default demo: <strong>admin / admin123</strong>
</div>
</div>
</div>
<div class="text-center mt-3">
<a class="text-muted small" href="/">Kembali ke halaman utama</a>
</div>
</div>
</div>
</div>
</body>
</html>