More buffer flush while printing unsorted lists
More buffer flush while printing unsorted lists

<?php <?php
// http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt // http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt
// return the interpolated value between pBegin and pEnd // return the interpolated value between pBegin and pEnd
function interpolate($pBegin, $pEnd, $pStep, $pMax) function interpolate($pBegin, $pEnd, $pStep, $pMax)
{ {
if ($pBegin < $pEnd) { if ($pBegin < $pEnd) {
return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin; return (($pEnd - $pBegin) * ($pStep / $pMax)) + $pBegin;
} }
else { else {
return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd; return (($pBegin - $pEnd) * (1 - ($pStep / $pMax))) + $pEnd;
} }
} }
function Gradient($HexFrom, $HexTo, $ColorSteps) function Gradient($HexFrom, $HexTo, $ColorSteps)
{ {
$theColorBegin = hexdec($HexFrom); $theColorBegin = hexdec($HexFrom);
$theColorEnd = hexdec($HexTo); $theColorEnd = hexdec($HexTo);
$theNumSteps = intval($ColorSteps); $theNumSteps = intval($ColorSteps);
$theR0 = ($theColorBegin & 0xff0000) >> 16; $theR0 = ($theColorBegin & 0xff0000) >> 16;
$theG0 = ($theColorBegin & 0x00ff00) >> 8; $theG0 = ($theColorBegin & 0x00ff00) >> 8;
$theB0 = ($theColorBegin & 0x0000ff) >> 0; $theB0 = ($theColorBegin & 0x0000ff) >> 0;
$theR1 = ($theColorEnd & 0xff0000) >> 16; $theR1 = ($theColorEnd & 0xff0000) >> 16;
$theG1 = ($theColorEnd & 0x00ff00) >> 8; $theG1 = ($theColorEnd & 0x00ff00) >> 8;
$theB1 = ($theColorEnd & 0x0000ff) >> 0; $theB1 = ($theColorEnd & 0x0000ff) >> 0;
$GradientColors = array(); $GradientColors = array();
// generate gradient swathe now // generate gradient swathe now
for ($i = 0; $i <= $theNumSteps; $i++) { for ($i = 0; $i <= $theNumSteps; $i++) {
$theR = interpolate($theR0, $theR1, $i, $theNumSteps); $theR = interpolate($theR0, $theR1, $i, $theNumSteps);
$theG = interpolate($theG0, $theG1, $i, $theNumSteps); $theG = interpolate($theG0, $theG1, $i, $theNumSteps);
$theB = interpolate($theB0, $theB1, $i, $theNumSteps); $theB = interpolate($theB0, $theB1, $i, $theNumSteps);
$theVal = ((($theR << 8) | $theG) << 8) | $theB; $theVal = ((($theR << 8) | $theG) << 8) | $theB;
$GradientColors[] = sprintf("%06X", $theVal); $GradientColors[] = sprintf("%06X", $theVal);
} }
return $GradientColors; return $GradientColors;
} }
function processLeg($legNumber, $leg) function processLeg($legNumber, $leg)
{ {
$legArray = object2array($leg); $legArray = object2array($leg);
if ($legArray["@mode"] === "BUS") { if ($legArray["@mode"] === "BUS") {
return "bus {$legArray['@route']} " . str_replace("To", "towards", $legArray['@headsign']); return "bus {$legArray['@route']} " . str_replace("To", "towards", $legArray['@headsign']);
} }
else { else {
return "walk"; return "walk";
//$walkingstep = "walk "; //$walkingstep = "walk ";
//if (strpos($step->streetName, "from") !== false && strpos($step->streetName, "way") !== false) { //if (strpos($step->streetName, "from") !== false && strpos($step->streetName, "way") !== false) {
// $walkingstep.= "footpath"; // $walkingstep.= "footpath";
//} //}
//else { //else {
// $walkingstep.= $step->streetName; // $walkingstep.= $step->streetName;
//} //}
//$walkingstep.= floor($step->distance) . "m"; //$walkingstep.= floor($step->distance) . "m";
//return $walkingstep; //return $walkingstep;
} }
} }
$csv = false; $csv = false;
$kml = true; $kml = true;
if ($kml) { if ($kml) {
//header('Content-Type: application/vnd.google-earth.kml+xml'); //header('Content-Type: application/vnd.google-earth.kml+xml');
echo '<?xml version="1.0" encoding="UTF-8"?> echo '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document>'; <kml xmlns="http://www.opengis.net/kml/2.2"><Document>';
} }
include ('../include/common.inc.php'); include ('../include/common.inc.php');
//Test code to grab transit times //Test code to grab transit times
// make sure to sleep(10); // make sure to sleep(10);
$boundingBoxes = Array( $boundingBoxes = Array(
"belconnen" => Array( "belconnen" => Array(
"startlat" => - 35.1928, "startlat" => - 35.1928,
"startlon" => 149.006, "startlon" => 149.006,
"finishlat" => - 35.2630, "finishlat" => - 35.2630,
"finishlon" => 149.1045, "finishlon" => 149.1045,
) , ) ,
"north gungahlin civic" => Array( "north gungahlin civic" => Array(
"startlat" => - 35.1828, "startlat" => - 35.1828,
"startlon" => 149.1045, "startlon" => 149.1045,
"finishlat" => - 35.2955, "finishlat" => - 35.2955,
"finishlon" => 149.1559, "finishlon" => 149.1559,
) , ) ,
"west duffy" => Array( "west duffy" => Array(
"startlat" => - 35.3252, "startlat" => - 35.3252,
"startlon" => 149.0240, "startlon" => 149.0240,
"finishlat" => - 35.3997, "finishlat" => - 35.3997,
"finishlon" => 149.0676, "finishlon" => 149.0676,
) , ) ,
"central south" => Array( "central south" => Array(
"startlat" => - 35.3042, "startlat" => - 35.3042,
"startlon" => 149.0762, "startlon" => 149.0762,
"finishlat" => - 35.3370, "finishlat" => - 35.3370,
"finishlon" => 149.1806, "finishlon" => 149.1806,
) , ) ,
"south" => Array( "south" => Array(
"startlat" => - 35.3403, "startlat" => - 35.3403,
"startlon" => 149.0714, "startlon" => 149.0714,
"finishlat" => - 35.4607, "finishlat" => - 35.4607,
"finishlon" => 149.1243, "finishlon" => 149.1243,
) )
); );
$latdeltasize = 0.01; $latdeltasize = 0.01;
$londeltasize = 0.01; $londeltasize = 0.01;
$from = "Wattle Street"; $from = "Wattle Street";
$fromPlace = (startsWith($from, "-") ? $from : geocode($from, false)); $fromPlace = (startsWith($from, "-") ? $from : geocode($from, false));
$startTime = "9:00 am"; $startTime = "9:00 am";
$startDate = "03/21/2011"; // american dates, OTP does not validate! $startDate = "03/21/2011"; // american dates, OTP does not validate!
$counter = 0; $counter = 0;
$regionTimes = Array(); $regionTimes = Array();
$testRegions = Array(); $testRegions = Array();
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; $useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
if ($csv) echo "<pre>"; if ($csv) echo "<pre>";
if ($csv) echo "lat,lon,time,latdeltasize, londeltasize, region key name\n"; if ($csv) echo "lat,lon,time,latdeltasize, londeltasize, region key name\n";
foreach ($boundingBoxes as $key => $boundingBox) { foreach ($boundingBoxes as $key => $boundingBox) {
for ($i = $boundingBox['startlat']; $i >= $boundingBox['finishlat']; $i-= $latdeltasize) { for ($i = $boundingBox['startlat']; $i >= $boundingBox['finishlat']; $i-= $latdeltasize) {
for ($j = $boundingBox['startlon']; $j <= $boundingBox['finishlon']; $j+= $londeltasize) { for ($j = $boundingBox['startlon']; $j <= $boundingBox['finishlon']; $j+= $londeltasize) {
$url = $otpAPIurl . "ws/plan?date=" . urlencode($startDate) . "&time=" . urlencode($startTime) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=440&wheelchair=false&toPlace=" . $i . "," . $j . "&fromPlace=$fromPlace"; $url = $otpAPIurl . "ws/plan?date=" . urlencode($startDate) . "&time=" . urlencode($startTime) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=440&wheelchair=false&toPlace=" . $i . "," . $j . "&fromPlace=$fromPlace";
$ch = curl_init($url); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/json" "Accept: application/json"
)); ));
curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$page = curl_exec($ch); $page = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
if ($csv) echo "Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch); if ($csv) echo "Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch);
} }
else { else {
$tripplan = json_decode($page); $tripplan = json_decode($page);
$plans = Array(); $plans = Array();
if (is_array($tripplan->plan->itineraries->itinerary)) { if (is_array($tripplan->plan->itineraries->itinerary)) {
foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) { foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) {
$plans[floor($itinerary->duration / 60000) ] = $itinerary; $plans[floor($itinerary->duration / 60000) ] = $itinerary;
} }
} }
else { else {
$plans[floor($tripplan->plan->itineraries->itinerary->duration / 60000) ] = $tripplan->plan->itineraries->itinerary; $plans[floor($tripplan->plan->itineraries->itinerary->duration / 60000) ] = $tripplan->plan->itineraries->itinerary;
} }
if ($csv) echo "$i,$j," . min(array_keys($plans)) . ",$latdeltasize, $londeltasize,$key\n"; if ($csv) echo "$i,$j," . min(array_keys($plans)) . ",$latdeltasize, $londeltasize,$key\n";
if ($kml) { if ($kml) {
$time = min(array_keys($plans)); $time = min(array_keys($plans));
$plan = ""; $plan = "";
if (is_array($plans[min(array_keys($plans)) ]->legs->leg)) { if (is_array($plans[min(array_keys($plans)) ]->legs->leg)) {
foreach ($plans[min(array_keys($plans)) ]->legs->leg as $legNumber => $leg) { foreach ($plans[min(array_keys($plans)) ]->legs->leg as $legNumber => $leg) {
$plan .= processLeg($legNumber, $leg).","; $plan .= processLeg($legNumber, $leg).",";
} }
} }
else { else {
$plan .= processLeg(0, $plans[min(array_keys($plans)) ]->legs->leg); $plan .= processLeg(0, $plans[min(array_keys($plans)) ]->legs->leg);
} }
if (isset($tripplan->error) && $tripplan->error->id == 404) { if (isset($tripplan->error) && $tripplan->error->id == 404) {
$time = 999; $time = 999;
$plan = "Trip not possible without excessive walking from nearest bus stop"; $plan = "Trip not possible without excessive walking from nearest bus stop";
} }
$testRegions[] = Array( $testRegions[] = Array(
"lat" => $i, "lat" => $i,
"lon" => $j, "lon" => $j,
"time" => $time, "time" => $time,
"latdeltasize" => $latdeltasize, "latdeltasize" => $latdeltasize,
"londeltasize" => $londeltasize, "londeltasize" => $londeltasize,
"regionname" => $key, "regionname" => $key,
"plan" => $plan . "<br/><a href='". htmlspecialchars($url)."'>original plan</a>" "plan" => $plan . "<br/><a href='". htmlspecialchars($url)."'>original plan</a>"
); );
$regionTimes[] = $time; $regionTimes[] = $time;
} }
} }
flush(); flush(); @ob_flush();
ob_flush();  
curl_close($ch); curl_close($ch);
} }
} }
} }
if ($kml) { if ($kml) {
$colorSteps = 9; $colorSteps = 9;
//$minTime = min($regionTimes); //$minTime = min($regionTimes);
//$maxTime = max($regionTimes); //$maxTime = max($regionTimes);
//$rangeTime = $maxTime - $minTime; //$rangeTime = $maxTime - $minTime;
//$deltaTime = $rangeTime / $colorSteps; //$deltaTime = $rangeTime / $colorSteps;
$Gradients = Gradient(strrev("66FF00"), strrev("FF0000"), $colorSteps); // KML is BGR not RGB so strrev $Gradients = Gradient(strrev("66FF00"), strrev("FF0000"), $colorSteps); // KML is BGR not RGB so strrev
foreach ($testRegions as $testRegion) { foreach ($testRegions as $testRegion) {
//$band = (floor(($testRegion[time] - $minTime) / $deltaTime)); //$band = (floor(($testRegion[time] - $minTime) / $deltaTime));
$band = (floor($testRegion[time] / 10)); $band = (floor($testRegion[time] / 10));
if ($band > $colorSteps) $band = $colorSteps; if ($band > $colorSteps) $band = $colorSteps;
echo "<Placemark> echo "<Placemark>
<name>" . $testRegion['regionname'] . " time {$testRegion['time']} band $band</name> <name>" . $testRegion['regionname'] . " time {$testRegion['time']} band $band</name>
<description> {$testRegion['plan']} </description> <description> {$testRegion['plan']} </description>
<Style> <Style>
<PolyStyle> <PolyStyle>
<color>c7" . $Gradients[$band] . "</color>" . // 7f = 50% alpha, c7=78% <color>c7" . $Gradients[$band] . "</color>" . // 7f = 50% alpha, c7=78%
"</PolyStyle> "</PolyStyle>
<LineStyle> <LineStyle>
<color>c7" . $Gradients[$band] . "</color>" . "</LineStyle> <color>c7" . $Gradients[$band] . "</color>" . "</LineStyle>
</Style> </Style>
<Polygon> <Polygon>
<altitudeMode>relativeToGround</altitudeMode> <altitudeMode>relativeToGround</altitudeMode>
<outerBoundaryIs> <outerBoundaryIs>
<LinearRing> <LinearRing>
<coordinates> <coordinates>
" . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] + ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] + ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] + ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] + ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . " " . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] + ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] + ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] + ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] + ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . ($testRegion['lon'] - ($testRegion['londeltasize'] / 2)) . "," . ($testRegion['lat'] - ($testRegion['latdeltasize'] / 2)) . ",500\n" . "
</coordinates> </coordinates>
</LinearRing> </LinearRing>
</outerBoundaryIs> </outerBoundaryIs>
</Polygon> </Polygon>
</Placemark>"; </Placemark>";
} }
echo "\n</Document></kml>\n"; echo "\n</Document></kml>\n";
} }
if ($csv) echo "</pre>"; if ($csv) echo "</pre>";
?> ?>
   
