--- a/stopList.php +++ b/stopList.php @@ -1,5 +1,6 @@ ' . $suburb . ''; - flush(); @ob_flush(); } } } @@ -41,14 +41,14 @@ // Timing Points / All stops if ($_REQUEST['allstops']) { $listType = 'allstops=yes'; - $url = $APIurl . "/json/stops"; + $stops = getStops(); include_header("All Stops", "stopList"); navbar(); timePlaceSettings(); } else if ($_REQUEST['nearby']) { $listType = 'nearby=yes'; - $url = $APIurl . "/json/neareststops?lat={$_SESSION['lat']}&lon={$_SESSION['lon']}&limit=15"; + $stops = getNearbyStops($_SESSION['lat'],$_SESSION['lon'],15); include_header("Nearby Stops", "stopList", true, true); navbar(); timePlaceSettings(true); @@ -59,14 +59,13 @@ } else if ($_REQUEST['suburb']) { $suburb = filter_var($_REQUEST['suburb'], FILTER_SANITIZE_STRING); - $listType = "suburb=$suburb"; - $url = $APIurl . "/json/stopzonesearch?q=" . $suburb; + $stops = getStopsBySuburb($suburb); include_header("Stops in " . ucwords($suburb) , "stopList"); navbar(); trackEvent("Stop Lists","Stops By Suburb", $suburb); } else { - $url = $APIurl . "/json/timingpoints"; + $stops = getStops(true,$_REQUEST['firstLetter']); include_header("Timing Points / Major Stops", "stopList"); navbar(); timePlaceSettings(); @@ -78,29 +77,21 @@ } } else { - $stops = json_decode(getPage($url)); - foreach ($stops as $key => $row) { - $stopName[$key] = $row[1]; - } - // Sort the stops by name - array_multisort($stopName, SORT_ASC, $stops); - if (!isset($_REQUEST['suburb']) && !isset($_REQUEST['nearby'])) { - $stops = array_filter($stops, "filterByFirstLetter"); - } + //var_dump($stops); $stopsGrouped = Array(); - foreach ($stops as $key => $row) { - if ((trim(preg_replace("/\(Platform.*/", "", $stops[$key][1])) != trim(preg_replace("/\(Platform.*/", "", $stops[$key + 1][1]))) || $key + 1 >= sizeof($stops)) { + foreach ($stops as $key => $stop) { + if ((trim(preg_replace("/\(Platform.*/", "", $stops[$key]["stop_name"])) != trim(preg_replace("/\(Platform.*/", "", $stops[$key + 1]["stop_name"]))) || $key + 1 >= sizeof($stops)) { if (sizeof($stopsGrouped) > 0) { // print and empty grouped stops // subsequent duplicates - $stopsGrouped["stop_ids"][] = $row[0]; + $stopsGrouped["stop_ids"][] = $stop['stop_id']; echo '