Harden Project 01 public endpoints
This commit is contained in:
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user