Add amon monitoring hook
Add amon monitoring hook

file:b/.gitmodules (new)
  [submodule "lib/amon-php"]
  path = lib/amon-php
  url = https://github.com/martinrusev/amon-php.git
 
createdb transitdata createdb transitdata
createlang -d transitdata plpgsql createlang -d transitdata plpgsql
psql -d transitdata -f /var/www/lib/postgis.sql psql -d transitdata -f /var/www/lib/postgis.sql
# curl https://github.com/maxious/ACTBus-ui/raw/master/transitdata.cbrfeed.sql.gz -o transitdata.cbrfeed.sql.gz # curl https://github.com/maxious/ACTBus-ui/raw/master/transitdata.cbrfeed.sql.gz -o transitdata.cbrfeed.sql.gz
#made with pg_dump transitdata | gzip -c > transitdata.cbrfeed.sql.gz #made with pg_dump transitdata | gzip -c > transitdata.cbrfeed.sql.gz
gunzip /var/www/transitdata.cbrfeed.sql.gz gunzip /var/www/transitdata.cbrfeed.sql.gz
psql -d transitdata -f /var/www/transitdata.cbrfeed.sql psql -d transitdata -f /var/www/transitdata.cbrfeed.sql
#createuser transitdata -SDRP #createuser transitdata -SDRP
#password transitdata #password 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 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 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,INSERT,UPDATE ON TABLE myway_routes,myway_stops TO transitdata;"
##psql -d transitdata -c "GRANT SELECT ON ALL TABLES IN SCHEMA public 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") ## 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) ##SELECT '', 'public', 'shapes', 'shape_pt', ST_CoordDim(shape_pt), ST_SRID(shape_pt), GeometryType(shape_pt)
##FROM shapes LIMIT 1; ##FROM shapes LIMIT 1;
php /var/www/updatedb.php php /var/www/updatedb.php
   
<?php <?php
header('Content-Type: application/vnd.google-earth.kml+xml'); header('Content-Type: application/vnd.google-earth.kml+xml');
include ('../include/common.inc.php'); include ('../include/common.inc.php');
  header('Content-Disposition: attachment; filename="route.' . urlencode($routeid) . '.kml"');
  $debugOkay = Array(); // disable debugging output even on dev server
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" xmlns:atom="http://www.w3.org/2005/Atom"><Document>'; <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>';
echo ' echo '
<Style id="yellowLineGreenPoly"> <Style id="ylw-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
   
  </Icon>
  </IconStyle>
   
  </Style>
  <Style id="blue-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png</href>
   
  </Icon>
  </IconStyle>
   
  </Style>
  <Style id="grn-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
   
  </Icon>
  </IconStyle>
  </Style>
  <Style id="yellowLineYellowPoly">
<LineStyle> <LineStyle>
<color>7f00ff00</color> <color>7f00ebff</color>
<width>4</width> <width>4</width>
</LineStyle> </LineStyle>
<PolyStyle> <PolyStyle>
<color>7f00ffff</color> <color>7f00ebff</color>
</PolyStyle> </PolyStyle>
</Style>'; </Style>
  <Style id="blueLineBluePoly">
  <LineStyle>
  <color>7fff0000</color>
  <width>4</width>
  </LineStyle>
  <PolyStyle>
  <color>7fff0000</color>
  </PolyStyle>
  </Style>
  ';
$route = getRoute($routeid); $route = getRoute($routeid);
echo "\n<Placemark>\n"; echo "\n<Placemark>\n";
$link = curPageURL()."/../trip.php?routeid=".htmlspecialchars ($route["route_id"]); $_REQUEST['time'] = "12:00";
echo "<name>".$route['route_short_name']."</name>"; $trip = getRouteNextTrip($routeid, 0);
echo '<atom:link href="'.$link.'"/>'; $link = curPageURL() . "/../trip.php?routeid=" . htmlspecialchars($route["route_id"]. "&directionid=0&tripid=".$trip['trip_id']) ;
echo '<description><![CDATA[ <a href="'.$link.'">'.$route['route_short_name']." ".$route['route_long_name']."</a>]]> </description>"; echo "<name>" . $route['route_short_name'] . " Direction 0 </name>";
echo "<styleUrl>#yellowLineGreenPoly</styleUrl>"; echo '<atom:link rel="related" href="' . $link . '"/>';
  echo '<description><![CDATA[ <a href="' . $link . '">' . $route['route_short_name'] . " Direction 0</a>]]> </description>";
  echo "<styleUrl>#yellowLineYellowPoly</styleUrl>";
   
$trip = getRouteNextTrip($routeid); echo getTripShape($trip['trip_id']);
echo getTripShape($trip['trip_id']); echo "</Placemark>\n";
  $stops = Array();
  foreach (getTripStops($trip['trip_id']) as $stop) {
  $stop['style'] = "#ylw-pushpin";
  $stops[$stop['stop_id']] = $stop;
  }
   
