Purge openid-php
Purge openid-php

file:a/.gitignore -> file:b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
 /labs/tiles/16
 /labs/tiles/17
 /labs/tiles/19
+/nbproject/private/

file:a/about.php -> file:b/about.php
--- a/about.php
+++ b/about.php
@@ -21,10 +21,6 @@
 , <a href="http://itunes.apple.com/au/app/act-buses/id376634797?mt=8">ACT Buses by David Sullivan</a>) 
 and Android (<a href="https://market.android.com/details?id=com.action">MyBus 2.0 by Imagine Team</a>)
 <br />
-GTFS-realtime API;
-Alerts and Trip Updates (but only Cancelled or Stop Skipped)
-Default format binary but can get JSON by adding ?ascii=yes
-<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.
 Whilst every effort has been made to ensure the high quality and accuracy of the Site, the Author makes no warranty, 

--- a/aws/busuiphp.sh
+++ b/aws/busuiphp.sh
@@ -9,6 +9,7 @@
 chcon -R -t httpd_sys_content_rw_t /var/www/labs/tiles
 chmod -R 777 /var/www/labs/tiles
 
+mkdir /var/www/lib/openid-php/oid_store
 chcon -R -t httpd_sys_content_rw_t /var/www/lib/openid-php/oid_store
 chmod -R 777 /var/www/lib/openid-php/oid_store
 

--- a/include/common-auth.inc.php
+++ b/include/common-auth.inc.php
@@ -1,83 +1,33 @@
 <?php
+require $basePath.'lib/openid.php';
+ $openid = new LightOpenID($_SERVER['HTTP_HOST']);
+ 
+function login()
+{
+ global $openid;
+ if(!$openid->mode) {
+    $openid->required = array('contact/email');
+            $openid->identity = 'https://www.google.com/accounts/o8/id';
+            header('Location: ' . $openid->authUrl());
+ }
+    } 
 
-function getScheme() {
-    $scheme = 'http';
-    if (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
-        $scheme .= 's';
-    }
-    return $scheme;
-}
 
-function getTrustRoot() {
-    return sprintf("%s://%s:%s%s/", getScheme(), $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], dirname($_SERVER['PHP_SELF']));
-}
+function auth()
 
-// Includes required files
-set_include_path(get_include_path() . PATH_SEPARATOR . $basePath . "lib/openid-php/");
-require_once "Auth/OpenID/Consumer.php";
-require_once "Auth/OpenID/FileStore.php";
-require_once "Auth/OpenID/AX.php";
-
-function login() {
-    // Just tested this with/for Google, needs trying with others ...
-    $oid_identifier = 'https://www.google.com/accounts/o8/id';
-    // Create file storage area for OpenID data
-    $store = new Auth_OpenID_FileStore('lib/openid-php/oid_store');
-    // Create OpenID consumer
-    $consumer = new Auth_OpenID_Consumer($store);
-    // Create an authentication request to the OpenID provider
-    $auth = $consumer->begin($oid_identifier);
-
-    // Create attribute request object
-    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
-    // Usage: make($type_uri, $count=1, $required=false, $alias=null)
-    $attribute[] = Auth_OpenID_AX_AttrInfo :: make('http://axschema.org/contact/email', 2, 1, 'email');
-    $attribute[] = Auth_OpenID_AX_AttrInfo :: make('http://axschema.org/namePerson/first', 1, 1, 'firstname');
-    $attribute[] = Auth_OpenID_AX_AttrInfo :: make('http://axschema.org/namePerson/last', 1, 1, 'lastname');
-
-    // Create AX fetch request
-    $ax = new Auth_OpenID_AX_FetchRequest;
-
-    // Add attributes to AX fetch request
-    foreach ($attribute as $attr) {
-        $ax->add($attr);
-    }
-
-    // Add AX fetch request to authentication request
-    $auth->addExtension($ax);
-    $_SESSION['returnURL'] = curPageURL();
-    // Redirect to OpenID provider for authentication
-    $url = $auth->redirectURL(getTrustRoot(), $_SESSION['returnURL']);
-    header('Location: ' . $url);
-}
-
-function auth() {
-    if ($_SESSION['authed'] == true)
-        return true;
-
-    // Create file storage area for OpenID data
-    $store = new Auth_OpenID_FileStore('lib/openid-php/oid_store');
-    // Create OpenID consumer
-    $consumer = new Auth_OpenID_Consumer($store);
-    // Create an authentication request to the OpenID provider
-    $response = $consumer->complete($_SESSION['returnURL']);
-
-    if ($response->status == Auth_OpenID_SUCCESS) {
-        // Get registration informations
-        $ax = new Auth_OpenID_AX_FetchResponse();
-        $obj = $ax->fromSuccessResponse($response);
-        $email = $obj->data['http://axschema.org/contact/email'][0];
-        var_dump($email);
-        if ($email != "maxious@gmail.com") {
+{
+  if ($_SESSION['authed'] == true) return true;
+ global $openid;
+  
+  if($openid->mode) {
+      $attr = $openid->getAttributes();
+        if ($attr["contact/email"] != "maxious@gmail.com") {
             die("Access Denied");
+             } else {
+               $_SESSION['authed'] = true;
+             }
         } else {
-            $_SESSION['authed'] = true;
-        }
-    } else {
         login();
-    }
-}
-
-if ($_REQUEST['janrain_nonce'])
-    auth();
+         } 
+    } 
 ?>

