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:
2026-06-10 17:44:46 +07:00
parent c6087ed7dd
commit e98a8ecec9
34 changed files with 963 additions and 211 deletions
+36 -12
View File
@@ -1,23 +1,47 @@
<?php
session_start();
include '../php/db.php';
// Kredensial Admin — bisa diganti sesuai kebutuhan
$ADMIN_USER = 'admin';
$ADMIN_PASS = 'admin123';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = $_POST['username'] ?? '';
$user = trim($_POST['username'] ?? '');
$pass = $_POST['password'] ?? '';
if ($user === $ADMIN_USER && $pass === $ADMIN_PASS) {
$_SESSION['is_admin'] = true;
header('Location: admin.php');
exit;
$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';
if ($account['role'] === 'admin') {
header('Location: admin.php');
} else {
header('Location: index.php');
}
exit;
}
$error = 'Username atau password salah.';
$stmt->close();
}
}
if (isset($conn)) {
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="id">
@@ -182,12 +206,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="login-logo-icon">🕌</div>
<div>
<div class="login-logo-text">WEB<span>GIS</span> SOSIAL</div>
<div class="login-logo-sub">Portal Administrasi</div>
<div class="login-logo-sub">Portal Pengguna</div>
</div>
</div>
<h1>🔐 Masuk sebagai Admin</h1>
<p class="login-desc">Halaman ini khusus untuk petugas yang berwenang mengelola data penduduk dan masjid.</p>
<h1>🔐 Masuk Pengguna</h1>
<p class="login-desc">Gunakan akun sesuai role untuk mengakses dashboard publik atau panel pengelolaan data.</p>
<?php if ($error): ?>
<div class="error-msg">⚠️ <?= htmlspecialchars($error) ?></div>
@@ -200,7 +224,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="••••••••" required>
<button type="submit" class="btn-login">Masuk ke Panel Admin →</button>
<button type="submit" class="btn-login">Masuk →</button>
</form>
<a href="index.php" class="back-link">← Kembali ke Dashboard Publik</a>