This commit is contained in:
2026-06-08 17:07:17 +07:00
parent a8349a43af
commit afd656779f
14 changed files with 7510 additions and 1142 deletions
-21
View File
@@ -1,21 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
if ($id <= 0) {
echo json_encode(["status" => "error", "message" => "ID tidak valid"]);
exit;
}
$sql = "DELETE FROM spbu WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>
-21
View File
@@ -1,21 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
if ($id <= 0) {
echo json_encode(["status" => "error", "message" => "ID tidak valid"]);
exit;
}
$sql = "DELETE FROM jalan WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>
-21
View File
@@ -1,21 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
if ($id <= 0) {
echo json_encode(["status" => "error", "message" => "ID tidak valid"]);
exit;
}
$sql = "DELETE FROM parsil WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>
-25
View File
@@ -1,25 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$sql = "SELECT * FROM spbu";
$result = $conn->query($sql);
if (!$result) {
echo json_encode([
"status" => "error",
"message" => "Gagal membaca tabel spbu",
"detail" => $conn->error
]);
exit;
}
$data = [];
while($row = $result->fetch_assoc()){
$data[] = $row;
}
echo json_encode($data);
?>
-25
View File
@@ -1,25 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$sql = "SELECT * FROM jalan";
$result = $conn->query($sql);
if (!$result) {
echo json_encode([
"status" => "error",
"message" => "Gagal membaca tabel jalan",
"detail" => $conn->error
]);
exit;
}
$data = [];
while($row = $result->fetch_assoc()){
$data[] = $row;
}
echo json_encode($data);
?>
-25
View File
@@ -1,25 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$sql = "SELECT * FROM parsil";
$result = $conn->query($sql);
if (!$result) {
echo json_encode([
"status" => "error",
"message" => "Gagal membaca tabel parsil",
"detail" => $conn->error
]);
exit;
}
$data = [];
while($row = $result->fetch_assoc()){
$data[] = $row;
}
echo json_encode($data);
?>
-53
View File
@@ -1,53 +0,0 @@
<?php
ini_set('display_errors', 0);
error_reporting(0);
ob_start();
include "db_config.php";
header('Content-Type: application/json');
$raw = file_get_contents("php://input");
$data = json_decode($raw, true);
$nama = $data['nama'] ?? '';
$no = $data['no'] ?? '';
$status = $data['status'] ?? 'Tidak';
$lat = floatval($data['lat'] ?? 0);
$lng = floatval($data['lng'] ?? 0);
if(!$nama || !$no) {
ob_clean();
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
exit;
}
try {
$stmt = $conn->prepare("INSERT INTO spbu (nama,no,status,lat,lng) VALUES (?,?,?,?,?)");
if(!$stmt) {
$err = $conn->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU PREPARE ERR: $err\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]);
exit;
}
$stmt->bind_param("sssdd", $nama, $no, $status, $lat, $lng);
if($stmt->execute()){
$id = $stmt->insert_id;
ob_clean();
echo json_encode(["status"=>"success","id"=>$id]);
} else {
$err = $stmt->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU EXEC ERR: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]);
}
$stmt->close();
} catch (Exception $e) {
$err = $e->getMessage();
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU EXCEPTION: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]);
}
?>
-59
View File
@@ -1,59 +0,0 @@
<?php
ini_set('display_errors', 0);
error_reporting(0);
ob_start();
include "db_config.php";
header('Content-Type: application/json');
$raw = file_get_contents("php://input");
$data = json_decode($raw, true);
$nama = $data['nama'] ?? '';
$status = $data['status'] ?? 'Kabupaten';
$panjang = floatval($data['panjang'] ?? 0);
$koordinatInput = $data['koordinat'] ?? [];
if (is_string($koordinatInput)) {
$decoded = json_decode($koordinatInput, true);
$koordinat = (json_last_error() === JSON_ERROR_NONE) ? json_encode($decoded) : '[]';
} else {
$koordinat = json_encode($koordinatInput);
}
if(!$nama) {
ob_clean();
echo json_encode(["status" => "error", "message" => "Nama tidak boleh kosong"]);
exit;
}
try {
$stmt = $conn->prepare("INSERT INTO jalan (nama,status,panjang,koordinat) VALUES (?,?,?,?)");
if(!$stmt) {
$err = $conn->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN PREPARE ERR: $err\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]);
exit;
}
$stmt->bind_param("ssds", $nama, $status, $panjang, $koordinat);
if($stmt->execute()){
$id = $stmt->insert_id;
ob_clean();
echo json_encode(["status"=>"success","id"=>$id]);
} else {
$err = $stmt->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN EXEC ERR: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]);
}
$stmt->close();
} catch (Exception $e) {
$err = $e->getMessage();
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN EXCEPTION: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]);
}
?>
-60
View File
@@ -1,60 +0,0 @@
<?php
ini_set('display_errors', 0);
error_reporting(0);
ob_start();
include "db_config.php";
header('Content-Type: application/json');
$raw = file_get_contents("php://input");
$data = json_decode($raw, true);
$nama = $data['nama'] ?? '';
$pemilik = $data['pemilik'] ?? '';
$status = $data['status'] ?? 'SHM';
$luas = floatval($data['luas'] ?? 0);
$koordinatInput = $data['koordinat'] ?? [];
if (is_string($koordinatInput)) {
$decoded = json_decode($koordinatInput, true);
$koordinat = (json_last_error() === JSON_ERROR_NONE) ? json_encode($decoded) : '[]';
} else {
$koordinat = json_encode($koordinatInput);
}
if(!$nama) {
ob_clean();
echo json_encode(["status" => "error", "message" => "Nama tidak boleh kosong"]);
exit;
}
try {
$stmt = $conn->prepare("INSERT INTO parsil (nama, pemilik, status, luas, koordinat) VALUES (?,?,?,?,?)");
if(!$stmt) {
$err = $conn->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL PREPARE ERR: $err\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]);
exit;
}
$stmt->bind_param("sssds", $nama, $pemilik, $status, $luas, $koordinat);
if($stmt->execute()){
$id = $stmt->insert_id;
ob_clean();
echo json_encode(["status"=>"success","id"=>$id]);
} else {
$err = $stmt->error;
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL EXEC ERR: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]);
}
$stmt->close();
} catch (Exception $e) {
$err = $e->getMessage();
file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL EXCEPTION: $err | Payload: $raw\n", FILE_APPEND);
ob_clean();
echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]);
}
?>
-27
View File
@@ -1,27 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
$nama = $conn->real_escape_string($data['nama'] ?? '');
$no = $conn->real_escape_string($data['no'] ?? '');
$status = $conn->real_escape_string($data['status'] ?? 'Tidak');
$lat = isset($data['lat']) ? floatval($data['lat']) : 0;
$lng = isset($data['lng']) ? floatval($data['lng']) : 0;
if ($id <= 0 || $nama === '' || $no === '') {
echo json_encode(["status" => "error", "message" => "Data tidak valid"]);
exit;
}
$sql = "UPDATE spbu SET nama='$nama', no='$no', status='$status', lat='$lat', lng='$lng' WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>
-35
View File
@@ -1,35 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
$nama = $conn->real_escape_string($data['nama'] ?? '');
$status = $conn->real_escape_string($data['status'] ?? 'Kabupaten');
$panjang = isset($data['panjang']) ? floatval($data['panjang']) : 0;
$koordinatInput = $data['koordinat'] ?? [];
if ($id <= 0 || $nama === '') {
echo json_encode(["status" => "error", "message" => "Data tidak valid"]);
exit;
}
if (is_string($koordinatInput)) {
$decoded = json_decode($koordinatInput, true);
$koordinat = (json_last_error() === JSON_ERROR_NONE) ? json_encode($decoded) : '[]';
} else {
$koordinat = json_encode($koordinatInput);
}
$koordinat = $conn->real_escape_string($koordinat);
$sql = "UPDATE jalan SET nama='$nama', status='$status', panjang='$panjang', koordinat='$koordinat' WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>
-36
View File
@@ -1,36 +0,0 @@
<?php
include "db_config.php";
header('Content-Type: application/json');
$data = json_decode(file_get_contents("php://input"), true);
$id = isset($data['id']) ? intval($data['id']) : 0;
$nama = $conn->real_escape_string($data['nama'] ?? '');
$pemilik = $conn->real_escape_string($data['pemilik'] ?? '');
$status = $conn->real_escape_string($data['status'] ?? 'SHM');
$luas = isset($data['luas']) ? floatval($data['luas']) : 0;
$koordinatInput = $data['koordinat'] ?? [];
if ($id <= 0 || $nama === '') {
echo json_encode(["status" => "error", "message" => "Data tidak valid"]);
exit;
}
if (is_string($koordinatInput)) {
$decoded = json_decode($koordinatInput, true);
$koordinat = (json_last_error() === JSON_ERROR_NONE) ? json_encode($decoded) : '[]';
} else {
$koordinat = json_encode($koordinatInput);
}
$koordinat = $conn->real_escape_string($koordinat);
$sql = "UPDATE parsil SET nama='$nama', pemilik='$pemilik', status='$status', luas='$luas', koordinat='$koordinat' WHERE id=$id";
if ($conn->query($sql)) {
echo json_encode(["status" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => $conn->error]);
}
?>