Purge openid-php
Purge openid-php

file:a/.gitignore -> file:b/.gitignore
   
/labs/tiles/12 /labs/tiles/12
/labs/tiles/13 /labs/tiles/13
/labs/tiles/14 /labs/tiles/14
/labs/tiles/15 /labs/tiles/15
/labs/tiles/16 /labs/tiles/16
/labs/tiles/17 /labs/tiles/17
/labs/tiles/19 /labs/tiles/19
  /nbproject/private/
cp /root/aws.php /tmp/ cp /root/aws.php /tmp/
mkdir /var/www/lib/staticmaplite/cache mkdir /var/www/lib/staticmaplite/cache
chcon -h system_u:object_r:httpd_sys_content_t /var/www 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 -h root:object_r:httpd_sys_content_t /var/www/*
   
chcon -R -t httpd_sys_content_rw_t /var/www/lib/staticmaplite/cache chcon -R -t httpd_sys_content_rw_t /var/www/lib/staticmaplite/cache
chmod -R 777 /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 chcon -R -t httpd_sys_content_rw_t /var/www/labs/tiles
chmod -R 777 /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 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 chmod -R 777 /var/www/lib/openid-php/oid_store
   
wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \
-O /var/www/cbrfeed.zip -O /var/www/cbrfeed.zip
<?php <?php
function getScheme() require $basePath.'lib/openid.php';
{ $openid = new LightOpenID($_SERVER['HTTP_HOST']);
$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']));  
}  
   
   
// Includes required files  
set_include_path(get_include_path() . PATH_SEPARATOR . $labsPath."lib/openid-php/");  
require_once "Auth/OpenID/Consumer.php";  
require_once "Auth/OpenID/FileStore.php";  
require_once "Auth/OpenID/AX.php";  
   
   
   
function login() function login()
{ {
// Just tested this with/for Google, needs trying with others ... global $openid;
$oid_identifier = 'https://www.google.com/accounts/o8/id'; if(!$openid->mode) {
// Create file storage area for OpenID data $openid->required = array('contact/email');
$store = new Auth_OpenID_FileStore('lib/openid-php/oid_store'); $openid->identity = 'https://www.google.com/accounts/o8/id';
// Create OpenID consumer header('Location: ' . $openid->authUrl());
$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() function auth()
   
{ {
if ($_SESSION['authed'] == true) return true; if ($_SESSION['authed'] == true) return true;
  global $openid;
// Create file storage area for OpenID data  
$store = new Auth_OpenID_FileStore('lib/openid-php/oid_store'); if($openid->mode) {
// Create OpenID consumer $attr = $openid->getAttributes();
$consumer = new Auth_OpenID_Consumer($store); if ($attr["contact/email"] != "maxious@gmail.com") {
// 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"); die("Access Denied");
} else { } else {
$_SESSION['authed'] = true; $_SESSION['authed'] = true;
} }
} else { } else {
login(); login();
} }
} }
if ($_REQUEST['janrain_nonce']) auth();  
?> ?>
<?php <?php
$service_periods = Array( $service_periods = Array(
'sunday', 'sunday',
'saturday', 'saturday',
'weekday' 'weekday'
); );
   
function service_period($date = "") function service_period($date = "")
{ {
if (isset($_SESSION['service_period'])) return $_SESSION['service_period']; if (isset($_SESSION['service_period'])) return $_SESSION['service_period'];
$override = getServiceOverride($date); $override = getServiceOverride($date);
if ($override['service_id']){ if ($override['service_id']){
return $override['service_id']; return $override['service_id'];
} }
   
switch (date('w',($date != "" ? $date : time()))) { switch (date('w',($date != "" ? $date : time()))) {
case 0: case 0:
return 'sunday'; return 'sunday';
case 6: case 6:
return 'saturday'; return 'saturday';
default: default:
return 'weekday'; return 'weekday';
} }
} }
function midnight_seconds($time = "") function midnight_seconds($time = "")
{ {
// from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html // from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html
if ($time != "") { if ($time != "") {
return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time); return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time);
} }
if (isset($_SESSION['time'])) { if (isset($_SESSION['time'])) {
$time = strtotime($_SESSION['time']); $time = strtotime($_SESSION['time']);
return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time); return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time);
} }
return (date("G") * 3600) + (date("i") * 60) + date("s"); return (date("G") * 3600) + (date("i") * 60) + date("s");
} }
function midnight_seconds_to_time($seconds) function midnight_seconds_to_time($seconds)
{ {
if ($seconds > 0) { if ($seconds > 0) {
$midnight = mktime(0, 0, 0, date("n") , date("j") , date("Y")); $midnight = mktime(0, 0, 0, date("n") , date("j") , date("Y"));
return date("h:ia", $midnight + $seconds); return date("h:ia", $midnight + $seconds);
} }
else { else {
return ""; return "";
} }
} }
   
$serviceAlertCause = Array( $serviceAlertCause = Array(
UNKNOWN_CAUSE "UNKNOWN_CAUSE" => "Unknown cause",
OTHER_CAUSE "OTHER_CAUSE" => "Other cause",
TECHNICAL_PROBLEM "TECHNICAL_PROBLEM" => "Technical problem",
STRIKE "STRIKE" => "Strike",
DEMONSTRATION "DEMONSTRATION" => "Demonstration",
ACCIDENT "ACCIDENT" => "Accident",
HOLIDAY "HOLIDAY" => "Holiday",
WEATHER "WEATHER" => "Weather",
MAINTENANCE "MAINTENANCE" => "Maintenance",
CONSTRUCTION "CONSTRUCTION" => "Construction",
POLICE_ACTIVITY "POLICE_ACTIVITY" => "Police activity",
MEDICAL_EMERGENCY "MEDICAL_EMERGENCY" => "Medical emergency"
   
Unknown cause  
Other cause (not represented by any of these options)  
Technical problem  
Strike  
Demonstration  
Accident  
Holiday  
Weather  
Maintenance  
Construction  
Police activity  
Medical emergency  
); );
$serviceAlertEffect = Array( $serviceAlertEffect = Array(
NO_SERVICE "NO_SERVICE" => "No service",
REDUCED_SERVICE "REDUCED_SERVICE" => "Reduced service",
SIGNIFICANT_DELAYS "SIGNIFICANT_DELAYS" => "Significant delays",
DETOUR "DETOUR" => "Detour",
ADDITIONAL_SERVICE "ADDITIONAL_SERVICE" => "Additional service",
MODIFIED_SERVICE "MODIFIED_SERVICE" => "Modified service",
OTHER_EFFECT "OTHER_EFFECT" => "Other effect",
UNKNOWN_EFFECT "UNKNOWN_EFFECT" => "Unknown effect",
STOP_MOVED "STOP_MOVED" => "Stop moved");
   
No service  
Reduced service  
Significant delays (insignificant delays should only be provided through Trip updates).  
Detour  
Additional service  
Modified service  
Stop moved  
Other effect (not represented by any of these options)  
Unknown effect);  
   
function getServiceAlerts($filter_class, $filter_id) { function getServiceAlerts($filter_class, $filter_id) {
/* /*
   
also need last modified epoch of client gtfs also need last modified epoch of client gtfs
- add,remove,patch,inform (null) - add,remove,patch,inform (null)
- stop - stop
- trip - trip
- network - network
- classes (WHERE=) - classes (WHERE=)
- route (short_name or route_id) - route (short_name or route_id)
- street - street
- stop - stop
- trip - trip
Currently support: Currently support:
network inform network inform
trip patch: stop remove trip patch: stop remove
street inform: route inform, trip inform, stop inform street inform: route inform, trip inform, stop inform
route patch: trip remove route patch: trip remove
*/ */
$return = Array(); $return = Array();
$return['header']['gtfs_realtime_version'] = "1"; $return['header']['gtfs_realtime_version'] = "1";
$return['header']['timestamp'] = time(); $return['header']['timestamp'] = time();
$return['header']['incrementality'] = "FULL_DATASET"; $return['header']['incrementality'] = "FULL_DATASET";
$return['entities'] = Array(); $return['entities'] = Array();
foreach(getCurrentAlerts() as $alert) { foreach(getCurrentAlerts() as $alert) {
$informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']); $informedEntities = getInformedAlerts($alert['id'],$_REQUEST['filter_class'],$_REQUEST['filter_id']);
if (sizeof($informedEntities) >0) { if (sizeof($informedEntities) >0) {
$entity = Array(); $entity = Array();
$entity['id'] = $alert['id']; $entity['id'] = $alert['id'];
$entity['alert']['active_period']['start'] = $alert['start']; $entity['alert']['active_period']['start'] = $alert['start'];
$entity['alert']['active_period']['end'] = $alert['end']; $entity['alert']['active_period']['end'] = $alert['end'];
$entity['alert']['url']['translation']['text'] = $alert['url']; $entity['alert']['url']['translation']['text'] = $alert['url'];
$entity['alert']['url']['translation']['language'] = 'en'; $entity['alert']['url']['translation']['language'] = 'en';
$entity['alert']['header_text']['translation']['text'] = $alert['header']; $entity['alert']['header_text']['translation']['text'] = $alert['header'];
$entity['alert']['header_text']['translation']['language'] = 'en'; $entity['alert']['header_text']['translation']['language'] = 'en';
$entity['alert']['description_text']['translation']['text'] = $alert['description']; $entity['alert']['description_text']['translation']['text'] = $alert['description'];
$entity['alert']['description_text']['translation']['language'] = 'en'; $entity['alert']['description_text']['translation']['language'] = 'en';
foreach ($informedEntities as $informedEntity) { foreach ($informedEntities as $informedEntity) {
$informed = Array(); $informed = Array();
$informed[$informedEntity['informed_class']."_id"] = $informedEntity['informed_id']; $informed[$informedEntity['informed_class']."_id"] = $informedEntity['informed_id'];
if ($informedEntity['informed_action'] != "") $informed["x-action"] = $informedEntity['informed_action']; if ($informedEntity['informed_action'] != "") $informed["x-action"] = $informedEntity['informed_action'];
$informed[$informedEntity['class']."_type"] = $informedEntity['type']; $informed[$informedEntity['class']."_type"] = $informedEntity['type'];
$entity['informed'][] = $informed; $entity['informed'][] = $informed;
} }
$return['entities'][] = $entity; $return['entities'][] = $entity;
} }
} }
return $return; return $return;
} }
function getServiceAlertsByClass() { function getServiceAlertsByClass() {
$return = Array(); $return = Array();
$alerts = getServiceAlerts("",""); $alerts = getServiceAlerts("","");
foreach ($alerts['entities'] as $entity) { foreach ($alerts['entities'] as $entity) {
foreach ($entity['informed'] as $informed) { foreach ($entity['informed'] as $informed) {
foreach($informed as $key => $value){ foreach($informed as $key => $value){
if (strpos("_id",$key) > 0) { if (strpos("_id",$key) > 0) {
$parts = explode($key); $parts = explode($key);
$class = $parts[0]; $class = $parts[0];
$id = $value; $id = $value;
} }
} }
$return[$class][$id][]['entity'] = $entity; $return[$class][$id][]['entity'] = $entity;
$return[$class][$id][]['action'] = $informed["x-action"]; $return[$class][$id][]['action'] = $informed["x-action"];
} }
} }
} }
?> ?>