--- a/trip.php +++ b/trip.php @@ -3,21 +3,25 @@ $tripid = filter_var($_REQUEST['tripid'], FILTER_SANITIZE_NUMBER_INT); $stopid = filter_var($_REQUEST['stopid'], FILTER_SANITIZE_NUMBER_INT); $routeid = filter_var($_REQUEST['routeid'], FILTER_SANITIZE_NUMBER_INT); +$routetrips = Array(); if ($_REQUEST['routeid']) { $url = $APIurl . "/json/routetrips?route_id=" . $routeid; - $trips = json_decode(getPage($url)); - debug(print_r($trips, true)); - foreach ($trips as $trip) { + $routetrips = json_decode(getPage($url)); + foreach ($routetrips as $trip) { if ($trip[0] < midnight_seconds()) { $tripid = $trip[1]; break; } } - if (!($tripid > 0)) $tripid = $trips[0][1]; + if (!($tripid > 0)) $tripid = $routetrip[0][1]; } $url = $APIurl . "/json/triprows?trip=" . $tripid; $trips = array_flatten(json_decode(getPage($url))); -debug(print_r($trips, true)); +if (sizeof($routetrips) == 0) { + $routeid = $trips[1]->route_id; + $url = $APIurl . "/json/routetrips?route_id=" . $trips[1]->route_id; + $routetrips = json_decode(getPage($url)); +} include_header("Stops on " . $trips[1]->route_short_name . ' ' . $trips[1]->route_long_name, "trip"); if (isMetricsOn()) { // Create a new Instance of the tracker @@ -36,19 +40,59 @@ $owa->trackEvent($event); } timePlaceSettings(); +echo '

Other Trips: '; +foreach ($routetrips as $othertrip) { + echo '' . midnight_seconds_to_time($othertrip[0]) . ' '; +} +echo '

Other directions/timing periods: '; echo ' '; include_footer();