echo "</Placemark>\n</Document></kml>\n";  
  echo "\n<Placemark>\n";
  $trip = getRouteNextTrip($routeid, 1);
  $link = curPageURL() . "/../trip.php?routeid=" . htmlspecialchars($route["route_id"]. "&directionid=1&tripid=".$trip['trip_id']) ;
  echo "<name>" . $route['route_short_name'] . " Direction 1 </name>";
  echo '<atom:link rel="related" href="' . $link . '"/>';
  echo '<description><![CDATA[ <a href="' . $link . '">' . $route['route_short_name'] . " Direction 1</a>]]> </description>";
  echo "<styleUrl>#blueLineBluePoly</styleUrl>";
   
  echo getTripShape($trip['trip_id']);
  echo "</Placemark>\n";
  foreach (getTripStops($trip['trip_id']) as $stop) {
  if (isset($stops[$stop['stop_id']])) {
  $stop['style'] = "#grn-pushpin";
  } else {
  $stop['style'] = "#blue-pushpin";
  }
  $stops[$stop['stop_id']] = $stop;
  }
  foreach ($stops as $stop) {
  echo "\n<Placemark>\n";
  $link = curPageURL() . '/../stop.php?stopid=' . htmlspecialchars($stop['stop_id']);
  echo "<name>" . htmlspecialchars($stop['stop_name']) . "</name>";
  echo '<atom:link rel="related" href="' . $link . '"/>';
  echo '<description><![CDATA[ <a href="' . $link . '">' . htmlspecialchars($stop['stop_name']) . "</a>]]> </description>";
  echo "<styleUrl>" . $stop['style'] . "</styleUrl>";
  echo $stop['positionkml'];
  echo "</Placemark>\n";
  }
   
  echo "</Document></kml>\n";
?> ?>
   
   
<?php <?php
  header('Content-type: application/vnd.google-earth.kml+xml');
include ('../include/common.inc.php'); include ('../include/common.inc.php');
header('Content-type: application/vnd.google-earth.kml+xml'); header('Content-Disposition: attachment; filename="stops.kml"');
  $debugOkay = Array(); // disable debugging output even on dev server
//http://wiki.openstreetmap.org/wiki/OpenLayers_Dynamic_KML //http://wiki.openstreetmap.org/wiki/OpenLayers_Dynamic_KML
// Creates the KML/XML Document. // Creates the KML/XML Document.
$dom = new DOMDocument('1.0', 'UTF-8'); $dom = new DOMDocument('1.0', 'UTF-8');
// Creates the root KML element and appends it to the root document. // Creates the root KML element and appends it to the root document.
$node = $dom->createElementNS('http://earth.google.com/kml/2.1', 'kml'); $node = $dom->createElementNS('http://www.opengis.net/kml/2.2', 'kml');
$parNode = $dom->appendChild($node); $parNode = $dom->appendChild($node);
// Creates a KML Document element and append it to the KML element. // Creates a KML Document element and append it to the KML element.
$dnode = $dom->createElement('Document'); $dnode = $dom->createElement('Document');
$docNode = $parNode->appendChild($dnode); $docNode = $parNode->appendChild($dnode);
if ($suburb != "") $result_stops = getStopsBySuburb($suburb); if ($suburb != "") $result_stops = getStopsBySuburb($suburb);
else $result_stops = getStops(); else $result_stops = getStops();
foreach ($result_stops as $stop) { foreach ($result_stops as $stop) {
$description = 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $stop['stop_id'] . " <br>"; $description = '<a href="'.curPageURL() . '/../stop.php?stopid=' . $stop['stop_id'] . '">View stop page</a><br>';
// Creates a Placemark and append it to the Document. // Creates a Placemark and append it to the Document.
$node = $dom->createElement('Placemark'); $node = $dom->createElement('Placemark');
$placeNode = $docNode->appendChild($node); $placeNode = $docNode->appendChild($node);
// Creates an id attribute and assign it the value of id column. // Creates an id attribute and assign it the value of id column.
$placeNode->setAttribute('id', 'placemark' . $stop['stop_id']); $placeNode->setAttribute('id', 'placemark' . $stop['stop_id']);
// Create name, and description elements and assigns them the values of the name and address columns from the results. // Create name, and description elements and assigns them the values of the name and address columns from the results.
$nameNode = $dom->createElement('name', htmlentities($stop['stop_name'])); $nameNode = $dom->createElement('name', htmlentities($stop['stop_name']));
$descriptionNode = $dom->createElement('description', $description); $descriptionNode = $dom->createElement('description', $description);
$placeNode->appendChild($nameNode); $placeNode->appendChild($nameNode);
$placeNode->appendChild($descriptionNode); $placeNode->appendChild($descriptionNode);
// Creates a Point element. // Creates a Point element.
$pointNode = $dom->createElement('Point'); $pointNode = $dom->createElement('Point');
$placeNode->appendChild($pointNode); $placeNode->appendChild($pointNode);
// Creates a coordinates element and gives it the value of the lng and lat columns from the results. // Creates a coordinates element and gives it the value of the lng and lat columns from the results.
$coorStr = $stop['stop_lon'] . ',' . $stop['stop_lat']; $coorStr = $stop['stop_lon'] . ',' . $stop['stop_lat'];
$coorNode = $dom->createElement('coordinates', $coorStr); $coorNode = $dom->createElement('coordinates', $coorStr);
$pointNode->appendChild($coorNode); $pointNode->appendChild($coorNode);
} }
$kmlOutput = $dom->saveXML(); $kmlOutput = $dom->saveXML();
echo $kmlOutput; echo $kmlOutput;
?> ?>
   
