From: Maxious Date: Sun, 26 Feb 2012 04:22:21 +0000 Subject: Fix myway_timeliness_route X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=e5c6822ca0ed5f53c851987c1ccc212f46c8def7 --- Fix myway_timeliness_route --- --- /dev/null +++ b/.gitmodules @@ -1,1 +1,4 @@ +[submodule "lib/amon-php"] + path = lib/amon-php + url = https://github.com/martinrusev/amon-php.git --- a/about.php +++ b/about.php @@ -20,8 +20,8 @@

Busness Time - An ACT bus timetable webapp
Based on the maxious-canberra-transit-feed (download, - last updated )
+ href="http://busresources.lambdacomplex.org/cbrfeed.zip">download, + last updated )
Source code for the transit feed and this --- a/aws/busuidb.sh +++ b/aws/busuidb.sh @@ -7,10 +7,10 @@ psql -d transitdata -f /var/www/transitdata.cbrfeed.sql #createuser transitdata -SDRP #password transitdata -#psql -d transitdata -c "GRANT SELECT ON TABLE agency,calendar,calendar_dates,routes,stop_times,stops,trips\ -#,servicealerts_alerts,servicealerts_informed TO transitdata;" -#psql -d transitdata -c "GRANT SELECT,INSERT ON TABLE myway_observations,myway_routes,myway_stops,myway_timingdeltas TO transitdata;" -#psql -d transitdata -c "GRANT SELECT,INSERT,UPDATE ON TABLE myway_routes,myway_stops TO transitdata;" +#psql -d transitdata -c "GRANT SELECT ON TABLE agency,calendar,calendar_dates,routes,stop_times,stops,trips TO transitdata;" +#psql -d transitdata -c "GRANT SELECT,INSERT ON TABLE myway_observations,myway_timingdeltas,myway_routes,myway_stops TO transitdata;" +#psql -d transitdata -c "GRANT SELECT,INSERT,UPDATE ON TABLE servicealerts_alerts,servicealerts_informed TO transitdata;" +#psql -d transitdata -c "GRANT USAGE,SELECT ON SEQUENCE servicealerts_alerts_id_seq TO transitdata;" ##psql -d transitdata -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO transitdata;" ## INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") ##SELECT '', 'public', 'shapes', 'shape_pt', ST_CoordDim(shape_pt), ST_SRID(shape_pt), GeometryType(shape_pt) --- a/css/local.css.php +++ b/css/local.css.php @@ -55,7 +55,7 @@ visibility: hidden; display: none; } - #servicewarning { + .servicewarning { padding: 1em; margin-bottom: 0.5em; text-size: 0.2em; --- a/feedback.php +++ b/feedback.php @@ -67,7 +67,7 @@ echo "\nServer host/IP: ".php_uname("n"); echo "\nCurrent date/time: ". date("c"); echo "\nCurrent code revision: ".exec("git rev-parse --short HEAD"); - echo "\nCurrent timetables version: ".date("c",@filemtime('cbrfeed.zip')); + echo "\nCurrent timetables version: ".date("c",@filemtime('../busresources/cbrfeed.zip')); echo "\nDump of session: ".print_r($_SESSION,true); ?> --- a/include/common-geo.inc.php +++ b/include/common-geo.inc.php @@ -58,8 +58,8 @@ $output = ""; if ($collapsible) $output.= '

Open Map...

