define("SHUTTLE_NOTIFY_THRESHOLD", 320);

require_once("DaemonWrapper.php");

$daemon = new DaemonWrapper("shuttle");
$daemon->start($argv);

$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_lib_constants.php";
require_once LIBDIR . "GTFSReader.php";
require_once LIBDIR . "db.php";
require_once "apns_lib.php";

$all_routes = ShuttleSchedule::getRouteList();

while ($daemon->sleep(10)) {
  db::ping(); // keep the database connection running

  $time = time();
  $too_old = $time - 7200; // arbitrary 2 hour timeout threshold for now

  // only keep track of shuttles that are running
  $routes = array_filter($all_routes, array('ShuttleSchedule', 'is_running'));

  if (count($routes)) {
    foreach ($routes as $route_id) {
      // force NextBusReader to cache
      ShuttleSchedule::getNextLoop($route_id);
    }
Exemple #2
0
<?php

$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_web_constants.php";
require_once WEBROOT . "page_builder/page_header.php";
require_once LIBDIR . "GTFSReader.php";

$route_id = $_REQUEST['route'];

if (!in_array($route_id, ShuttleSchedule::getActiveRoutes())) {
  if (!in_array($route_id, ShuttleSchedule::getRouteList())) {
    $routeName = $route_id;
    $routeError = "does not exist";
  } else {
    $routeName = ShuttleSchedule::getRoute($route_id)->long_name;
    $routeError = "is not currently in service";
  }

  $not_found_text = '<p>The route ' . $routeName . ' ' . $routeError . '.  Please update your bookmarks accordingly.  For more information see the <a href="help.php">help page</a>.</p>';

  $page->prepare_error_page('Shuttle Schedule', 'shuttle', $not_found_text);

} else {

  $now = time();

  $route = ShuttleSchedule::getRoute($route_id);
  $stops = ShuttleSchedule::list_stop_times($route_id);
  $lastIndex = count($stops) - 1;
  if ($stops[$lastIndex]['gps']) {