Initial commit

This commit is contained in:
Your Name
2026-06-02 12:40:37 +07:00
commit 20607b0e75
117 changed files with 25598 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 0);
header('Content-Type: application/json');
require_once 'config.php';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
try {
$db = getDB();
$stmt = $db->query('SELECT id, name, road_type, coordinates, length_meters, created_at, updated_at FROM roads ORDER BY created_at DESC');
$roads = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Decode coordinates JSON for each road
foreach ($roads as &$road) {
$road['coordinates'] = json_decode($road['coordinates'], true);
}
echo json_encode([
'success' => true,
'lines' => $roads
]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
} else {
http_response_code(405);
echo json_encode(['error' => 'Method not allowed']);
}
?>