file:b/geo/trip.kml.php (new)
  <?php
  header('Content-Type: application/vnd.google-earth.kml+xml');
  include ('../include/common.inc.php');
  header('Content-Disposition: attachment; filename="trip.' . urlencode($tripid) . '.kml"');
  $debugOkay = Array(); // disable debugging output even on dev server
  echo '<?xml version="1.0" encoding="UTF-8"?>
  <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>';
  echo '
  <Style id="ylw-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
 
  </Icon>
  </IconStyle>
 
  </Style>
  <Style id="blue-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png</href>
 
  </Icon>
  </IconStyle>
 
  </Style>
  <Style id="grn-pushpin">
  <IconStyle>
  <Icon>
  <href>http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
 
  </Icon>
  </IconStyle>
  </Style>
  <Style id="yellowLineGreenPoly">
  <LineStyle>
  <color>7f00ff00</color>
  <width>4</width>
  </LineStyle>
  <PolyStyle>
  <color>7f00ffff</color>
  </PolyStyle>
  </Style>';
  $trip = getTrip($tripid);
  echo "\n<Placemark>\n";
  $link = curPageURL() . "/../trip.php?tripid=" . htmlspecialchars($$tripid);
  echo "<name>" . $tripid . "</name>";
  echo '<atom:link rel="related" href="' . $link . '"/>';
  echo '<description><![CDATA[ <a href="' . $link . '">' . $tripid . "</a>]]> </description>";
  echo "<styleUrl>#yellowLineGreenPoly</styleUrl>";
 
 
  echo getTripShape($tripid);
 
  echo "</Placemark>\n";
  foreach (getTripStopTimes($tripid) as $stop) {
  echo "\n<Placemark>\n";
  $link = curPageURL() . '/../trip.php?tripid=' . htmlspecialchars($tripid);
  echo "<name>" . $stop['arrival_time'] . " @ " . htmlspecialchars($stop['stop_name']) . "</name>";
  echo '<atom:link rel="related" href="' . $link . '"/>';
  echo '<description><![CDATA[ <a href="' . $link . '">' . htmlspecialchars($stop['stop_name']) . "</a>]]> </description>";
  echo "<styleUrl>#blue-pushpin</styleUrl>";
  echo "<Point><coordinates>" . $stop['stop_lon'] . "," . $stop['stop_lat'] . "</coordinates></Point>";
 
  echo "</Placemark>\n";
  }
  echo "</Document></kml>\n";
  ?>
 
 
<?php <?php
require $basePath.'lib/openid.php'; require $basePath.'lib/openid.php';
$openid = new LightOpenID($_SERVER['HTTP_HOST']); $openid = new LightOpenID($_SERVER['HTTP_HOST']);
function login() function login()
{ {
global $openid; global $openid;
if(!$openid->mode) { if(!$openid->mode) {
$openid->required = array('contact/email'); $openid->required = array('contact/email');
$openid->identity = 'https://www.google.com/accounts/o8/id'; $openid->identity = 'https://www.google.com/accounts/o8/id';
header('Location: ' . $openid->authUrl()); header('Location: ' . $openid->authUrl());
} }
} }
   
   
function auth() function auth()
   
{ {
if ($_SESSION['authed'] == true) return true; if ($_SESSION['authed'] == true) return true;
global $openid; global $openid;
if($openid->mode) { if($openid->mode) {
$attr = $openid->getAttributes(); $attr = $openid->getAttributes();
if ($attr["contact/email"] != "maxious@gmail.com") { if ($attr["contact/email"] != "maxious@gmail.com") {
die("Access Denied"); die("Access Denied");
} else { } else {
$_SESSION['authed'] = true; $_SESSION['authed'] = true;
} }
} else { } else {
login(); login();
} }
} }
?>  
<?php <?php
   
/* /*
* Copyright 2010,2011 Alexander Sadleir * Copyright 2010,2011 Alexander Sadleir