file:a/stop.php -> file:b/stop.php
<?php <?php
include ('include/common.inc.php'); include ('include/common.inc.php');
$stopid = filter_var($_REQUEST['stopid'], FILTER_SANITIZE_NUMBER_INT); $stopid = filter_var($_REQUEST['stopid'], FILTER_SANITIZE_NUMBER_INT);
$stopcode = filter_var($_REQUEST['stopcode'], FILTER_SANITIZE_STRING); $stopcode = filter_var($_REQUEST['stopcode'], FILTER_SANITIZE_STRING);
$url = $APIurl . "/json/stop?stop_id=" . $stopid; $url = $APIurl . "/json/stop?stop_id=" . $stopid;
$stop = json_decode(getPage($url)); $stop = json_decode(getPage($url));
if ($stopcode != "" && $stop[5] != $stopcode) { if ($stopcode != "" && $stop[5] != $stopcode) {
$url = $APIurl . "/json/stopcodesearch?q=" . $stopcode; $url = $APIurl . "/json/stopcodesearch?q=" . $stopcode;
$stopsearch = json_decode(getPage($url)); $stopsearch = json_decode(getPage($url));
$stopid = $stopsearch[0][0]; $stopid = $stopsearch[0][0];
$url = $APIurl . "/json/stop?stop_id=" . $stopid; $url = $APIurl . "/json/stop?stop_id=" . $stopid;
$stop = json_decode(getPage($url)); $stop = json_decode(getPage($url));
} }
if (!startsWith($stop[5], "Wj") && strpos($stop[1], "Platform") === false) { if (!startsWith($stop[5], "Wj") && strpos($stop[1], "Platform") === false) {
// expand out to all platforms // expand out to all platforms
} }
$stops = Array(); $stops = Array();
$stopPositions = Array(); $stopPositions = Array();
$stopNames = Array(); $stopNames = Array();
$tripStopNumbers = Array(); $tripStopNumbers = Array();
$allStopsTrips = Array(); $allStopsTrips = Array();
$stopLinks = ""; $stopLinks = "";
if (isset($_REQUEST['stopids'])) { if (isset($_REQUEST['stopids'])) {
$stopids = explode(",", filter_var($_REQUEST['stopids'], FILTER_SANITIZE_STRING)); $stopids = explode(",", filter_var($_REQUEST['stopids'], FILTER_SANITIZE_STRING));
foreach ($stopids as $sub_stopid) { foreach ($stopids as $sub_stopid) {
$url = $APIurl . "/json/stop?stop_id=" . $sub_stopid; $url = $APIurl . "/json/stop?stop_id=" . $sub_stopid;
$stop = json_decode(getPage($url)); $stop = json_decode(getPage($url));
$stops[] = $stop; $stops[] = $stop;
} }
$stop = $stops[0]; $stop = $stops[0];
$stopid = $stops[0][0]; $stopid = $stops[0][0];
$stopLinks.= "Individual stop pages: "; $stopLinks.= "Individual stop pages: ";
foreach ($stops as $key => $sub_stop) { foreach ($stops as $key => $sub_stop) {
// $stopNames[$key] = $sub_stop[1] . ' Stop #' . ($key + 1); // $stopNames[$key] = $sub_stop[1] . ' Stop #' . ($key + 1);
if (strpos($stop[1], if (strpos($stop[1],
"Station")) { "Station")) {
$stopNames[$key] = 'Platform ' . ($key + 1); $stopNames[$key] = 'Platform ' . ($key + 1);
$stopLinks.= '<a href="stop.php?stopid=' . $sub_stop[0] . '&stopcode=' . $sub_stop[5] . '">' . $sub_stop[1] . '</a> '; $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop[0] . '&stopcode=' . $sub_stop[5] . '">' . $sub_stop[1] . '</a> ';
} else { } else {
$stopNames[$key] = '#' . ($key + 1); $stopNames[$key] = '#' . ($key + 1);
$stopLinks.= '<a href="stop.php?stopid=' . $sub_stop[0] . '&stopcode=' . $sub_stop[5] . '">' . $sub_stop[1] . ' Stop #' . ($key + 1) . '</a> '; $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop[0] . '&stopcode=' . $sub_stop[5] . '">' . $sub_stop[1] . ' Stop #' . ($key + 1) . '</a> ';
} }
$stopPositions[$key] = Array( $stopPositions[$key] = Array(
$sub_stop[2], $sub_stop[2],
$sub_stop[3] $sub_stop[3]
); );
$url = $APIurl . "/json/stoptrips?stop=" . $sub_stop[0] . "&time=" . midnight_seconds() . "&service_period=" . service_period(); $url = $APIurl . "/json/stoptrips?stop=" . $sub_stop[0] . "&time=" . midnight_seconds() . "&service_period=" . service_period();
$trips = json_decode(getPage($url)); $trips = json_decode(getPage($url));
foreach ($trips as $trip) { foreach ($trips as $trip) {
if (!isset($allStopsTrips[$trip[1][0]])) $allStopsTrips[$trip[1][0]] = $trip; if (!isset($allStopsTrips[$trip[1][0]])) $allStopsTrips[$trip[1][0]] = $trip;
$tripStopNumbers[$trip[1][0]][] = $key; $tripStopNumbers[$trip[1][0]][] = $key;
} }
} }
} }
include_header($stop[1], "stop"); include_header($stop[1], "stop");
timePlaceSettings(); timePlaceSettings();
echo '<div data-role="content" class="ui-content" role="main"> <a name="maincontent" id="maincontent"></a>'; echo '<div data-role="content" class="ui-content" role="main"> <a name="maincontent" id="maincontent"></a>';
echo $stopLinks; echo $stopLinks;
if (sizeof($stops) > 0) { if (sizeof($stops) > 0) {
trackEvent("View Stops","View Combined Stops", $stop[1], $stop[0]); trackEvent("View Stops","View Combined Stops", $stop[1], $stop[0]);
   
echo '<p>' . staticmap($stopPositions) . '</p>'; echo '<p>' . staticmap($stopPositions) . '</p>';
} }
else { else {
trackEvent("View Stops","View Single Stop", $stop[1], $stop[0]); trackEvent("View Stops","View Single Stop", $stop[1], $stop[0]);
echo '<p>' . staticmap(Array( echo '<p>' . staticmap(Array(
0 => Array( 0 => Array(
$stop[2], $stop[2],
$stop[3] $stop[3]
) )
)) . '</p>'; )) . '</p>';
} }
echo ' <ul data-role="listview" data-inset="true">'; echo ' <ul data-role="listview" data-inset="true">';
if (sizeof($allStopsTrips) > 0) { if (sizeof($allStopsTrips) > 0) {
sksort($allStopsTrips,0, $true); sksort($allStopsTrips,0, $true);
$trips = $allStopsTrips; $trips = $allStopsTrips;
} }
else { else {
$url = $APIurl . "/json/stoptrips?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); $url = $APIurl . "/json/stoptrips?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period();
$trips = json_decode(getPage($url)); $trips = json_decode(getPage($url));
} }
foreach ($trips as $row) { foreach ($trips as $row) {
echo '<li>'; echo '<li>';
echo '<a href="trip.php?stopid=' . $stopid . '&tripid=' . $row[1][0] . '"><h3>' . $row[1][1]."</h3><p>"; echo '<a href="trip.php?stopid=' . $stopid . '&tripid=' . $row[1][0] . '"><h3>' . $row[1][1]."</h3><p>";
$viaPoints = viaPointNames($row[1][0], $stopid); $viaPoints = viaPointNames($row[1][0], $stopid);
if ($viaPoints != "") echo '<br><span class="viaPoints">Via: ' . $viaPoints . '</span>'; if ($viaPoints != "") echo '<br><span class="viaPoints">Via: ' . $viaPoints . '</span>';
if (sizeof($tripStopNumbers) > 0) { if (sizeof($tripStopNumbers) > 0) {
echo '<br><small>Boarding At: '; echo '<br><small>Boarding At: ';
foreach ($tripStopNumbers[$row[1][0]] as $key) { foreach ($tripStopNumbers[$row[1][0]] as $key) {
echo $stopNames[$key] .' '; echo $stopNames[$key] .' ';
} }
echo '</small>'; echo '</small>';
} }
echo '</p>'; echo '</p>';
echo '<p class="ui-li-aside"><strong>' . midnight_seconds_to_time($row[0]) . '</strong></p>'; echo '<p class="ui-li-aside"><strong>' . midnight_seconds_to_time($row[0]) . '</strong></p>';
echo '</a></li>'; echo '</a></li>';
  flush(); @ob_flush();
} }
if (sizeof($trips) == 0) echo "<li> <center>No trips in the near future.</center> </li>"; if (sizeof($trips) == 0) echo "<li> <center>No trips in the near future.</center> </li>";
echo '</ul></div>'; echo '</ul></div>';
include_footer(); include_footer();
?> ?>
   
<?php <?php
include ('include/common.inc.php'); include ('include/common.inc.php');
function filterByFirstLetter($var) function filterByFirstLetter($var)
{ {
return $var[1][0] == $_REQUEST['firstLetter']; return $var[1][0] == $_REQU