From bb501dcd8b29ed74ca6f258d9589185ea3243870 Mon Sep 17 00:00:00 2001 From: Joscelind Date: Tue, 9 Jun 2026 13:50:00 +0700 Subject: [PATCH] First Commit --- 01/ambil.php | 112 ++++ 01/index.html | 146 +++++ 01/index.php | 414 +++++++++++++++ 01/koneksi.php | 12 + 02/ambil.php | 215 ++++++++ 02/buat_akun.php | 68 +++ 02/index.html | 146 +++++ 02/index.php | 1231 +++++++++++++++++++++++++++++++++++++++++++ 02/koneksi.php | 12 + 02/login.php | 153 ++++++ 02/logout.php | 7 + 02/proses_login.php | 41 ++ 12 files changed, 2557 insertions(+) create mode 100644 01/ambil.php create mode 100644 01/index.html create mode 100644 01/index.php create mode 100644 01/koneksi.php create mode 100644 02/ambil.php create mode 100644 02/buat_akun.php create mode 100644 02/index.html create mode 100644 02/index.php create mode 100644 02/koneksi.php create mode 100644 02/login.php create mode 100644 02/logout.php create mode 100644 02/proses_login.php diff --git a/01/ambil.php b/01/ambil.php new file mode 100644 index 0000000..9fa050c --- /dev/null +++ b/01/ambil.php @@ -0,0 +1,112 @@ + [], 'jalan' => [], 'parsil' => []]; + + // Ambil SPBU + $q_spbu = mysqli_query($conn, "SELECT * FROM spbu"); + while($r = mysqli_fetch_assoc($q_spbu)) { + $r['latitude'] = (float)$r['latitude']; + $r['longitude'] = (float)$r['longitude']; + $data['spbu'][] = $r; + } + + // Ambil Jalan + $q_jalan = mysqli_query($conn, "SELECT * FROM data_jalan"); + while($r = mysqli_fetch_assoc($q_jalan)) $data['jalan'][] = $r; + + // Ambil Parsil + $q_parsil = mysqli_query($conn, "SELECT * FROM data_parsil"); + while($r = mysqli_fetch_assoc($q_parsil)) $data['parsil'][] = $r; + + header('Content-Type: application/json'); + echo json_encode($data); +} +?> \ No newline at end of file diff --git a/01/index.html b/01/index.html new file mode 100644 index 0000000..9fafd5a --- /dev/null +++ b/01/index.html @@ -0,0 +1,146 @@ + + + + + + Web GIS Pontianak - SPBU, Jalan & Parsil + + + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/01/index.php b/01/index.php new file mode 100644 index 0000000..628fe31 --- /dev/null +++ b/01/index.php @@ -0,0 +1,414 @@ + + + + WebGIS SPBU, Jalan & Parsil Pontianak + + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/01/koneksi.php b/01/koneksi.php new file mode 100644 index 0000000..c3ff981 --- /dev/null +++ b/01/koneksi.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/02/ambil.php b/02/ambil.php new file mode 100644 index 0000000..f324628 --- /dev/null +++ b/02/ambil.php @@ -0,0 +1,215 @@ + "success"]); + } else { + echo json_encode(["status" => "error", "message" => mysqli_error($conn)]); + } + exit; + } +} + +// --- LOGIKA AMBIL DATA (METODE GET) --- +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $data = ['spbu' => [], 'jalan' => [], 'parsil' => []]; + + // Ambil SPBU + $q_spbu = mysqli_query($conn, "SELECT * FROM spbu"); + while($r = mysqli_fetch_assoc($q_spbu)) { + $r['latitude'] = (float)$r['latitude']; + $r['longitude'] = (float)$r['longitude']; + $data['spbu'][] = $r; + } + + // Ambil Jalan + $q_jalan = mysqli_query($conn, "SELECT * FROM data_jalan"); + while($r = mysqli_fetch_assoc($q_jalan)) $data['jalan'][] = $r; + + // Ambil Parsil + $q_parsil = mysqli_query($conn, "SELECT * FROM data_parsil"); + while($r = mysqli_fetch_assoc($q_parsil)) $data['parsil'][] = $r; + + // Ambil Rumah Ibadah + $q_ibadah = mysqli_query($conn, "SELECT * FROM rumah_ibadah"); + if($q_ibadah) { + $data['rumah_ibadah'] = []; + while($r = mysqli_fetch_assoc($q_ibadah)) { + $r['latitude'] = (float)$r['latitude']; + $r['longitude'] = (float)$r['longitude']; + $r['radius_meter'] = (int)$r['radius_meter']; + $data['rumah_ibadah'][] = $r; + } + } + + // Ambil Penduduk Miskin + $q_penduduk = mysqli_query($conn, "SELECT * FROM penduduk_miskin"); + if($q_penduduk) { + $data['penduduk_miskin'] = []; + while($r = mysqli_fetch_assoc($q_penduduk)) { + $r['latitude'] = (float)$r['latitude']; + $r['longitude'] = (float)$r['longitude']; + + // Ambil histori bantuan untuk penduduk ini + $p_id = $r['id']; + $r['histori_bantuan'] = []; + $q_histori = mysqli_query($conn, "SELECT tanggal, deskripsi_bantuan FROM histori_bantuan WHERE penduduk_id = '$p_id' ORDER BY tanggal DESC"); + if ($q_histori) { + while($h = mysqli_fetch_assoc($q_histori)) { + $r['histori_bantuan'][] = $h; + } + } + + $data['penduduk_miskin'][] = $r; + } + } + + header('Content-Type: application/json'); + echo json_encode($data); +} +?> \ No newline at end of file diff --git a/02/buat_akun.php b/02/buat_akun.php new file mode 100644 index 0000000..54aca61 --- /dev/null +++ b/02/buat_akun.php @@ -0,0 +1,68 @@ + 'admin', + 'password' => password_hash('admin123', PASSWORD_DEFAULT), + 'role' => 'Admin', + 'ibadah_id' => 'NULL' + ], + [ + 'username' => 'walikota', + 'password' => password_hash('walikota123', PASSWORD_DEFAULT), + 'role' => 'Walikota', + 'ibadah_id' => 'NULL' + ], + [ + 'username' => 'HKBP', + 'password' => password_hash('HKBP123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '1' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ], + [ + 'username' => 'klenteng', + 'password' => password_hash('klenteng123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '4' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ], + [ + 'username' => 'pura', + 'password' => password_hash('pura123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '5' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ], + [ + 'username' => 'vihara', + 'password' => password_hash('vihara123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '6' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ], + [ + 'username' => 'gereja', + 'password' => password_hash('gereja123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '7' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ], + [ + 'username' => 'masjid', + 'password' => password_hash('masjid123', PASSWORD_DEFAULT), + 'role' => 'Rumah_Ibadah', + 'ibadah_id' => '8' // Pastikan ID 1 benar-benar ada di tabel rumah_ibadah Anda! + ] +]; + +// 2. Masukkan ke database +foreach ($akun as $a) { + $ibadah = $a['ibadah_id']; + $sql = "INSERT INTO users (username, password, role, ibadah_id) + VALUES ('{$a['username']}', '{$a['password']}', '{$a['role']}', $ibadah)"; + + if (mysqli_query($conn, $sql)) { + echo "Akun {$a['username']} berhasil dibuat!
"; + } else { + echo "Gagal membuat {$a['username']}: " . mysqli_error($conn) . "
"; + } +} +?> \ No newline at end of file diff --git a/02/index.html b/02/index.html new file mode 100644 index 0000000..9fafd5a --- /dev/null +++ b/02/index.html @@ -0,0 +1,146 @@ + + + + + + Web GIS Pontianak - SPBU, Jalan & Parsil + + + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/02/index.php b/02/index.php new file mode 100644 index 0000000..2eaa4a8 --- /dev/null +++ b/02/index.php @@ -0,0 +1,1231 @@ + + + + + WebGIS SPBU, Jalan & Parsil Pontianak + + + + + + + + + + +
+ + + +
+ Halo, + πŸšͺ Logout +
+ + + + + + + + +
+ + + + + + + + +
+
+ + + + + + + + + \ No newline at end of file diff --git a/02/koneksi.php b/02/koneksi.php new file mode 100644 index 0000000..c3ff981 --- /dev/null +++ b/02/koneksi.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/02/login.php b/02/login.php new file mode 100644 index 0000000..330e80f --- /dev/null +++ b/02/login.php @@ -0,0 +1,153 @@ + 0) { + $user = mysqli_fetch_assoc($result); + + // Verifikasi password hash + if (password_verify($password, $user['password'])) { + // Set session + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + $_SESSION['ibadah_id'] = $user['ibadah_id']; // Bisa null untuk Admin/Walikota + + header("Location: index.php"); + exit; + } else { + $error = "Password salah!"; + } + } else { + $error = "Username tidak ditemukan!"; + } +} +?> + + + + + + Login WebGIS + + + + +
+

πŸ” WebGIS Login

+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ + +
+
+ + + diff --git a/02/logout.php b/02/logout.php new file mode 100644 index 0000000..99aadf2 --- /dev/null +++ b/02/logout.php @@ -0,0 +1,7 @@ + diff --git a/02/proses_login.php b/02/proses_login.php new file mode 100644 index 0000000..275d1ba --- /dev/null +++ b/02/proses_login.php @@ -0,0 +1,41 @@ + 0) { + $user = mysqli_fetch_assoc($result); + + // Verifikasi password hash + if (password_verify($password, $user['password'])) { + // Set session + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + $_SESSION['ibadah_id'] = $user['ibadah_id']; + + // Redirect kembali ke halaman utama jika berhasil + header("Location: index.php"); + exit; + } else { + // Password salah + header("Location: index.php?error=1"); + exit; + } + } else { + // Username tidak ditemukan + header("Location: index.php?error=1"); + exit; + } +} else { + // Jika diakses langsung tanpa POST form + header("Location: index.php"); + exit; +} +?>