--- a/include/common-geo.inc.php
+++ b/include/common-geo.inc.php
@@ -1,166 +1,153 @@
 <?php
-
 // SELECT array_to_string(array(SELECT REPLACE(name_2006, ',', '\,') as name FROM suburbs order by name), ',')
 $suburbs = explode(",", "Acton,Ainslie,Amaroo,Aranda,Banks,Barton,Belconnen,Bonner,Bonython,Braddon,Bruce,Calwell,Campbell,Chapman,Charnwood,Chifley,Chisholm,City,Conder,Cook,Curtin,Deakin,Dickson,Downer,Duffy,Dunlop,Evatt,Fadden,Farrer,Fisher,Florey,Flynn,Forrest,Franklin,Fraser,Fyshwick,Garran,Gilmore,Giralang,Gordon,Gowrie,Greenway,Griffith,Gungahlin,Hackett,Hall,Harrison,Hawker,Higgins,Holder,Holt,Hughes,Hume,Isaacs,Isabella Plains,Kaleen,Kambah,Kingston,Latham,Lawson,Lyneham,Lyons,Macarthur,Macgregor,Macquarie,Mawson,McKellar,Melba,Mitchell,Monash,Narrabundah,Ngunnawal,Nicholls,Oaks Estate,O'Connor,O'Malley,Oxley,Page,Palmerston,Parkes,Pearce,Phillip,Pialligo,Red Hill,Reid,Richardson,Rivett,Russell,Scullin,Spence,Stirling,Symonston,Tharwa,Theodore,Torrens,Turner,Wanniassa,Waramanga,Watson,Weetangera,Weston,Yarralumla");
