fix servicealert editor due to "end" field master
fix servicealert editor due to "end" field

file:a/about.php -> file:b/about.php
--- a/about.php
+++ b/about.php
@@ -27,24 +27,24 @@
         feed</a> and <a href="https://github.com/maxious/ACTBus-ui">this 
         site</a> available from github.<br />
     Uses jQuery Mobile, PHP, PostgreSQL, OpenTripPlanner, OpenLayers, OpenStreetMap, Cloudmade Geocoder and Tile Service<br />
-    Suburb Geocoding Based on <A href="http://www.abs.gov.au/AUSSTATS/abs@.nsf/Lookup/1270.0.55.003Main+Features1July%202011?OpenDocument">Australian Bureau of Statistics data.</a><br />
+    Suburb geocoding based on <A href="http://www.abs.gov.au/AUSSTATS/abs@.nsf/Lookup/1270.0.55.003Main+Features1July%202011?OpenDocument">Australian Bureau of Statistics data.</a><br />
     Street geocoding based on work by OpenStreetMap contributors<br>
     <br />
     Feedback encouraged; contact maxious@lambdacomplex.org<br />
     <br />
     Some icons by Joseph Wain / glyphish.com<br />
-    Native clients also available for iPhone(<a href="http://itunes.apple.com/au/app/cbrtimetable/id444287349?mt=8">cbrTimetable by Sandor Kolotenko</a>
-    , <a href="http://itunes.apple.com/au/app/act-buses/id376634797?mt=8">ACT Buses by David Sullivan</a>, <a href="http://itunes.apple.com/app/bus-trips-act/id489146525?mt=8">Bus Trips ACT by Molson Chengalath</a>) 
+    Native clients also available for iPhone (<a href="http://itunes.apple.com/au/app/cbrtimetable/id444287349?mt=8">cbrTimetable by Sandor Kolotenko</a>
+    , <a href="http://itunes.apple.com/au/app/act-buses/id376634797?mt=8">ACT Buses by David Sullivan</a>, <a href="http://itunes.apple.com/app/bus-trips-act/id489146525?mt=8">Bus Trips ACT by Molson Chengalath</a>)
     , Android (<a href="https://market.android.com/details?id=com.action">MyBus 2.0 by Imagine Team</a>, <A href="https://market.android.com/details?id=GetMe2CanberraFree.source">GetMe2 Canberra by
 Colin Thompson </a>, <a href="https://market.android.com/details?id=au.com.transittimes.android">TransitTimes+ by Zervaas Enterprises</a>) 
-    and Windows Phone 7 (<a href="http://www.windowsphone.com/en-AU/apps/d840375e-429c-4aa4-a358-80eec6ea9e66">TransHub Canberra by Soul Solutions</a>) Other web clients include <a href="http://canberra.itranzit.com/option.html">iTranzit</a>.
+    and Windows Phone 7 (<a href="http://www.windowsphone.com/en-AU/apps/d840375e-429c-4aa4-a358-80eec6ea9e66">TransHub Canberra by Soul Solutions</a>).
     <br />
-    GTFS-realtime API:
-    Alerts and Trip Updates (but only Cancelled or Stop Skipped)
-    Default format binary Protocol Buffer but can get JSON by adding ?ascii=yes
+    <!--GTFS-realtime API:<br />
+    Alerts and Trip Updates (but only Cancelled or Stop Skipped)<br />
+    Default format binary Protocol Buffer but can get JSON by adding ?ascii=yes<br />-->
     <br />
     <br />
-    <small>Disclaimer: The content of this website is of a general and informative nature. Please check with printed timetables or those available on http://action.act.gov.au before your trip.
+    <small>Disclaimer: The content of this website is of a general and informative nature. Please check with printed timetables or those available on http://www.action.act.gov.au before your trip.
         Whilst every effort has been made to ensure the high quality and accuracy of the Site, the Author makes no warranty, 
         express or implied concerning the topicality, correctness, completeness or quality of the information, which is provided 
         "as is". The Author expressly disclaims all warranties, including but not limited to warranties of fitness for a particular purpose and warranties of merchantability. 

--- a/include/common-geo.inc.php
+++ b/include/common-geo.inc.php
@@ -56,15 +56,23 @@
         }
     }
     $output = '';