'; - if (isIOSDevice()) $output.= ''; - else $output.= ''; + if (isIOSDevice()) $output.= 'map of stop location'; + else $output.= 'map of stop location'; if ($collapsible) $output.= '
'; --- a/include/common-request.inc.php +++ b/include/common-request.inc.php @@ -51,6 +51,9 @@ if (isset($_REQUEST['routeDestination'])) { $routeDestination = urldecode(filter_var($_REQUEST['routeDestination'], FILTER_SANITIZE_ENCODED)); } +if (isset($_REQUEST['routename'])) { + $routename = urldecode(filter_var($_REQUEST['routename'], FILTER_SANITIZE_ENCODED)); +} if (isset($_REQUEST['stopcode'])) { $stopcode = filter_var($_REQUEST['stopcode'], FILTER_SANITIZE_STRING); } --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -176,35 +176,35 @@ $overrides = getServiceOverride(); if (isset($overrides['service_id'])) { if ($overrides['service_id'] == "noservice") { - echo '
Buses are not running today due to industrial action/public holiday. See Buses are not running today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; } else { - echo '
Buses are running on an altered timetable today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; + echo '
Buses are running on an altered timetable today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; } } $serviceAlerts = Array(); $globalAlerts = getServiceAlertsAsArray("agency", "0"); - if ($globalAlerts != nullarray) { + if ($globalAlerts != null) { // echo "getting alerts due to network wide"; $serviceAlerts = array_merge($serviceAlerts, $globalAlerts); } if (isset($stopid)) { $stopAlerts = getServiceAlertsAsArray("stop", $stopid); - if ($stopAlerts != nullarray) { + if ($stopAlerts != null) { // echo "getting alerts due to stop $stopid"; $serviceAlerts = array_merge($serviceAlerts, $stopAlerts); } } if (isset($routeid)) { $routeAlerts = getServiceAlertsAsArray("route", $routeid); - if ($routeAlerts != nullarray) { + if ($routeAlerts != null) { // echo "getting alerts due to route $routeid"; $serviceAlerts = array_merge($serviceAlerts, $routeAlerts); } } if (isset($serviceAlerts['entity']) && sizeof($serviceAlerts['entity']) > 0) { foreach ($serviceAlerts['entity'] as $entity) { - echo "
{$entity['alert']['header_text']['translation'][0]['text']} " + echo "
{$entity['alert']['header_text']['translation'][0]['text']} " . date("F jS Y, g:i a", $entity['alert']['active_period'][0]['start']) . " to " . date("F jS Y, g:i a", $entity['alert']['active_period'][0]['end']) . "
Warning: {$entity['alert']['description_text']['translation'][0]['text']} @@ -229,7 +229,7 @@ s.parentNode.insertBefore(ga, s); })();"; $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl(); - echo ''; + echo ''; } echo "\n
"; } --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -245,7 +245,7 @@ return $codec->encode($alerts); } else { - return nullarray; + return null; } } --- a/include/common.inc.php +++ b/include/common.inc.php @@ -61,6 +61,12 @@ || $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" || $_SERVER['SERVER_NAME'] == "192.168.1.8" || $_SERVER['SERVER_NAME'] == "192.168.178.24"); } +if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == "maxious.xen.prgmr.com") { +// Set the exception handler +require $basePath."/lib/amon-php/amon.php"; +Amon::setup_exception_handler(); +} + include_once ("common-geo.inc.php"); include_once ("common-net.inc.php"); include_once ("common-transit.inc.php"); --- a/include/db/route-dao.inc.php +++ b/include/db/route-dao.inc.php @@ -59,7 +59,12 @@ databaseError($conn->errorInfo()); return Array(); } - return $query->fetchAll(); + $results = $query->fetchAll(); + if (is_array($results)) { + return $results; + } else { + return Array($results); + } } function getRouteDescription($routeID, $directionID) { $trip = getRouteNextTrip($routeID, $directionID); @@ -120,7 +125,7 @@ function getRouteNextTrip($routeID, $directionID) { global $conn; - $query = "select routes.route_id,direction_id,trips.trip_id,trip_headsign,departure_time from routes join trips on trips.route_id = routes.route_id + $query = "select routes.route_id,routes.route_url,direction_id,trips.trip_id,trip_headsign,departure_time,service_id from routes join trips on trips.route_id = routes.route_id join stop_times on stop_times.trip_id = trips.trip_id where arrival_time between :currentTime and :futureTime and routes.route_id = :routeID and trips.direction_id = :directionID order by arrival_time limit 1"; --- /dev/null +++ b/lib/amon-php --- a/myway/myway_timeliness_route.json.php +++ b/myway/myway_timeliness_route.json.php @@ -21,12 +21,12 @@ header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); ?> { -"label": "", +"label": "", "data": prepare($query); -$_REQUEST['routeid'].=" "; -$query->bindParam(':route_name', $_REQUEST['routeid'], PDO::PARAM_STR); +$query->bindParam(':route_name', $routename, PDO::PARAM_STR); $query->execute(); if (!$query) { @@ -39,3 +39,4 @@ echo "[" . implode(",", $points) . "]"; ?> } + --- a/myway/myway_timeliness_route.php +++ b/myway/myway_timeliness_route.php @@ -22,7 +22,7 @@
- prepare($query); @@ -59,12 +59,12 @@ // fetch one series, adding to what we got var alreadyFetched = {}; - $("#routeid").change(function () { + $("#routename").change(function () { var select = $(this); // find the URL in the link right next to us // var dataurl = button.siblings('a').attr('href'); - var dataurl = "myway_timeliness_route.json.php?routeid=" + select.val(); + var dataurl = "myway_timeliness_route.json.php?routename=" + select.val(); // then fetch the data with jQuery function onDataReceived(series) { // extract the first coordinate pair so you can see that --- a/routeList.php +++ b/routeList.php @@ -50,17 +50,17 @@ echo '
    '; foreach ($routes as $route) { $time = getRouteAtStop($route['route_id'], $route['direction_id'], $route['stop_id']); - $start = getTripStartingPoint($time['trip_id']); - $end = getTripDestination($time['trip_id']); + $start = getTripStartingPoint($time['trip_id']); + $end = getTripDestination($time['trip_id']); //print_r($route); echo '
  • ' . $route['route_short_name'] . "

    -

    " . $time['trip_headsign'] . (strstr($time['trip_headsign'], "bound") === false ? "bound" : "") . " from ".$start['stop_name']." to ".$end['stop_name'] . " (" . ucwords($time['service_id']) . ")

    "; +

    " . $time['trip_headsign'] . (strstr($time['trip_headsign'], "bound") === false ? "bound" : "") . " from " . $start['stop_name'] . " to " . $end['stop_name'] . " (" . ucwords($time['service_id']) . ")

    "; $stop = getStop($route['stop_id']); -echo "

    Board at ".$stop['stop_name']."

    "; + echo "

    Board at " . $stop['stop_name'] . "

    "; echo '' . ($time['arrival_time'] ? $time['arrival_time'] : "No more trips today") . "
    " . floor($route['distance']) . 'm away
    '; - - echo"
  • \n"; + + echo" \n"; } } @@ -92,7 +92,8 @@ } else if (isset($nearby)) { $routes = Array(); include_header("Routes Nearby", "routeList", true, true); - if (isset($_SESSION['lat'])) trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); + if (isset($_SESSION['lat'])) + trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); navbar(); placeSettings(); if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { @@ -132,7 +133,7 @@ $seriesRange[$seriesNum]['max'] = $routeNumber; $seriesRange[$seriesNum]['min'] = $routeNumber; } - $routeSeries[$seriesNum][$seriesNum . "-" . $row[1] . "-" . $row[0]] = $row; + $routeSeries[$seriesNum][] = null; } } ksort($routeSeries); @@ -157,7 +158,8 @@ displayRoutes(getRoutesByDestination($routeDestination)); } else { foreach (getRoutesByDestination() as $destination) { - echo '
  • ' . $destination['stop_name'] . "...
  • \n"; + echo '
  • ' . $destination['stop_name'] . "...
  • \n"; } } } --- a/rtpis/servicealert_editor.php +++ b/rtpis/servicealert_editor.php @@ -35,18 +35,18 @@ echo "Saved " . $_REQUEST['saveedit']; die(); } -if ($_REQUEST['delete']) { +if (isset($_REQUEST['delete'])) { $deleteParts = explode(";", $_REQUEST['delete']); deleteInformedAlert($deleteParts[0], $deleteParts[1], $deleteParts[2]); echo "Deleted network inform for {$deleteParts[0]} ({$deleteParts[1]},{$deleteParts[2]})
    \n"; die(); } -if ($_REQUEST['networkinform']) { +if (isset($_REQUEST['networkinform'])) { addInformedAlert($_REQUEST['networkinform'], "agency", "0", "inform"); echo "Added network inform for" . $_REQUEST['networkinform']; die(); } -if ($_REQUEST['stopsearch']) { +if (isset($_REQUEST['stopsearch'])) { addInformedAlert($_REQUEST['stopsearch'], "stop", $_REQUEST['stopid'], "remove"); echo "Added stop remove for" . $_REQUEST['stopsearch'] . ", stop" . $_REQUEST['stopid'] . "
    \n"; @@ -59,7 +59,7 @@ } die(); } -if ($_REQUEST['streetsearch']) { +if (isset($_REQUEST['streetsearch'])) { echo "Informing stops of street
    \n"; foreach (getStopsByName($_REQUEST['street']) as $stop) { @@ -87,7 +87,7 @@ ?> @@ -95,19 +95,21 @@
    " />
    " />
    @@ -141,12 +143,12 @@ } ?>
    - + '; foreach (getInformedAlerts($_REQUEST['edit'], "", "") as $informed) { --- a/stop.php +++ b/stop.php @@ -16,8 +16,9 @@ limitations under the License. */ include ('include/common.inc.php'); -if ($stopid) +if (isset($stopid)) { $stop = getStop($stopid); +} /* if ($stopcode != "" && $stop[5] != $stopcode) { $url = $APIurl . "/json/stopcodesearch?q=" . $stopcode; $stopsearch = json_decode(getPage($url)); @@ -85,7 +86,7 @@ echo '
    '.$serviceAlert['alert']['description']['translation'].'
    '; } */ -echo ''; +echo '
    '; echo $stopLinks; if (sizeof($stops) > 0) { trackEvent("View Stops", "View Combined Stops", $stop["stop_name"], $stop["stop_id"]); @@ -102,7 +103,7 @@ timeSettings(); -echo ''; +echo '
    '; echo '
      '; if (sizeof($allStopsTrips) > 0) { sktimesort($allStopsTrips, "arrival_time", true); @@ -173,7 +174,7 @@ } } echo '
    '; -echo ''; +echo '
    '; include_footer(); ?> --- a/stopList.php +++ b/stopList.php @@ -60,7 +60,7 @@ die(); } $stops = getNearbyStops($_SESSION['lat'], $_SESSION['lon'], 15); - echo ''; + echo '
    '; $stopPositions[] = Array( $_SESSION['lat'], $_SESSION['lon'] @@ -73,7 +73,7 @@ } echo staticmap($stopPositions, true, true); placeSettings(); - echo ''; + echo '
    '; } else if (isset($suburb)) { $stops = getStopsBySuburb($suburb); include_header("Stops in " . ucwords($suburb), "stopList"); @@ -144,8 +144,9 @@ } } echo '