-
-function staticmap($mapPoints, $zoom = 0, $markerImage = "iconb", $collapsible = true, $twotone = false) {
-    global $basePath;
-    $width = 300;
-    $height = 300;
-    $metersperpixel[9] = 305.492 * $width;
-    $metersperpixel[10] = 152.746 * $width;
-    $metersperpixel[11] = 76.373 * $width;
-    $metersperpixel[12] = 38.187 * $width;
-    $metersperpixel[13] = 19.093 * $width;
-    $metersperpixel[14] = 9.547 * $width;
-    $metersperpixel[15] = 4.773 * $width;
-    //$metersperpixel[16] = 2.387 * $width;
-    // $metersperpixel[17]=1.193*$width;
-    $center = "";
-    $markers = "";
-    $mapwidthinmeters = 50;
-    if (sizeof($mapPoints) < 1)
-        return "map error";
-    if (sizeof($mapPoints) === 1) {
-        if ($zoom == 0)
-            $zoom = 14;
-        $markers.= "{$mapPoints[0][0]},{$mapPoints[0][1]},$markerimage";
-        $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
-    }
-    else {
-        foreach ($mapPoints as $index => $mapPoint) {
-            if ($twotone && $index == 0) {
-                $markers.= $mapPoint[0] . "," . $mapPoint[1] . "," . "iconr" . ($index + 1);
-                $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
-            } else {
-                $markers.= $mapPoint[0] . "," . $mapPoint[1] . "," . $markerImage . ($index + 1);
-            }
-            if ($index + 1 != sizeof($mapPoints))
-                $markers.= "|";
-            $dist = distance($mapPoints[0][0], $mapPoint[0][1], $mapPoint[0], $mapPoint[1]);
-            $mapwidthinmeters = ($dist > $mapwidthinmeters ? $dist : $mapwidthinmeters);
-            $totalLat+= $mapPoint[0];
-            $totalLon+= $mapPoint[1];
-        }
-        if ($zoom == 0) {
-            $mapwidthinmeters = distance($minlat, $minlon, $minlat, $maxlon);
-            foreach (array_reverse($metersperpixel, true) as $zoomLevel => $maxdistance) {
-                if ($zoom == 0 && $mapwidthinmeters * 1.5 < ($maxdistance))
-                    $zoom = $zoomLevel;
-            }
-        }
-        $center = $totalLat / sizeof($mapPoints) . "," . $totalLon / sizeof($mapPoints);
-    }
-    $output = "";
-    if ($collapsible)
-        $output.= '<div class="map" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>';
-    $output.= '<img class="map" src="' . curPageURL() . '/' . $basePath . '/lib/staticmaplite/staticmap.php?center=' . $center . '&amp;zoom=' . $zoom . '&amp;size=' . $width . 'x' . $height . '&amp;markers=' . $markers . '" width=' . $width . ' height=' . $height . '>';
-    if ($collapsible)
-        $output.= '</div>';
-    return $output;
+function staticmap($mapPoints, $zoom = 0, $markerImage = "iconb", $collapsible = true, $twotone = false)
+{
+	global $labsPath;
+	$width = 300;
+	$height = 300;
+	$metersperpixel[9] = 305.492 * $width;
+	$metersperpixel[10] = 152.746 * $width;
+	$metersperpixel[11] = 76.373 * $width;
+	$metersperpixel[12] = 38.187 * $width;
+	$metersperpixel[13] = 19.093 * $width;
+	$metersperpixel[14] = 9.547 * $width;
+	$metersperpixel[15] = 4.773 * $width;
+	//$metersperpixel[16] = 2.387 * $width;
+	// $metersperpixel[17]=1.193*$width;
+	$center = "";
+	$markers = "";
+	$mapwidthinmeters = 50;
+	if (sizeof($mapPoints) < 1) return "map error";
+	if (sizeof($mapPoints) === 1) {
+		if ($zoom == 0) $zoom = 14;
+		$markers.= "{$mapPoints[0][0]},{$mapPoints[0][1]},$markerimage";
+		$center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
+	}
+	else {
+		foreach ($mapPoints as $index => $mapPoint) {
+			if ($twotone && $index == 0) {
+				$markers.= $mapPoint[0] . "," . $mapPoint[1] . "," . "iconr" . ($index + 1);
+				$center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
+			}
+			else {
+				$markers.= $mapPoint[0] . "," . $mapPoint[1] . "," . $markerImage . ($index + 1);
+			}
+			if ($index + 1 != sizeof($mapPoints)) $markers.= "|";
+			$dist = distance($mapPoints[0][0], $mapPoint[0][1], $mapPoint[0], $mapPoint[1]);
+			$mapwidthinmeters = ($dist > $mapwidthinmeters ? $dist : $mapwidthinmeters);
+			$totalLat+= $mapPoint[0];
+			$totalLon+= $mapPoint[1];
+		}
+		if ($zoom == 0) {
+			$mapwidthinmeters = distance($minlat, $minlon, $minlat, $maxlon);
+			foreach (array_reverse($metersperpixel, true) as $zoomLevel => $maxdistance) {
+				if ($zoom == 0 && $mapwidthinmeters * 1.5 < ($maxdistance)) $zoom = $zoomLevel;
+			}
+		}
+		$center = $totalLat / sizeof($mapPoints) . "," . $totalLon / sizeof($mapPoints);
+	}
+	$output = "";
+	if ($collapsible) $output.= '<div class="map" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>';
+	$output.= '<img class="map" src="' . curPageURL() . '/' . $labsPath . '/lib/staticmaplite/staticmap.php?center=' . $center . '&amp;zoom=' . $zoom . '&amp;size=' . $width . 'x' . $height . '&amp;markers=' . $markers . '" width=' . $width . ' height=' . $height . '>';
+	if ($collapsible) $output.= '</div>';
+	return $output;
 }
-
-function distance($lat1, $lng1, $lat2, $lng2, $roundLargeValues = false) {
-    $pi80 = M_PI / 180;
-    $lat1*= $pi80;
-    $lng1*= $pi80;
-    $lat2*= $pi80;
-    $lng2*= $pi80;
-    $r = 6372.797; // mean radius of Earth in km
-    $dlat = $lat2 - $lat1;
-    $dlng = $lng2 - $lng1;
-    $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
-    $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
-    $km = $r * $c;
-    if ($roundLargeValues) {
-        if ($km < 1)
-            return floor($km * 1000);
-        else
-            return round($km, 2) . "k";
-    }
-    else
-        return floor($km * 1000);
+function distance($lat1, $lng1, $lat2, $lng2, $roundLargeValues = false)
+{
+	$pi80 = M_PI / 180;
+	$lat1*= $pi80;
+	$lng1*= $pi80;
+	$lat2*= $pi80;
+	$lng2*= $pi80;
+	$r = 6372.797; // mean radius of Earth in km
+	$dlat = $lat2 - $lat1;
+	$dlng = $lng2 - $lng1;
+	$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
+	$c = 2 * atan2(sqrt($a) , sqrt(1 - $a));
+	$km = $r * $c;
+	if ($roundLargeValues) {
+		if ($km < 1) return floor($km * 1000);
+		else return round($km, 2) . "k";
+	}
+	else return floor($km * 1000);
 }
-
-function decodePolylineToArray($encoded) {
-    // source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5
-    $length = strlen($encoded);
-    $index = 0;
-    $points = array();
-    $lat = 0;
-    $lng = 0;
-    while ($index < $length) {
-        // Temporary variable to hold each ASCII byte.
-        $b = 0;
-        // The encoded polyline consists of a latitude value followed by a
-        // longitude value.  They should always come in pairs.  Read the
-        // latitude value first.
-        $shift = 0;
-        $result = 0;
-        do {
-            // The `ord(substr($encoded, $index++))` statement returns the ASCII
-            //  code for the character at $index.  Subtract 63 to get the original
-            // value. (63 was added to ensure proper ASCII characters are displayed
-            // in the encoded polyline string, which is `human` readable)
-            $b = ord(substr($encoded, $index++)) - 63;
-            // AND the bits of the byte with 0x1f to get the original 5-bit `chunk.
-            // Then left shift the bits by the required amount, which increases
-            // by 5 bits each time.
-            // OR the value into $results, which sums up the individual 5-bit chunks
-            // into the original value.  Since the 5-bit chunks were reversed in
-            // order during encoding, reading them in this way ensures proper
-            // summation.
-            $result|= ($b & 0x1f) << $shift;
-            $shift+= 5;
-        }
-        // Continue while the read byte is >= 0x20 since the last `chunk`
-        // was not OR'd with 0x20 during the conversion process. (Signals the end)
-        while ($b >= 0x20);
-        // Check if negative, and convert. (All negative values have the last bit
-        // set)
-        $dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1));
-        // Compute actual latitude since value is offset from previous value.
-        $lat+= $dlat;
-        // The next values will correspond to the longitude for this point.
-        $shift = 0;
-        $result = 0;
-        do {
-            $b = ord(substr($encoded, $index++)) - 63;
-            $result|= ($b & 0x1f) << $shift;
-            $shift+= 5;
-        } while ($b >= 0x20);
-        $dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1));
-        $lng+= $dlng;
-        // The actual latitude and longitude values were multiplied by
-        // 1e5 before encoding so that they could be converted to a 32-bit
-        // integer representation. (With a decimal accuracy of 5 places)
-        // Convert back to original values.
-        $points[] = array(
-            $lat * 1e-5,
-            $lng * 1e-5
-        );
-    }
-    return $points;
+function decodePolylineToArray($encoded)
+{
+	// source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5
+	$length = strlen($encoded);
+	$index = 0;
+	$points = array();
+	$lat = 0;
+	$lng = 0;
+	while ($index < $length) {
+		// Temporary variable to hold each ASCII byte.
+		$b = 0;
+		// The encoded polyline consists of a latitude value followed by a
+		// longitude value.  They should always come in pairs.  Read the
+		// latitude value first.
+		$shift = 0;
+		$result = 0;
+		do {
+			// The `ord(substr($encoded, $index++))` statement returns the ASCII
+			//  code for the character at $index.  Subtract 63 to get the original
+			// value. (63 was added to ensure proper ASCII characters are displayed
+			// in the encoded polyline string, which is `human` readable)
+			$b = ord(substr($encoded, $index++)) - 63;
+			// AND the bits of the byte with 0x1f to get the original 5-bit `chunk.
+			// Then left shift the bits by the required amount, which increases
+			// by 5 bits each time.
+			// OR the value into $results, which sums up the individual 5-bit chunks
+			// into the original value.  Since the 5-bit chunks were reversed in
+			// order during encoding, reading them in this way ensures proper
+			// summation.
+			$result|= ($b & 0x1f) << $shift;
+			$shift+= 5;
+		}
+		// Continue while the read byte is >= 0x20 since the last `chunk`
+		// was not OR'd with 0x20 during the conversion process. (Signals the end)
+		while ($b >= 0x20);
+		// Check if negative, and convert. (All negative values have the last bit
+		// set)
+		$dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1));
+		// Compute actual latitude since value is offset from previous value.
+		$lat+= $dlat;
+		// The next values will correspond to the longitude for this point.
+		$shift = 0;
+		$result = 0;
+		do {
+			$b = ord(substr($encoded, $index++)) - 63;
+			$result|= ($b & 0x1f) << $shift;
+			$shift+= 5;
+		} while ($b >= 0x20);
+		$dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1));
+		$lng+= $dlng;
+		// The actual latitude and longitude values were multiplied by
+		// 1e5 before encoding so that they could be converted to a 32-bit
+		// integer representation. (With a decimal accuracy of 5 places)
+		// Convert back to original values.
+		$points[] = array(
+			$lat * 1e-5,
+			$lng * 1e-5
+		);
+	}
+	return $points;
 }
