From: Maxious Date: Tue, 23 Aug 2011 10:45:57 +0000 Subject: Add test of protobuf GTFS-realtime conversion to PHP X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=1e2c95dada70cdbb68b896e6729ef07c135be735 --- Add test of protobuf GTFS-realtime conversion to PHP --- --- /dev/null +++ b/.gitignore @@ -1,1 +1,8 @@ +/labs/tiles/12 +/labs/tiles/13 +/labs/tiles/14 +/labs/tiles/15 +/labs/tiles/16 +/labs/tiles/17 +/labs/tiles/19 --- a/aws/busuiphp.sh +++ b/aws/busuiphp.sh @@ -2,9 +2,15 @@ mkdir /var/www/lib/staticmaplite/cache chcon -h system_u:object_r:httpd_sys_content_t /var/www chcon -R -h root:object_r:httpd_sys_content_t /var/www/* + chcon -R -t httpd_sys_content_rw_t /var/www/lib/staticmaplite/cache chmod -R 777 /var/www/lib/staticmaplite/cache + chcon -R -t httpd_sys_content_rw_t /var/www/labs/tiles chmod -R 777 /var/www/labs/tiles + +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 + wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ -O /var/www/cbrfeed.zip --- /dev/null +++ b/include/common-auth.inc.php @@ -1,1 +1,91 @@ + 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") { + die("Access Denied"); + } else { + $_SESSION['authed'] = true; + } + } else { + login(); + } + } + if ($_REQUEST['janrain_nonce']) auth(); +?> --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -159,8 +159,8 @@ if ($serviceAlertsEnabled) { $serviceAlerts = getServiceAlerts("network","network"); foreach ($serviceAlerts['entities'] as $entity) { - echo "
".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']))."
Warning: {$entity['alert']['description']['translation']} -
Source
"; + echo "
".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']}
Warning: {$entity['alert']['description_text']['translation']['text']} +
Source
"; } } } --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -45,6 +45,32 @@ return ""; } } + +$serviceAlertCause = Array( +"UNKNOWN_CAUSE" => "Unknown cause", +"OTHER_CAUSE" => "Other cause", +"TECHNICAL_PROBLEM" => "Technical problem", +"STRIKE" => "Strike", +"DEMONSTRATION" => "Demonstration", +"ACCIDENT" => "Accident", +"HOLIDAY" => "Holiday", +"WEATHER" => "Weather", +"MAINTENANCE" => "Maintenance", +"CONSTRUCTION" => "Construction", +"POLICE_ACTIVITY" => "Police activity", +"MEDICAL_EMERGENCY" => "Medical emergency" +); +$serviceAlertEffect = Array( +"NO_SERVICE" => "No service", +"REDUCED_SERVICE" => "Reduced service", +"SIGNIFICANT_DELAYS" => "Significant delays", +"DETOUR" => "Detour", +"ADDITIONAL_SERVICE" => "Additional service", +"MODIFIED_SERVICE" => "Modified service", +"OTHER_EFFECT" => "Other effect", +"UNKNOWN_EFFECT" => "Unknown effect", +"STOP_MOVED" => "Stop moved"); + function getServiceAlerts($filter_class, $filter_id) { /* @@ -66,8 +92,9 @@ route patch: trip remove */ $return = Array(); -$return['header']['gtrtfs_version'] = "1"; +$return['header']['gtfs_realtime_version'] = "1"; $return['header']['timestamp'] = time(); +$return['header']['incrementality'] = "FULL_DATASET"; $return['entities'] = Array(); foreach(getCurrentAlerts() as $alert) { $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']); @@ -76,8 +103,12 @@ $entity['id'] = $alert['id']; $entity['alert']['active_period']['start'] = $alert['start']; $entity['alert']['active_period']['end'] = $alert['end']; - $entity['alert']['url']['translation'] = $alert['url']; - $entity['alert']['description']['translation'] = $alert['description']; + $entity['alert']['url']['translation']['text'] = $alert['url']; + $entity['alert']['url']['translation']['language'] = 'en'; + $entity['alert']['header_text']['translation']['text'] = $alert['header']; + $entity['alert']['header_text']['translation']['language'] = 'en'; + $entity['alert']['description_text']['translation']['text'] = $alert['description']; + $entity['alert']['description_text']['translation']['language'] = 'en'; foreach ($informedEntities as $informedEntity) { $informed = Array(); --- a/include/common.inc.php +++ b/include/common.inc.php @@ -43,6 +43,7 @@ include_once ("common-request.inc.php"); include_once ("common-session.inc.php"); +include_once ("common-auth.inc.php"); include_once ("common-template.inc.php"); @@ -55,6 +56,7 @@ global $debugOkay; return in_array($debugReason, $debugOkay, false) && isDebugServer(); } + function debug($msg, $debugReason = "other") { if (isDebug($debugReason)) echo "\n\n"; @@ -187,5 +189,6 @@ } return implode( $glue, $retVal ); } + ?> --- a/include/db/trip-dao.inc.php +++ b/include/db/trip-dao.inc.php @@ -215,14 +215,14 @@ } return $query -> fetchAll(); } -function viaPoints($tripID, $stop_sequence = "") +function viaPoints($tripID, $stop_sequence = "", $timing_points_only = true) { global $conn; $query = "SELECT stops.stop_id, stop_name, arrival_time FROM stop_times join stops on stops.stop_id = stop_times.stop_id WHERE stop_times.trip_id = :tripID -" . ($stop_sequence != "" ? " AND stop_sequence > :stop_sequence " : "") . "AND substr(stop_code,1,2) != 'Wj' ORDER BY stop_sequence"; +" . ($stop_sequence != "" ? " AND stop_sequence > :stop_sequence " : "") . ($timing_points_only ? "AND substr(stop_code,1,2) != 'Wj' ": ""). " ORDER BY stop_sequence"; debug($query, "database"); $query = $conn -> prepare($query); if ($stop_sequence != "") $query -> bindParam(":stop_sequence", $stop_sequence); --- a/labs/index.php +++ b/labs/index.php @@ -1,6 +1,18 @@ +
  • Admin Features
  • +
  • myway_timeliness_calculate

    +

    myway_timeliness_calculate

  • +
  • myway_timeliness_reconcile

    +

    myway_timeliness_reconcile

  • +
  • servicealert_editor

    +

    servicealert_editor

  • + '; + } ?>