'; - if (isset($nearby)) - echo ''; + if (isset($nearby)) { + echo ''; +} } include_footer(); ?> --- a/trip.php +++ b/trip.php @@ -32,8 +32,8 @@ $service_period = strtolower($trip["service_id"]); $destination = getTripDestination($trip['trip_id']); include_header("Route " . $trip['route_id'] . ' to ' . $destination['stop_name'], "trip"); -trackEvent("Route/Trip View", "View Route", $trip['route_short_name'] . ' ' . $destination['stop_name'], $routeid); -echo ''; +trackEvent("Route/Trip View", "View Route", $trip['route_id'] . ' ' . $destination['stop_name'], $routeid); +echo '
'; echo 'View Original Timetable/Map '; echo 'View Trip in Google Earth '; echo 'View Route in Google Earth'; @@ -59,7 +59,7 @@ foreach (getRouteHeadsigns($routeid) as $headsign) { if ($headsign['direction_id'] != $directionid || strtolower($headsign['service_id']) != $service_period) { - echo ' Starting at ' . $headsign['stop_name'] . ' (' . $headsign['service_id'] . ') '; + echo ' Starting at ' . $headsign['stop_name'] . ' (' . $headsign['service_id'] . ') '; $otherDir++; } } @@ -67,21 +67,23 @@ if ($otherDir == 0) { echo "None"; } -echo ''; +echo '
'; flush(); @ob_flush(); echo "
"; -if ($nextTrip) +if (isset($nextTrip)) { echo 'Next Trip'; -if ($prevTrip) +} +if (isset($prevTrip)) { echo 'Previous Trip'; +} echo "
"; echo '
    '; $stopsGrouped = Array(); $tripStopTimes = getTripStopTimes($tripid); echo '
  • ' . $tripStopTimes[0]['arrival_time'] . ' to ' . $tripStopTimes[sizeof($tripStopTimes) - 1]['arrival_time'] . ' towards ' . $destination['stop_name'] . ' (' . ucwords(strtolower($tripStopTimes[0]['service_id'])) . ')
  • '; foreach ($tripStopTimes as $key => $tripStopTime) { - if ($key + 1 > sizeof($tripStopTimes) || stopCompare($tripStopTimes[$key]["stop_name"]) != stopCompare($tripStopTimes[$key + 1]["stop_name"])) { + if ($key + 1 >= sizeof($tripStopTimes) || stopCompare($tripStopTimes[$key]["stop_name"]) != stopCompare($tripStopTimes[$key + 1]["stop_name"])) { echo '
  • '; if (sizeof($stopsGrouped) > 0) { @@ -119,7 +121,6 @@ if ($key - 1 <= 0 || stopCompare($tripStopTimes[$key]['stop_name']) != stopCompare($tripStopTimes[$key - 1]['stop_name'])) { // first duplicate $stopsGrouped = Array( - "name" => trim(preg_replace("/\(Platform.*/", "", $stop['stop_name'])), "startTime" => $tripStopTime['arrival_time'], "stop_ids" => Array( $tripStopTime['stop_id'] @@ -133,7 +134,7 @@ } } echo '
'; -echo ''; +echo '
'; include_footer(); ?>