Update: 2026-06-30 23:32:14

This commit is contained in:
Hamza-Ayed
2026-06-30 23:32:15 +03:00
parent 808066f4a6
commit d2ce4bdb16
7 changed files with 277 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
<?php
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/../../connect.php';
// Optional filter: days
$days = filterRequest('days') ?? 7;
try {
$sql = "SELECT latitude, longitude, source, created_at
FROM passenger_opening_locations
WHERE created_at >= DATE_SUB(NOW(), INTERVAL :days DAY)
ORDER BY created_at DESC LIMIT 5000"; // Limit to prevent massive payloads
$stmt = $con->prepare($sql);
$stmt->bindValue(':days', (int) $days, PDO::PARAM_INT);
$stmt->execute();
$locations = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
"status" => "success",
"data" => $locations
]);
} catch (Exception $e) {
error_log("Error fetching heatmap data: " . $e->getMessage());
echo json_encode(["status" => "error", "message" => "Server error"]);
}
?>