Harden Project 01 public endpoints

This commit is contained in:
Andrie
2026-06-11 23:15:42 +07:00
parent a90748d9c1
commit 6f4488c1b8
39 changed files with 1183 additions and 612 deletions
+7 -4
View File
@@ -4,10 +4,14 @@ header('Content-Type: application/json');
$id = (int)($_GET['id'] ?? 0);
if ($id <= 0) {
echo json_encode(['status' => 'error', 'message' => 'ID tidak valid.']); exit;
json_error('ID tidak valid.', 400);
}
$stmt = $conn->prepare("SELECT geojson FROM choropleth_layers WHERE id = ?");
$stmt = $conn->prepare("SELECT geojson FROM choropleth_layers WHERE id = ? AND is_visible = 1");
if (!$stmt) {
error_log('Project 01 choropleth geojson prepare failed: ' . $conn->error);
json_error('Gagal memuat GeoJSON.', 500);
}
$stmt->bind_param('i', $id);
$stmt->execute();
$row = $stmt->get_result()->fetch_assoc();
@@ -15,8 +19,7 @@ $stmt->close();
$conn->close();
if (!$row) {
http_response_code(404);
echo json_encode(['status' => 'error', 'message' => 'Layer tidak ditemukan.']); exit;
json_error('Layer tidak ditemukan.', 404);
}
echo $row['geojson'];