update
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
|
||||
$host = "localhost";
|
||||
$user = "root";
|
||||
$pass = "fira123";
|
||||
$db = "webgis"; // Menggunakan database sendiri sesuai setup_webgis.sql
|
||||
|
||||
$conn = new mysqli($host, $user, $pass, $db);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Koneksi database gagal",
|
||||
"detail" => $conn->connect_error
|
||||
]));
|
||||
}
|
||||
|
||||
$conn->set_charset('utf8mb4');
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
include "db_config.php";
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$nama = $conn->real_escape_string($data['nama']);
|
||||
$no = $conn->real_escape_string($data['no']);
|
||||
$status = $conn->real_escape_string($data['status']);
|
||||
$alamat = isset($data['alamat']) ? $conn->real_escape_string($data['alamat']) : '';
|
||||
$lat = $data['lat'];
|
||||
$lng = $data['lng'];
|
||||
|
||||
$sql = "INSERT INTO spbu (nama,no,status,alamat,lat,lng)
|
||||
VALUES ('$nama','$no','$status','$alamat','$lat','$lng')";
|
||||
|
||||
if($conn->query($sql)){
|
||||
echo json_encode([
|
||||
"status"=>"success",
|
||||
"id"=>$conn->insert_id
|
||||
]);
|
||||
}else{
|
||||
echo json_encode(["status"=>"error", "msg"=>$conn->error]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "db_config.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$nama = $data['nama'];
|
||||
$status = $data['status'];
|
||||
$panjang = $data['panjang'];
|
||||
$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);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO jalan (nama,status,panjang,koordinat)
|
||||
VALUES ('$nama','$status','$panjang','$koordinat')";
|
||||
|
||||
if($conn->query($sql)){
|
||||
echo json_encode([
|
||||
"status"=>"success",
|
||||
"id"=>$conn->insert_id
|
||||
]);
|
||||
}else{
|
||||
echo json_encode([
|
||||
"status"=>"error",
|
||||
"error"=>$conn->error
|
||||
]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include "db_config.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$nama = $data['nama'];
|
||||
$pemilik = $data['pemilik'];
|
||||
$status = $data['status'];
|
||||
$luas = $data['luas'];
|
||||
$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);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO parsil
|
||||
(nama, pemilik, status, luas, koordinat)
|
||||
VALUES
|
||||
('$nama','$pemilik','$status','$luas','$koordinat')";
|
||||
|
||||
if($conn->query($sql)){
|
||||
echo json_encode([
|
||||
"status"=>"success",
|
||||
"id"=>$conn->insert_id
|
||||
]);
|
||||
}else{
|
||||
echo json_encode([
|
||||
"status"=>"error",
|
||||
"message"=>$conn->error
|
||||
]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,60 @@
|
||||
CREATE DATABASE IF NOT EXISTS webgis
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE webgis;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS spbu (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
nama VARCHAR(200) NOT NULL,
|
||||
no VARCHAR(60) NOT NULL,
|
||||
status ENUM('Ya','Tidak') NOT NULL DEFAULT 'Tidak',
|
||||
lat DECIMAL(10,7) NOT NULL,
|
||||
lng DECIMAL(10,7) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jalan (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
nama VARCHAR(200) NOT NULL,
|
||||
status ENUM('Nasional','Provinsi','Kabupaten') NOT NULL DEFAULT 'Kabupaten',
|
||||
panjang DECIMAL(12,2) NOT NULL DEFAULT 0,
|
||||
koordinat LONGTEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS parsil (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
nama VARCHAR(200) NOT NULL,
|
||||
pemilik VARCHAR(200) NOT NULL,
|
||||
status ENUM('SHM','HGB','Sewa','Lainnya') NOT NULL DEFAULT 'SHM',
|
||||
luas DECIMAL(14,2) NOT NULL DEFAULT 0,
|
||||
koordinat LONGTEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS kemiskinan (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
nama_kk VARCHAR(200) NOT NULL,
|
||||
jumlah_kk INT NOT NULL DEFAULT 1,
|
||||
alamat TEXT NOT NULL,
|
||||
lat DECIMAL(10,7) NOT NULL,
|
||||
lng DECIMAL(10,7) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS masjid (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
nama_masjid VARCHAR(200) NOT NULL,
|
||||
pic_masjid VARCHAR(200) NOT NULL,
|
||||
alamat_masjid TEXT NOT NULL,
|
||||
radius INT NOT NULL DEFAULT 500,
|
||||
lat DECIMAL(10,7) NOT NULL,
|
||||
lng DECIMAL(10,7) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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');
|
||||
$alamat = $conn->real_escape_string($data['alamat'] ?? '');
|
||||
$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', alamat='$alamat', 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]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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]);
|
||||
}
|
||||
?>
|
||||
+2160
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user