Compare commits
2 Commits
4cbbd3c718
...
7a6d552bad
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a6d552bad | |||
| d77596f62b |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
@@ -4,26 +4,17 @@
|
|||||||
// ============================================================
|
// ============================================================
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
$modul = $_GET['modul'] ?? 'utuh';
|
$modul = $_GET['modul'] ?? 'bantuan';
|
||||||
|
|
||||||
// TAHAP 1: Modul publik diizinkan tanpa login
|
// Aplikasi Kemiskinan Wajib Login Sepenuhnya
|
||||||
$public_modules = ['spbu', 'tematik', 'digitasi'];
|
if (!isset($_SESSION['user_id'])) {
|
||||||
$is_public_access = in_array($modul, $public_modules);
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
if ($is_public_access) {
|
|
||||||
// Jika akses publik, berikan role petugas agar pengunjung dapat mengedit data
|
|
||||||
$currentUser = $_SESSION['username'] ?? 'Pengunjung Kelas';
|
|
||||||
$currentRole = $_SESSION['role'] ?? 'petugas';
|
|
||||||
} else {
|
|
||||||
// Modul privat wajib login
|
|
||||||
if (!isset($_SESSION['user_id'])) {
|
|
||||||
header('Location: login.php');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$currentUser = $_SESSION['username'];
|
|
||||||
$currentRole = $_SESSION['role'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$currentUser = $_SESSION['username'];
|
||||||
|
$currentRole = $_SESSION['role'];
|
||||||
|
|
||||||
include 'koneksi.php';
|
include 'koneksi.php';
|
||||||
|
|
||||||
// Eksekusi ALTER TABLE secara diam-diam jika kolom belum ada
|
// Eksekusi ALTER TABLE secara diam-diam jika kolom belum ada
|
||||||
@@ -134,27 +134,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bottom / Public Shortcuts -->
|
<!-- Bottom / Features Info -->
|
||||||
<div>
|
<div class="mt-8">
|
||||||
<h2 class="mb-3 flex items-center gap-2 text-sm font-bold text-white/90">
|
<h2 class="mb-4 flex items-center gap-2 text-sm font-bold text-white/90 uppercase tracking-wider">
|
||||||
<svg viewBox="0 0 24 24" fill="none" class="h-4.5 w-4.5 text-rose-300" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
<svg viewBox="0 0 24 24" fill="none" class="h-5 w-5 text-rose-300" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path d="M2 12h4l2-9 5 18 3-10h4"></path>
|
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
Project Kelas (Akses Publik):
|
Sistem Pengamanan Tertutup
|
||||||
</h2>
|
</h2>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-4 text-white/80 text-sm">
|
||||||
<a href="index.php?modul=spbu" class="group flex items-center gap-3 rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm font-bold text-white transition-all hover:-translate-y-0.5 hover:border-white/30 hover:bg-white/20">
|
<div class="flex items-start gap-3">
|
||||||
<span class="text-xl transition-transform group-hover:scale-110">⛽</span>
|
<div class="mt-0.5 rounded-full bg-white/20 p-1"><svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg></div>
|
||||||
Peta Lokasi SPBU
|
<p><strong>Database Terpusat:</strong> Melacak data penduduk miskin berdasarkan NIK secara real-time.</p>
|
||||||
</a>
|
</div>
|
||||||
<a href="index.php?modul=tematik" class="group flex items-center gap-3 rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm font-bold text-white transition-all hover:-translate-y-0.5 hover:border-white/30 hover:bg-white/20">
|
<div class="flex items-start gap-3">
|
||||||
<span class="text-xl transition-transform group-hover:scale-110">🗺️</span>
|
<div class="mt-0.5 rounded-full bg-white/20 p-1"><svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg></div>
|
||||||
Peta Tematik
|
<p><strong>Tracking Bantuan:</strong> Verifikasi silang penyaluran BLT dan PKH di berbagai wilayah.</p>
|
||||||
</a>
|
</div>
|
||||||
<a href="index.php?modul=digitasi" class="group flex items-center gap-3 rounded-xl border border-white/10 bg-white/5 px-4 py-3 text-sm font-bold text-white transition-all hover:-translate-y-0.5 hover:border-white/30 hover:bg-white/20">
|
<div class="flex items-start gap-3">
|
||||||
<span class="text-xl transition-transform group-hover:scale-110">📐</span>
|
<div class="mt-0.5 rounded-full bg-white/20 p-1"><svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg></div>
|
||||||
Digitasi Lahan Kota
|
<p><strong>Analisis Spasial:</strong> Pemetaan kantong kemiskinan untuk kebijakan tepat sasaran.</p>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Before Width: | Height: | Size: 366 KiB After Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 366 KiB After Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 374 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
// ============================================================
|
||||||
|
// koneksi.php — Database Connection (PDO)
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
|
||||||
|
define('DB_USER', getenv('DB_USER') ?: 'root');
|
||||||
|
define('DB_PASS', getenv('DB_PASS') !== false ? getenv('DB_PASS') : '');
|
||||||
|
define('DB_NAME', getenv('DB_NAME') ?: 'webgis');
|
||||||
|
define('DB_CHARSET', 'utf8mb4');
|
||||||
|
|
||||||
|
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=' . DB_CHARSET;
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// AUTO-MIGRATION SCRIPT (Sesuai Permintaan)
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
// 1. Buat tabel users jika belum ada (fallback)
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
username VARCHAR(50) NOT NULL UNIQUE,
|
||||||
|
password VARCHAR(255) NOT NULL,
|
||||||
|
role ENUM('admin','petugas','guest') NOT NULL DEFAULT 'guest',
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB");
|
||||||
|
|
||||||
|
// 2. Cek dan tambahkan kolom baru pada tabel users
|
||||||
|
$columns = $pdo->query("SHOW COLUMNS FROM users")->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
if (!in_array('email', $columns)) {
|
||||||
|
$pdo->exec("ALTER TABLE users ADD COLUMN email VARCHAR(150) UNIQUE NULL AFTER username");
|
||||||
|
}
|
||||||
|
if (!in_array('nama_lengkap', $columns)) {
|
||||||
|
$pdo->exec("ALTER TABLE users ADD COLUMN nama_lengkap VARCHAR(150) NULL AFTER email");
|
||||||
|
}
|
||||||
|
if (!in_array('status', $columns)) {
|
||||||
|
// Update user lama menjadi active terlebih dahulu jika diperlukan, tapi defaultnya active
|
||||||
|
$pdo->exec("ALTER TABLE users ADD COLUMN status ENUM('pending', 'active') NOT NULL DEFAULT 'active' AFTER role");
|
||||||
|
}
|
||||||
|
if (!in_array('auth_provider', $columns)) {
|
||||||
|
$pdo->exec("ALTER TABLE users ADD COLUMN auth_provider ENUM('local', 'google') NOT NULL DEFAULT 'local' AFTER status");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Buat tabel settings
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS settings (
|
||||||
|
setting_key VARCHAR(50) PRIMARY KEY,
|
||||||
|
setting_value VARCHAR(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB");
|
||||||
|
|
||||||
|
// 4. Masukkan data default settings jika belum ada
|
||||||
|
$pdo->exec("INSERT IGNORE INTO settings (setting_key, setting_value) VALUES ('show_demo_accounts', '1')");
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
die(json_encode([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Koneksi database gagal: ' . $e->getMessage()
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy mysqli compatibility (untuk file yang masih menggunakannya)
|
||||||
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
|
if ($conn) {
|
||||||
|
mysqli_set_charset($conn, DB_CHARSET);
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Gitkeep
|
||||||
|
After Width: | Height: | Size: 366 KiB |
|
After Width: | Height: | Size: 366 KiB |
|
After Width: | Height: | Size: 374 KiB |