$date2 = $path_components[6]; } //url: ~/station/top/N/in or ~/station/top/N/out or ~/station/top/N [in & out] //url: ~/station/bottom/N/in or ~/station/bottom/N/out or ~/station/bottom/N [in & out] if (($path_components[2] == 'top' || $path_components[2] == 'bottom') && $path_components[3] != '') { $order = $path_components[2]; // top or bottom $num_of_station = intval($path_components[3]); // N station //incoming or ourcoming or all if (count($path_components) == 4) { $weight = 'all'; } else { $weight = $path_components[4]; } $all_stations = Station::getNStations($num_of_station, $order, $weight, $date1, $date2); if ($all_stations == null) { //Station info not found header("HTTP/1.1 404 Not Found"); print "Data for " . $order . " " . $weight . " " . $num_of_station . " stations are null;"; exit; } header("Content-type: application/json"); print json_encode($all_stations); exit; } } } else { if ($path_components[1] == 'trip') { if (count($path_components) == 2) { //url: ~/trip
} if (count($path_components) >= 4) { //url: ~/station/top/N/in or ~/station/top/N/out or ~/station/top/N [in & out] //url: ~/station/bottom/N/in or ~/station/bottom/N/out or ~/station/bottom/N [in & out] if (($path_components[2] == 'top' || $path_components[2] == 'bottom') && $path_components[3] != '') { $order = $path_components[2]; // top or bottom $num_of_station = intval($path_components[3]); // N station //incoming or ourcoming or all if (count($path_components) == 4) { $weight = 'all'; } else { $weight = $path_components[4]; } $all_stations = Station::getNStations($num_of_station, $order, $weight); if ($all_stations == null) { //Station info not found header("HTTP/1.1 404 Not Found"); print "Data for " . $order . " " . $weight . " " . $num_of_station . "stations are null;"; exit; } header("Content-type: application/json"); print json_encode($all_stations); exit; } } } else { if ($path_components[1] == 'trip') { if (count($path_components) == 2) { //url: ~/trip