-    if ($collapsible)
-        $output.= '<div class="map" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>';
-    if (isIOSDevice())
+    if ($collapsible) {
+        $output.= '<div class="map geo" itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>
+                <meta itemprop="latitude" content="'.$mapPoints[0][0].'" />
+                 <abbr class="latitude" title="'.$mapPoints[0][0].'"></abbr> 
+ <abbr class="longitude" title="'.$mapPoints[0][1].'"></abbr>
+    <meta itemprop="longitude" content="'.$mapPoints[0][1].'" />';
+    }
+    if (isIOSDevice()) {
         $output.= '<img class="hiresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&amp;' . $markers . '&amp;scale=2&amp;sensor=true" width=' . $width . ' height=' . $height . '" alt="map of stop location">';
-    else
+    }
+    else {
         $output.= '<img class="lowresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&amp;' . $markers . '&amp;scale=1&amp;format=jpg&amp;sensor=true" width=' . $width . ' height=' . $height . '" alt="map of stop location">';
-
-    if ($collapsible)
+    }
+    
+    if ($collapsible) {
         $output.= '</div>';
+    }
     return $output;
 }
 

--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -46,7 +46,7 @@
     echo '
 <!DOCTYPE html> 
 <html lang="en">
-	<head>
+	<head profile="http://microformats.org/profile/hcalendar http://microformats.org/profile/geo http://vocab.org/transit/terms">
         <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1"> 	
 <title>' . $pageTitle . ' - Canberra Bus Timetable</title>
