first commit

This commit is contained in:
2026-06-11 21:14:16 +07:00
parent b08a058a34
commit 027f1cc26b
28 changed files with 3428 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
include 'koneksi.php';
$nama = trim($_POST['nama'] ?? '');
$nomor = trim($_POST['no'] ?? '');
$status = trim($_POST['status'] ?? '');
$latitudeRaw = $_POST['lat'] ?? null;
$longitudeRaw = $_POST['lng'] ?? null;
$latitude = is_numeric($latitudeRaw) ? (float) $latitudeRaw : null;
$longitude = is_numeric($longitudeRaw) ? (float) $longitudeRaw : null;
$allowedStatus = ['24jam', 'tidak'];
if ($nama === '' || $nomor === '' || !in_array($status, $allowedStatus, true) || $latitude === null || $longitude === null) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"INSERT INTO spbu (nama, no_spbu, status, latitude, longitude) VALUES (?, ?, ?, ?, ?)"
);
mysqli_stmt_bind_param($statement, "sssdd", $nama, $nomor, $status, $latitude, $longitude);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
include 'koneksi.php';
$namaKepalaKeluarga = trim($_POST['nama_kepala_keluarga'] ?? '');
$jumlahKkRaw = $_POST['jumlah_kk'] ?? null;
$jumlahKk = filter_var($jumlahKkRaw, FILTER_VALIDATE_INT);
$alamat = trim($_POST['alamat'] ?? '');
$latitudeRaw = $_POST['lat'] ?? null;
$longitudeRaw = $_POST['lng'] ?? null;
$latitude = is_numeric($latitudeRaw) ? (float) $latitudeRaw : null;
$longitude = is_numeric($longitudeRaw) ? (float) $longitudeRaw : null;
if ($namaKepalaKeluarga === '' || $alamat === '' || $jumlahKk === false || $jumlahKk === null || $jumlahKk < 1 || $latitude === null || $longitude === null) {
http_response_code(400);
exit('error');
}
$statement = null;
try {
$statement = mysqli_prepare(
$conn,
"INSERT INTO kemiskinan (nama_kepala_keluarga, jumlah_kk, alamat, latitude, longitude) VALUES (?, ?, ?, ?, ?)"
);
mysqli_stmt_bind_param($statement, "sisdd", $namaKepalaKeluarga, $jumlahKk, $alamat, $latitude, $longitude);
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
if ($statement) {
mysqli_stmt_close($statement);
}
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
include 'koneksi.php';
$nama = trim($_POST['nama'] ?? '');
$status = trim($_POST['status'] ?? '');
$panjangRaw = $_POST['panjang'] ?? null;
$panjang = is_numeric($panjangRaw) ? (float) $panjangRaw : null;
$geom = trim($_POST['geom'] ?? '');
$allowedStatus = ['Jalan Nasional', 'Jalan Provinsi', 'Jalan Kabupaten'];
if ($nama === '' || $geom === '' || !in_array($status, $allowedStatus, true) || $panjang === null) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"INSERT INTO jalan (nama, status, panjang, geom) VALUES (?, ?, ?, ?)"
);
mysqli_stmt_bind_param($statement, "ssds", $nama, $status, $panjang, $geom);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+43
View File
@@ -0,0 +1,43 @@
<?php
include 'koneksi.php';
$namaMasjid = trim($_POST['nama_masjid'] ?? '');
$picMasjid = trim($_POST['pic_masjid'] ?? '');
$alamat = trim($_POST['alamat'] ?? '');
$latitudeRaw = $_POST['lat'] ?? null;
$longitudeRaw = $_POST['lng'] ?? null;
$radiusRaw = $_POST['radius'] ?? 500;
$latitude = is_numeric($latitudeRaw) ? (float) $latitudeRaw : null;
$longitude = is_numeric($longitudeRaw) ? (float) $longitudeRaw : null;
$radius = is_numeric($radiusRaw) ? (float) $radiusRaw : null;
if ($namaMasjid === '' || $picMasjid === '' || $alamat === '' || $latitude === null || $longitude === null || $radius === null || $radius < 100 || $radius > 5000) {
http_response_code(400);
exit('error');
}
$statement = null;
try {
$statement = mysqli_prepare(
$conn,
"INSERT INTO masjid (nama_masjid, pic_masjid, alamat, latitude, longitude, radius) VALUES (?, ?, ?, ?, ?, ?)"
);
mysqli_stmt_bind_param($statement, "sssddd", $namaMasjid, $picMasjid, $alamat, $latitude, $longitude, $radius);
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
if ($statement) {
mysqli_stmt_close($statement);
}
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
include 'koneksi.php';
$nama = trim($_POST['nama'] ?? '');
$status = trim($_POST['status'] ?? '');
$luasRaw = $_POST['luas'] ?? null;
$luas = is_numeric($luasRaw) ? (float) $luasRaw : null;
$geom = trim($_POST['geom'] ?? '');
$allowedStatus = ['SHM', 'HGB', 'HGU', 'HP'];
if ($nama === '' || $geom === '' || !in_array($status, $allowedStatus, true) || $luas === null) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"INSERT INTO kavling (nama, status, luas, geom) VALUES (?, ?, ?, ?)"
);
mysqli_stmt_bind_param($statement, "ssds", $nama, $status, $luas, $geom);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
if ($id === false || $id === null || $id <= 0) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "DELETE FROM spbu WHERE id = ?");
mysqli_stmt_bind_param($statement, "i", $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
if ($id === false || $id === null || $id <= 0) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "DELETE FROM kemiskinan WHERE id = ?");
mysqli_stmt_bind_param($statement, "i", $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
if ($id === false || $id === null || $id <= 0) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "DELETE FROM jalan WHERE id = ?");
mysqli_stmt_bind_param($statement, "i", $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
if ($id === false || $id === null || $id <= 0) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "DELETE FROM masjid WHERE id = ?");
mysqli_stmt_bind_param($statement, "i", $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+28
View File
@@ -0,0 +1,28 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
if ($id === false || $id === null || $id <= 0) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "DELETE FROM kavling WHERE id = ?");
mysqli_stmt_bind_param($statement, "i", $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
$conn = mysqli_connect("127.0.0.1", "root", "", "webgis_spbu");
if (!$conn) {
die("Koneksi gagal: " . mysqli_connect_error());
}
mysqli_set_charset($conn, "utf8mb4");
$bootstrapQueries = [
"CREATE TABLE IF NOT EXISTS kemiskinan (
id INT AUTO_INCREMENT PRIMARY KEY,
nama_kepala_keluarga VARCHAR(150) NOT NULL,
jumlah_kk INT NOT NULL,
alamat TEXT NOT NULL,
latitude DOUBLE NOT NULL,
longitude DOUBLE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)",
"CREATE TABLE IF NOT EXISTS masjid (
id INT AUTO_INCREMENT PRIMARY KEY,
nama_masjid VARCHAR(150) NOT NULL,
pic_masjid VARCHAR(150) NOT NULL,
alamat TEXT NOT NULL,
latitude DOUBLE NOT NULL,
longitude DOUBLE NOT NULL,
radius DOUBLE NOT NULL DEFAULT 500,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)"
];
foreach ($bootstrapQueries as $query) {
mysqli_query($conn, $query);
}
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json; charset=utf-8');
$query = "SELECT * FROM spbu ORDER BY id DESC";
$result = mysqli_query($conn, $query);
$data = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
}
echo json_encode($data);
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json; charset=utf-8');
$query = "SELECT * FROM kemiskinan ORDER BY id DESC";
$result = mysqli_query($conn, $query);
$data = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
}
echo json_encode($data);
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json; charset=utf-8');
$query = "SELECT * FROM jalan ORDER BY id DESC";
$result = mysqli_query($conn, $query);
$data = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
}
echo json_encode($data);
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json; charset=utf-8');
$query = "SELECT * FROM masjid ORDER BY id DESC";
$result = mysqli_query($conn, $query);
$data = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
}
echo json_encode($data);
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json; charset=utf-8');
$query = "SELECT * FROM kavling ORDER BY id DESC";
$result = mysqli_query($conn, $query);
$data = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
}
echo json_encode($data);
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$nama = trim($_POST['nama'] ?? '');
$nomor = trim($_POST['no'] ?? '');
$status = trim($_POST['status'] ?? '');
$allowedStatus = ['24jam', 'tidak'];
if ($id === false || $id === null || $id <= 0 || $nama === '' || $nomor === '' || !in_array($status, $allowedStatus, true)) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"UPDATE spbu SET nama = ?, no_spbu = ?, status = ? WHERE id = ?"
);
mysqli_stmt_bind_param($statement, "sssi", $nama, $nomor, $status, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$namaKepalaKeluarga = trim($_POST['nama_kepala_keluarga'] ?? '');
$jumlahKkRaw = $_POST['jumlah_kk'] ?? null;
$jumlahKk = filter_var($jumlahKkRaw, FILTER_VALIDATE_INT);
$alamat = trim($_POST['alamat'] ?? '');
if ($id === false || $id === null || $id <= 0 || $namaKepalaKeluarga === '' || $jumlahKk === false || $jumlahKk === null || $jumlahKk < 1 || $alamat === '') {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"UPDATE kemiskinan SET nama_kepala_keluarga = ?, jumlah_kk = ?, alamat = ? WHERE id = ?"
);
mysqli_stmt_bind_param($statement, "sisi", $namaKepalaKeluarga, $jumlahKk, $alamat, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$nama = trim($_POST['nama'] ?? '');
$status = trim($_POST['status'] ?? '');
$allowedStatus = ['Jalan Nasional', 'Jalan Provinsi', 'Jalan Kabupaten'];
if ($id === false || $id === null || $id <= 0 || $nama === '' || !in_array($status, $allowedStatus, true)) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"UPDATE jalan SET nama = ?, status = ? WHERE id = ?"
);
mysqli_stmt_bind_param($statement, "ssi", $nama, $status, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$namaMasjid = trim($_POST['nama_masjid'] ?? '');
$picMasjid = trim($_POST['pic_masjid'] ?? '');
$alamat = trim($_POST['alamat'] ?? '');
$radiusRaw = $_POST['radius'] ?? null;
$radius = is_numeric($radiusRaw) ? (float) $radiusRaw : null;
if ($id === false || $id === null || $id <= 0 || $namaMasjid === '' || $picMasjid === '' || $alamat === '' || $radius === null || $radius < 100 || $radius > 5000) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"UPDATE masjid SET nama_masjid = ?, pic_masjid = ?, alamat = ?, radius = ? WHERE id = ?"
);
mysqli_stmt_bind_param($statement, "sssdi", $namaMasjid, $picMasjid, $alamat, $radius, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$radiusRaw = $_POST['radius'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$radius = is_numeric($radiusRaw) ? (float) $radiusRaw : null;
if ($id === false || $id === null || $id <= 0 || $radius === null || $radius < 100 || $radius > 5000) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare($conn, "UPDATE masjid SET radius = ? WHERE id = ?");
mysqli_stmt_bind_param($statement, "di", $radius, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>
+35
View File
@@ -0,0 +1,35 @@
<?php
include 'koneksi.php';
$idRaw = $_POST['id'] ?? null;
$id = filter_var($idRaw, FILTER_VALIDATE_INT);
$nama = trim($_POST['nama'] ?? '');
$status = trim($_POST['status'] ?? '');
$allowedStatus = ['SHM', 'HGB', 'HGU', 'HP'];
if ($id === false || $id === null || $id <= 0 || $nama === '' || !in_array($status, $allowedStatus, true)) {
http_response_code(400);
exit('error');
}
$statement = mysqli_prepare(
$conn,
"UPDATE kavling SET nama = ?, status = ? WHERE id = ?"
);
mysqli_stmt_bind_param($statement, "ssi", $nama, $status, $id);
try {
if (mysqli_stmt_execute($statement)) {
echo 'success';
} else {
http_response_code(500);
echo 'error';
}
} catch (mysqli_sql_exception $exception) {
http_response_code(500);
echo 'error: ' . $exception->getMessage();
}
mysqli_stmt_close($statement);
?>