update sistem proyek menjadi lebih struktural. dimulai dengan memisahkan dashboard publik dan administrator pada setiap proyek, membuat dockerfile untuk setup environment docker, dan merapikan database serta membuat file migration.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
session_start();
|
||||
include '../php/db.php';
|
||||
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$user = trim($_POST['username'] ?? '');
|
||||
$pass = $_POST['password'] ?? '';
|
||||
|
||||
$stmt = $conn->prepare("SELECT id, username, password_hash, role, full_name, is_active FROM users WHERE username = ? LIMIT 1");
|
||||
if (!$stmt) {
|
||||
$error = 'Konfigurasi login belum siap. Jalankan migration database terlebih dahulu.';
|
||||
} else {
|
||||
$stmt->bind_param("s", $user);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$account = $result ? $result->fetch_assoc() : null;
|
||||
|
||||
if ($account && intval($account['is_active']) === 1 && password_verify($pass, $account['password_hash'])) {
|
||||
session_regenerate_id(true);
|
||||
$_SESSION['user_id'] = intval($account['id']);
|
||||
$_SESSION['username'] = $account['username'];
|
||||
$_SESSION['role'] = $account['role'];
|
||||
$_SESSION['full_name'] = $account['full_name'];
|
||||
$_SESSION['is_admin'] = $account['role'] === 'admin';
|
||||
|
||||
header('Location: ' . ($account['role'] === 'admin' ? 'admin.php' : 'index.php'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = 'Username atau password salah.';
|
||||
$stmt->close();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($conn)) {
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login Admin - WebGIS SPBU</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family:'DM Sans',sans-serif; background:#0a0d14; color:#e2e8f0; min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
|
||||
body::before { content:''; position:fixed; inset:0; background-image:linear-gradient(rgba(59,130,246,.04) 1px, transparent 1px),linear-gradient(90deg, rgba(59,130,246,.04) 1px, transparent 1px); background-size:40px 40px; }
|
||||
.login-card { position:relative; z-index:1; width:100%; max-width:380px; background:#1a1d27; border:1px solid #2a2d3a; border-radius:16px; padding:36px 32px; box-shadow:0 25px 60px rgba(0,0,0,.5); }
|
||||
.login-logo { display:flex; align-items:center; gap:12px; margin-bottom:28px; }
|
||||
.login-logo-icon { width:44px; height:44px; background:linear-gradient(135deg,#1d4ed8,#3b82f6); border-radius:12px; display:flex; align-items:center; justify-content:center; font-weight:700; }
|
||||
.login-logo-text { font-family:'Space Mono',monospace; font-size:14px; font-weight:700; letter-spacing:.05em; }
|
||||
.login-logo-text span { color:#60a5fa; }
|
||||
.login-logo-sub { font-size:11px; color:#6b7280; margin-top:1px; }
|
||||
h1 { font-size:20px; margin-bottom:6px; }
|
||||
.login-desc { font-size:13px; color:#6b7280; margin-bottom:24px; line-height:1.5; }
|
||||
label { display:block; font-size:11px; color:#9ca3af; font-weight:600; letter-spacing:.05em; text-transform:uppercase; margin-bottom:6px; margin-top:16px; }
|
||||
input { width:100%; background:#0f1117; border:1px solid #2a2d3a; color:#e2e8f0; border-radius:8px; padding:10px 14px; font-size:14px; font-family:'DM Sans',sans-serif; outline:none; }
|
||||
input:focus { border-color:#60a5fa; }
|
||||
.error-msg { background:rgba(239,68,68,.1); border:1px solid rgba(239,68,68,.3); color:#f87171; border-radius:8px; padding:10px 14px; font-size:13px; margin-top:16px; }
|
||||
.btn-login { width:100%; margin-top:24px; padding:12px; background:linear-gradient(135deg,#1d4ed8,#3b82f6); color:#fff; border:0; border-radius:8px; font-size:14px; font-weight:700; font-family:'DM Sans',sans-serif; cursor:pointer; }
|
||||
.back-link { display:block; text-align:center; margin-top:16px; font-size:12px; color:#6b7280; text-decoration:none; }
|
||||
.back-link:hover { color:#e2e8f0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-card">
|
||||
<div class="login-logo">
|
||||
<div class="login-logo-icon">S</div>
|
||||
<div>
|
||||
<div class="login-logo-text">WEB<span>GIS</span> SPBU</div>
|
||||
<div class="login-logo-sub">Portal Administrasi</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>Masuk Admin</h1>
|
||||
<p class="login-desc">Halaman ini khusus untuk pengelola data titik SPBU.</p>
|
||||
<?php if ($error): ?><div class="error-msg"><?= htmlspecialchars($error) ?></div><?php endif; ?>
|
||||
<form method="POST">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" placeholder="admin" autocomplete="off" required>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" placeholder="password" required>
|
||||
<button type="submit" class="btn-login">Masuk</button>
|
||||
</form>
|
||||
<a href="index.php" class="back-link">Kembali ke Dashboard Publik</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user