-
-function geocode($query, $giveOptions) {
-    global $cloudmadeAPIkey;
-    $url = "http://geocoding.cloudmade.com/$cloudmadeAPIkey/geocoding/v2/find.js?query=" . urlencode($query) . "&bbox=-35.5,149.00,-35.15,149.1930&return_location=true&bbox_only=true";
-    $contents = json_decode(getPage($url));
-    if ($giveOptions)
-        return $contents->features;
-    elseif (isset($contents->features[0]->centroid))
-        return $contents->features[0]->centroid->coordinates[0] . "," . $contents->features[0]->centroid->coordinates[1];
-    else
-        return "";
+function geocode($query, $giveOptions)
+{
+	global $cloudmadeAPIkey;
+	$url = "http://geocoding.cloudmade.com/$cloudmadeAPIkey/geocoding/v2/find.js?query=" . urlencode($query) . "&bbox=-35.5,149.00,-35.15,149.1930&return_location=true&bbox_only=true";
+	$contents = json_decode(getPage($url));
+	if ($giveOptions) return $contents->features;
+	elseif (isset($contents->features[0]->centroid)) return $contents->features[0]->centroid->coordinates[0] . "," . $contents->features[0]->centroid->coordinates[1];
+	else return "";
 }
-
-function reverseGeocode($lat, $lng) {
-    global $cloudmadeAPIkey;
-    $url = "http://geocoding.cloudmade.com/$cloudmadeAPIkey/geocoding/v2/find.js?around=" . $lat . "," . $lng . "&distance=closest&object_type=road";
-    $contents = json_decode(getPage($url));
-    return $contents->features[0]->properties->name;
+function reverseGeocode($lat, $lng)
+{
+	global $cloudmadeAPIkey;
+	$url = "http://geocoding.cloudmade.com/$cloudmadeAPIkey/geocoding/v2/find.js?around=" . $lat . "," . $lng . "&distance=closest&object_type=road";
+	$contents = json_decode(getPage($url));
+	return $contents->features[0]->properties->name;
 }
-
 ?>
 

--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -1,64 +1,64 @@
 <?php
-
 // Copyright 2009 Google Inc. All Rights Reserved.
 $GA_ACCOUNT = "MO-22173039-1";
 $GA_PIXEL = "/lib/ga.php";
-
-function googleAnalyticsGetImageUrl() {
-    global $GA_ACCOUNT, $GA_PIXEL;
-    //if (stristr($_SERVER['HTTP_USER_AGENT'], 'Googlebot') return "";
-    $url = "";
-    $url.= $GA_PIXEL . "?";
-    $url.= "utmac=" . $GA_ACCOUNT;
-    $url.= "&utmn=" . rand(0, 0x7fffffff);
-    $referer = $_SERVER["HTTP_REFERER"];
-    $query = $_SERVER["QUERY_STRING"];
-    $path = $_SERVER["REQUEST_URI"];
-    if (empty($referer)) {
-        $referer = "-";
-    }
-    $url.= "&utmr=" . urlencode($referer);
-    if (!empty($path)) {
-        $url.= "&utmp=" . urlencode($path);
-    }
-    $url.= "&guid=ON";
-    return str_replace("&", "&amp;", $url);
-}
-
-function include_header($pageTitle, $pageType, $opendiv = true, $geolocate = false, $datepicker = false) {
-    global $basePath, $serviceAlertsEnabled;
-    echo '
+function googleAnalyticsGetImageUrl()
+{
+	global $GA_ACCOUNT, $GA_PIXEL;
+	//if (stristr($_SERVER['HTTP_USER_AGENT'], 'Googlebot') return "";
+	$url = "";
+	$url.= $GA_PIXEL . "?";
+	$url.= "utmac=" . $GA_ACCOUNT;
+	$url.= "&utmn=" . rand(0, 0x7fffffff);
+	$referer = $_SERVER["HTTP_REFERER"];
+	$query = $_SERVER["QUERY_STRING"];
+	$path = $_SERVER["REQUEST_URI"];
+	if (empty($referer)) {
+		$referer = "-";
+	}
+	$url.= "&utmr=" . urlencode($referer);
+	if (!empty($path)) {
+		$url.= "&utmp=" . urlencode($path);
+	}
+	$url.= "&guid=ON";
+	return str_replace("&", "&amp;", $url);
+}
+function include_header($pageTitle, $pageType, $opendiv = true, $geolocate = false, $datepicker = false)
+{
+	global $labsPath,$serviceAlertsEnabled;
+	echo '
 <!DOCTYPE html> 
 <html lang="en">
 	<head>
         <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1"> 	
-<title>' . $pageTitle . ' - Canberra Bus Timetable</title>
+<title>' . $pageTitle . '</title>
         <meta name="google-site-verification" content="-53T5Qn4TB_de1NyfR_ZZkEVdUNcNFSaYKSFkWKx-sY" />
 <link rel="dns-prefetch" href="//code.jquery.com">
 <link rel="dns-prefetch" href="//ajax.googleapis.com">
-	<link rel="stylesheet"  href="' . $basePath . 'css/jquery-ui-1.8.12.custom.css" />';
-    if (isDebugServer()) {
-        $jqmcss = $basePath . 'css/jquery.mobile-1.0b2.css';
-        $jqjs = $basePath . 'js/jquery-1.6.2.min.js';
-        $jqmjs = $basePath . 'js/jquery.mobile-1.0b2.js';
-    } else {
-        $jqmcss = "//code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css";
-        $jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js";
-        $jqmjs = "//code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js";
-    }
-    echo '<link rel="stylesheet"  href="' . $jqmcss . '" />
-	<script src="' . $jqjs . '"></script>
+	<link rel="stylesheet"  href="' . $labsPath . 'css/jquery-ui-1.8.12.custom.css" />';
+	if (isDebugServer()) {
+		$jqmcss = $labsPath . 'css/jquery.mobile-1.0b2.css';
+		$jqjs = $labsPath . 'js/jquery-1.6.2.min.js';
+		$jqmjs = $labsPath . 'js/jquery.mobile-1.0b2.js';
+	}
+	else {
+		$jqmcss = "//code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css";
+		$jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js";
+		$jqmjs = "//code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js";
+	}
+	echo '<link rel="stylesheet"  href="' . $jqmcss . '" />
+	<script src="'.$jqjs.'"></script>
 		 <script>$(document).bind("mobileinit", function(){
   $.mobile.ajaxEnabled = false;
 });
 </script> 
-	<script src="' . $jqmjs . '"></script>
-
-<script src="' . $basePath . 'js/jquery.ui.core.min.js"></script>
-<script src="' . $basePath . 'js/jquery.ui.position.min.js"></script>
-<script src="' . $basePath . 'js/jquery.ui.widget.min.js"></script>
-  <script src="' . $basePath . 'js/jquery.ui.autocomplete.min.js"></script>
+	<script src="'.$jqmjs.'"></script>
+
+<script src="' . $labsPath . 'js/jquery.ui.core.min.js"></script>
+<script src="' . $labsPath . 'js/jquery.ui.position.min.js"></script>
+<script src="' . $labsPath . 'js/jquery.ui.widget.min.js"></script>
+  <script src="' . $labsPath . 'js/jquery.ui.autocomplete.min.js"></script>
   <script>
 	$(function() {
 		$( "#geolocate" ).autocomplete({
@@ -75,9 +75,8 @@
 		});
 	});
 	</script>';
-    echo '<style type="text/css">';
-    if (strstr($_SERVER['HTTP_USER_AGENT'], 'Android'))
-        echo '.ui-shadow,.ui-btn-up-a,.ui-btn-hover-a,.ui-btn-down-a,.ui-body-b,.ui-btn-up-b,.ui-btn-hover-b,
+	echo '<style type="text/css">';
+	if (strstr($_SERVER['HTTP_USER_AGENT'], 'Android')) echo '.ui-shadow,.ui-btn-up-a,.ui-btn-hover-a,.ui-btn-down-a,.ui-body-b,.ui-btn-up-b,.ui-btn-hover-b,
 .ui-btn-down-b,.ui-bar-c,.ui-body-c,.ui-btn-up-c,.ui-btn-hover-c,.ui-btn-down-c,.ui-bar-c,.ui-body-d,
 .ui-btn-up-d,.ui-btn-hover-d,.ui-btn-down-d,.ui-bar-d,.ui-body-e,.ui-btn-up-e,.ui-btn-hover-e,
 .ui-btn-down-e,.ui-bar-e,.ui-overlay-shadow,.ui-shadow,.ui-btn-active,.ui-body-a,.ui-bar-a {
@@ -85,25 +84,22 @@
  box-shadow: none;
  -webkit-box-shadow: none;
 }';
-    echo '</style>';
-    echo '<link rel="stylesheet"  href="' . $basePath . 'css/local.css.php" />';
-    if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
-        echo '<meta name="apple-mobile-web-app-capable" content="yes" />
+	echo '</style>';
+	echo '<link rel="stylesheet"  href="' . $labsPath . 'css/local.css.php" />';
+	if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
+		echo '<meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <link rel="apple-touch-startup-image" href="startup.png" />
  <link rel="apple-touch-icon" href="apple-touch-icon.png" />';
-    }
-    if ($geolocate) {
-        echo "<script>
+	}
+	if ($geolocate) {
+		echo "<script>
 
 function success(position) {
 $('#error').val('Location now detected. Please wait for data to load.');
 $('#geolocate').val(position.coords.latitude+','+position.coords.longitude);
-$.ajax({ async: false, 
-success: function(){
-	location.reload(true);
-  },
-url: \"include/common.inc.php?geolocate=yes&lat=\"+position.coords.latitude+\"&lon=\"+position.coords.longitude });
+$.ajax({ url: \"include/common.inc.php?geolocate=yes&lat=\"+position.coords.latitude+\"&lon=\"+position.coords.longitude });
+location.reload(true);
 }
 function error(msg) {
 $('#error').val('Error: '+msg);
@@ -124,12 +120,10 @@
         $('#here').show();
 });
 ";
-        if (!isset($_SESSION['lat']) || $_SESSION['lat'] == "")
-            echo "geolocate();";
-        echo "</script> ";
-    }
-    if (isAnalyticsOn())
-        echo '
+		if (!isset($_SESSION['lat']) || $_SESSION['lat'] == "") echo "geolocate();";
+		echo "</script> ";
+	}
+	if (isAnalyticsOn()) echo '
 <script type="text/javascript">' . "
 
   var _gaq = _gaq || [];
@@ -137,46 +131,47 @@
   _gaq.push(['_trackPageview']);
    _gaq.push(['_trackPageLoadTime']);
 </script>";
-    echo '</head>
+	echo '</head>
 <body>
     <div id="skip">
     <a href="#maincontent">Skip to content</a>
     </div>
  ';
-    if ($opendiv) {
-        echo '<div data-role="page"> 
+	if ($opendiv) {
+		echo '<div data-role="page"> 
 	<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>
+		<a href="' . $labsPath . '/index.php" data-icon="home" class="ui-btn-right">Home</a>
 	</div><!-- /header -->
         <a name="maincontent" id="maincontent"></a>
         <div data-role="content"> ';
-        $overrides = getServiceOverride();
-        if ($overrides['service_id']) {
-            if ($overrides['service_id'] == "noservice") {
-                echo '<div id="servicewarning">Buses are <strong>not running today</strong> due to industrial action/public holiday. See <a 
+		$overrides = getServiceOverride();
+		if ($overrides['service_id']) {
+			if ($overrides['service_id'] == "noservice") {
+				echo '<div id="servicewarning">Buses are <strong>not running today</strong> due to industrial action/public holiday. See <a 
 href="http://www.action.act.gov.au">http://www.action.act.gov.au</a> for details.</div>';
-            } else {
-                echo '<div id="servicewarning">Buses are running on an altered timetable today due to industrial action/public holiday. See <a href="http://www.action.act.gov.au">http://www.action.act.gov.au</a> for details.</div>';
-            }
-        }
-        if ($GTFSREnabled) {
-            $serviceAlerts = getServiceAlertsAsArray("agency", "0");
-            foreach ($serviceAlerts['entity'] as $entity) {
-                echo "<div id='servicewarning'>" . date("F j, g:i a", strtotime($entity['alert']['active_period'][0]['start'])) . " to " . date("F j, g:i a", strtotime($entity['alert']['active_period'][0]['end'])) . "{$entity['alert']['header_text']['translation'][0]['text']}<br>Warning: {$entity['alert']['description_text']['translation'][0]['text']} 
-			<br><a href='{$entity['alert']['url']['translation'][0]['text']}'>Source</a>  </div>";
-            }
-        }
-    }
-}
-
-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>';
-    if (isAnalyticsOn()) {
-        echo "<script>  (function() {
+			}
+			else {
+				echo '<div id="servicewarning">Buses are running on an altered timetable today due to industrial action/public holiday. See <a href="http://www.action.act.gov.au">http://www.action.act.gov.au</a> for details.</div>';
+			}
+		}
+		if ($serviceAlertsEnabled) {
+		$serviceAlerts = getServiceAlerts("network","network");
+		foreach ($serviceAlerts['entities'] as $entity) {
+			echo "<div id='servicewarning'>".date("F j, g:i a",strtotime($entity['alert']['active_period']['start']))." to ". date("F j, g:i a", strtotime($entity['alert']['active_period']['end']))."{$entity['alert']['header_text']['translation']['text']}<br>Warning: {$entity['alert']['description_text']['translation']['text']} 
+			<br><a href='{$entity['alert']['url']['translation']['text']}'>Source</a>  </div>";
+		}
+	}
+	}
+}
+function include_footer()
+{
+	global $labsPath;
+	echo '<div id="footer"><a href="' . $labsPath . 'about.php">About/Contact Us</a>&nbsp;<a href="' . $labsPath . 'feedback.php">Feedback/Bug Report</a>&nbsp;<a href="' . $labsPath . 'privacy.php">Privacy Policy</a>';
+	echo '</div>';
+	if (isAnalyticsOn()) {
+		echo "<script>  (function() {
     var ga = document.createElement('script'); ga.type = 
 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 
@@ -184,25 +179,25 @@
     var s = document.getElementsByTagName('script')[0]; 
 s.parentNode.insertBefore(ga, s);
   })();</script>";
-        $googleAnalyticsImageUrl = googleAnalyticsGetImageUrl();
-        echo '<noscript><img src="' . $googleAnalyticsImageUrl . '" /></noscript>';
-    }
-    echo "\n</div>&l