if ($badreq) { header("HTTP/1.1 400 Bad Request"); } break; case "get": if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($cget["id"])) { $id = $cget["id"]; if (ctype_digit($id)) { $wr = new Walkroute($conn, $id); $doAnnotations = isset($cget["ann"]) && $cget["ann"] != 0; if ($wr->isValid()) { switch ($format) { case "json": case "geojson": header("Content-type: application/json"); echo $wr->toGeoJSON($doAnnotations); break; case "gpx": header("Content-type: text/xml"); header("Content-Disposition: attachment; filename=" . "walkroute{$id}.gpx"); echo $wr->toGPX($doAnnotations); break; } } else { header("HTTP/1.1 404 Not Found"); echo "Cannot find walkroute with that ID"; } } else { header("HTTP/1.1 400 Bad Request"); echo "Walkroute ID should be numeric!"; }