@@ -161,11 +161,11 @@
     </div>
  ';
     if ($opendiv) {
-        echo '<div data-role="page"> 
-	<div data-role="header" data-position="inline">
+        echo '<div data-role="page"'. (isset($stopid) ? 'itemscope itemtype="http://schema.org/BusStop"':'').'>'; 
+	echo '<div data-role="header" data-position="inline">
 	<a href="' . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "javascript:history.go(-1)") . '" data-icon="arrow-l" data-rel="back" class="ui-btn-left">Back</a> 
-		<h1>' . $pageTitle . '</h1>
-		<a href="' . $basePath . '/index.php" data-icon="home" class="ui-btn-right">Home</a>
+		<h1 itemprop="name">' . $pageTitle . '</h1>
+		<a href="' . $basePath . '/index.php" data-icon="home" class="ui-btn-right" rel="home">Home</a>
 	</div><!-- /header -->
         <a name="maincontent" id="maincontent"></a>
         <div data-role="content"> ';
@@ -215,7 +215,8 @@
 function include_footer() {
     global $basePath;
     echo '<div id="footer"><a href="' . $basePath . 'about.php">About/Contact Us</a>&nbsp;<a href="' . $basePath . 'feedback.php">Feedback/Bug Report</a>&nbsp;<a href="' . $basePath . 'privacy.php">Privacy Policy</a>';
-    echo '</div>';
+    echo '<br><small>
+        <a rel="license" href="http://creativecommons.org/licenses/by/3.0/au/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/au/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/au/">Creative Commons Attribution 3.0 Australia License</a>.</div></small>';
     if (isAnalyticsOn()) {
         echo "<script>  (function() {
     var ga = document.createElement('script'); ga.type = 

--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -21,28 +21,14 @@
     'session',
     'json',
     'phperror',
-    'awsotp',
-    //'squallotp',
-    //'vanilleotp',
     'database',
     'other'
 );
 $GTFSREnabled = true;
 $cloudmadeAPIkey = 'daa03470bb8740298d4b10e3f03d63e6';
 $googleMapsAPIkey = 'ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q';
-$otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/';
-if (isDebug('awsotp') || php_uname('n') == 'maxious.xen.prgmr.com' || strstr(php_uname('n'),'actbus')) {
-    $otpAPIurl = 'http://bus-main.lambdacomplex.org:8080/opentripplanner-api-webapp/';
-}
-if (isDebug('dotcloudotp') || php_uname('n') == 'actbus-www') {
-    $otpAPIurl = 'http://otp.actbus.dotcloud.com/opentripplanner-api-webapp/';
-}
-if (isDebug('squallotp')) {
-    $otpAPIurl = 'http://10.0.1.108:5080/opentripplanner-api-webapp/';
-}
-if (isDebug('vanilleotp')) {
-    $otpAPIurl = 'http://10.0.1.135:8080/opentripplanner-api-webapp/';
-}
+$otpAPIurl = 'http://localhost:9080/opentripplanner-api-webapp/';
+
 if (isDebug('phperror'))
     error_reporting(E_ALL ^ E_NOTICE);
 

--- a/include/db/servicealert-dao.inc.php
+++ b/include/db/servicealert-dao.inc.php
@@ -33,7 +33,7 @@
 
 function getServiceAlert($alertID) {
     global $conn;
-    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as \\\'end\\\',cause,effect,header,description,url from servicealerts_alerts where id = :servicealert_id';
+    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as end,cause,effect,header,description,url from servicealerts_alerts where id = :servicealert_id';
     debug($query, 'database');
     $query = $conn->prepare($query);
     $query->bindParam(':servicealert_id', $alertID);
@@ -93,7 +93,7 @@
 
 function getCurrentAlerts() {
     global $conn;
-    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as "end",cause,effect,header,description,url from servicealerts_alerts where NOW() > start and NOW() < "end"';
+    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start and NOW() < "end"';
     // debug($query, 'database');
     $query = $conn->prepare($query);
     $query->execute();
@@ -106,7 +106,7 @@
 
 function getFutureAlerts() {
     global $conn;
-    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as "end",cause,effect,header,description,url from servicealerts_alerts where  NOW() < "end"';
+    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as end,cause,effect,header,description,url from servicealerts_alerts where  NOW() < "end"';
     // debug($query, 'database');
     $query = $conn->prepare($query);
     $query->execute();
@@ -119,7 +119,7 @@
 
 function getAllAlerts() {
     global $conn;
-    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as "end",cause,effect,header,description,url from servicealerts_alerts';
+    $query = 'SELECT id,extract(\'epoch\' from start) as start, extract(\'epoch\' from "end") as end,cause,effect,header,description,url from servicealerts_alerts';
     // debug($query, 'database');
     $query = $conn->prepare($query);
     $query->execute();

--- a/rtpis/siri.php
+++ b/rtpis/siri.php
@@ -37,7 +37,7 @@
     return $toret;
 }
 function usage() {
-echo "Usage notes: Must specify format json/xml. If callback is specified, will provide jsonp. Can filter with parmaters filter_class route/stop and filter_id with the id specified in GTFS."
+echo "Usage notes: Must specify format json/xml. If callback is specified, will provide jsonp. Can filter with parmaters filter_class route/stop and filter_id with the id specified in GTFS.";
 die();
 }
 $json_types =  Array("application/json","application/x-javascript","text/javascript","text/x-javascript","text/x-json");

file:a/stop.php -> file:b/stop.php
--- a/stop.php
+++ b/stop.php
@@ -48,7 +48,13 @@
     foreach ($stops as $key => $sub_stop) {
 
         $stopNames[$key] = $sub_stop["stop_name"];
-        $stopLinks.= '<a href="stop.php?stopid=' . $sub_stop["stop_id"] . '&amp;stopcode=' . $sub_stop["stop_code"] . '">' . $sub_stop["stop_name"] . '</a>  ';
+        $stopLinks.= '<span itemscope itemtype="http://schema.org/BusStop"> 
+            <a itemprop="url" href="stop.php?stopid=' . $sub_stop["stop_id"] . 
+                '&amp;stopcode=' . $sub_stop["stop_code"] . '">' . $sub_stop["stop_name"] 
+                . '</a><meta itemprop="latitude" content="'.$sub_stop["stop_lat"].'" />
+                 <abbr class="latitude" title="'.$sub_stop["stop_lat"].'"></abbr> 
+ <abbr class="longitude" title="'.$sub_stop["stop_lon"].'"></abbr>
+    <meta itemprop="longitude" content="'.$sub_stop["stop_lon"].'" /></span>';
 
         $stopPositions[$key] = Array(
             $sub_stop["stop_lat"],
@@ -86,7 +92,7 @@
   echo '<div id="servicewarning">'.$serviceAlert['alert']['description']['translation'].'</div>';
   } */
 
-echo '<div class="content-secondary">';
+echo '<div class="content-secondary"><br>';
 echo $stopLinks;
 if (sizeof($stops) > 0) {
     trackEvent("View Stops", "View Combined Stops", $stop["stop_name"], $stop["stop_id"]);
@@ -110,6 +116,7 @@
     $trips = $allStopsTrips;
 } else {
     $trips = getStopTripsWithTimes($stopid, "", "", "", (isset($filterIncludeRoutes) || isset($filterHasStop) ? "75" : ""));
+    
 }
 
 echo "<div class='ui-header' style='overflow: visible; height: 2.5em'>";
@@ -171,10 +178,10 @@
                 || (isset($filterIncludeRoutes) && in_array($trip["route_short_name"], $filterIncludeRoutes))
                 || (!isset($filterIncludeRoutes) && !isset($filterHasStop))
         ) {
-            echo '<li>';
+            echo '<li class="vevent">';
 
             $destination = getTripDestination($trip['trip_id']);
-            echo '<a href="trip.php?stopid=' . $stopid . '&amp;tripid=' . $trip['trip_id'] . '"><h3>' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "</h3><p>";
+            echo '<a href="trip.php?stopid=' . $stopid . '&amp;tripid=' . $trip['trip_id'] . '"><h3 class="summary">' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "</h3><p>";
             $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']);
 if (isset($labs)) {
                 echo '<br><span class="eta">ETA: ' . $tripETA[$trip['trip_id']] . '</span>';
@@ -193,7 +200,7 @@
                 echo '</small>';
             }
             echo '</p>';
-            echo '<p class="ui-li-aside"><strong>' . $trip['arrival_time'] . '</strong></p>';
+            echo '<p class="ui-li-aside"><time class="dtstart" datetime="'.date("c",strtotime($trip['arrival_time'])).'">' . $trip['arrival_time'] . '</time></p>';
             echo '</a></li>';
             flush();
             @ob_flush();

file:a/trip.php -> file:b/trip.php
--- a/trip.php
+++ b/trip.php
@@ -91,13 +91,13 @@
             // subsequent duplicates
             $stopsGrouped["stop_ids"][] = $tripStopTime['stop_id'];
             $stopsGrouped["endTime"] = $tripStopTime['arrival_time'];
-            echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '">';
-            echo '<p class="ui-li-aside">' . $stopsGrouped['startTime'] . ' to ' . $stopsGrouped['endTime'];
+            echo '<a class="vevent" href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '">';
+            echo '<p class="ui-li-aside"> <time class="dtstart" datetime="'.date("c",strtotime($stopsGrouped['startTime'])).'">' . $stopsGrouped['startTime'] . '</time> to <time class="dtend" datetime="'.date("c",strtotime($stopsGrouped['endTime'])).'">' . $stopsGrouped['endTime'] . '</time>';
             if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
                 echo '<br>' . distance($tripStopTime['stop_lat'], $tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
             }
-            echo '</p>';
-            echo stopGroupTitle($tripStopTime['stop_name'], $tripStopTime['stop_desc']) . '<br><small>' . sizeof($stopsGrouped["stop_ids"]) . ' stops</small>';
+            echo '</p><span class="summary">';
+            echo stopGroupTitle($tripStopTime['stop_name'], $tripStopTime['stop_desc']) . '</span><br><small>' . sizeof($stopsGrouped["stop_ids"]) . ' stops</small>';
 
             echo '</a></li>';
             flush();
@@ -105,14 +105,17 @@
             $stopsGrouped = Array();
         } else {
             // just a normal stop
-            echo '<a href="stop.php?stopid=' . $tripStopTime['stop_id'] . (startsWith($tripStopTime['stop_code'], "Wj") ? '&amp;stopcode=' . $tripStopTime['stop_code'] : "") . '">';
-            echo '<p class="ui-li-aside">' . $tripStopTime['arrival_time'];
+            echo '<span itemscope itemtype="http://schema.org/BusStop" class="vevent"> <a itemprop="url" href="stop.php?stopid=' . $tripStopTime['stop_id'] . (startsWith($tripStopTime['stop_code'], "Wj") ? '&amp;stopcode=' . $tripStopTime['stop_code'] : "") . '">';
+            echo '<p class="ui-li-aside geo"><time class="dtstart" datetime="'.date("c",strtotime($trip['arrival_time'])).'">' . $tripStopTime['arrival_time'].'</time>';
+            echo '<abbr class="latitude" title="'.$tripStopTime['stop_lat'].'"></abbr> 
+ <abbr class="longitude" title="'.$tripStopTime['stop_lon'].'"></abbr><meta itemprop="latitude" content="'.$tripStopTime['stop_lat'].'" />
+    <meta itemprop="longitude" content="'.$tripStopTime['stop_lon'].'" />';
             if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
                 echo '<br>' . distance($tripStopTime['stop_lat'], $tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
             }
-            echo '</p>';
+            echo '</p><span class="summary" itemprop="name">';
             echo $tripStopTime['stop_name'];
-            echo '</a></li>';
+            echo '</span></a></li>';
             flush();
             @ob_flush();
         }

--- a/tripPlanner.php
+++ b/tripPlanner.php
@@ -167,7 +167,11 @@
             trackEvent("Trip Planner", "Plan Trip To", $to);
             $tripplan = json_decode($page);
             debug(print_r($tripplan, true));
+            if (isset ($tripplan->error->msg)) {
+                echo $tripplan->error->msg;
+            } else {
             echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>";
+            echo  $tripplan->plan->date;
             echo "<h1> At: " . formatTime($tripplan->plan->date) . " </h1>";
             if (is_array($tripplan->plan->itineraries->itinerary)) {
                 echo '<div data-role="collapsible-set">';
@@ -177,6 +181,7 @@
                 echo "</div>";
             } else {
                 processItinerary(0, $tripplan->plan->itineraries->itinerary);
+            }
             }
         }
         curl_close($ch);