From: Maxious Date: Thu, 29 Sep 2011 08:35:53 +0000 Subject: Make geo kml work X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=04b727d9383a1195428deac5ac6acb0537580fc6 --- Make geo kml work --- --- a/aws/busuiphp.sh +++ b/aws/busuiphp.sh @@ -1,17 +1,12 @@ cp /root/aws.php /tmp/ -mkdir /var/www/lib/staticmaplite/cache +chmod 777 /var/cache/lighttpd/compress/ + 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 -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 - wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ -O /var/www/cbrfeed.zip + --- a/css/local.css.php +++ b/css/local.css.php @@ -1,13 +1,15 @@ --- a/geo/route.kml.php +++ b/geo/route.kml.php --- a/geo/stops.kml.php +++ b/geo/stops.kml.php @@ -1,4 +1,5 @@ saveXML(); echo $kmlOutput; -?> +?> + --- a/include/common-auth.inc.php +++ b/include/common-auth.inc.php @@ -1,6 +1,6 @@ $mapPoint) { if ($twotone && $index == 0) { - $markers.= $mapPoint[0] . "," . $mapPoint[1] . "," . "iconr" . ($index + 1); - $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}"; + $markers = "markerd=color:red|".$mapPoint[0] . "," . $mapPoint[1]."&markers="; } 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; + if ($numbered) { + $label = ($index > 9 ? 9 : $index); + $markers.= "markers=label:$label|" . $mapPoint[0] . "," . $mapPoint[1]; + if ($index + 1 != sizeof($mapPoints)) { + $markers.= "&"; + } + } else { + $markers.= $mapPoint[0] . "," . $mapPoint[1]; + if ($index + 1 != sizeof($mapPoints)) { + $markers.= "|"; + } + } + $index++; } } - $center = $totalLat / sizeof($mapPoints) . "," . $totalLon / sizeof($mapPoints); } $output = ""; if ($collapsible) $output.= '

Open Map...

'; - $output.= ''; + if (isIOSDevice()) $output.= ''; + else $output.= ''; + if ($collapsible) $output.= '
'; return $output; --- a/include/common-request.inc.php +++ b/include/common-request.inc.php @@ -33,10 +33,18 @@ if (isset($_REQUEST['suburb'])) { $suburb = $_REQUEST['suburb']; } -$pageKey = filter_var($_REQUEST['pageKey'], FILTER_SANITIZE_NUMBER_INT); -$lat = filter_var($_REQUEST['lat'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); -$lon = filter_var($_REQUEST['lon'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); -$max_distance = filter_var($_REQUEST['radius'], FILTER_SANITIZE_NUMBER_INT); +if (isset($_REQUEST['pageKey'])) { + $pageKey = filter_var($_REQUEST['pageKey'], FILTER_SANITIZE_NUMBER_INT); +} +if (isset($_REQUEST['lat'])) { + $lat = filter_var($_REQUEST['lat'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); +} +if (isset($_REQUEST['lon'])) { + $lon = filter_var($_REQUEST['lon'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); +} +if (isset($_REQUEST['radius'])) { + $max_distance = filter_var($_REQUEST['radius'], FILTER_SANITIZE_NUMBER_INT); +} if (isset($_REQUEST['numberSeries'])) { $numberSeries = filter_var($_REQUEST['numberSeries'], FILTER_SANITIZE_NUMBER_INT); } --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -42,7 +42,7 @@ } function include_header($pageTitle, $pageType, $opendiv = true, $geolocate = false, $datepicker = false) { - global $basePath, $serviceAlertsEnabled; + global $basePath, $GTFSREnabled; echo ' @@ -103,7 +103,7 @@ }'; echo ''; echo ''; - if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { + if (isIOSDevice()){ echo ' @@ -179,9 +179,11 @@ } if ($GTFSREnabled) { $serviceAlerts = getServiceAlertsAsArray("agency", "0"); - foreach ($serviceAlerts['entity'] as $entity) { - echo "
" . 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']}
Warning: {$entity['alert']['description_text']['translation'][0]['text']} -
Source
"; + if (isset($serviceAlerts['entity']) && sizeof($serviceAlerts['entity']) > 0) { + foreach ($serviceAlerts['entity'] as $entity) { + echo "
" . 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']}
Warning: {$entity['alert']['description_text']['translation'][0]['text']} +
Source
"; + } } } } --- a/include/common.inc.php +++ b/include/common.inc.php @@ -48,6 +48,9 @@ $basePath = ""; if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "myway/") + || strstr($_SERVER['PHP_SELF'], "lib/") + || strstr($_SERVER['PHP_SELF'], "geo/") + || strstr($_SERVER['PHP_SELF'], "include/") || strstr($_SERVER['PHP_SELF'], "servicealerts/")) $basePath = "../"; @@ -81,31 +84,15 @@ if (isDebug($debugReason)) echo "\n\n"; } - +function isIOSDevice() { + return strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPod') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad'); +} function isJQueryMobileDevice() { // http://forum.jquery.com/topic/what-is-the-best-way-to-detect-all-useragents-which-can-handle-jquery-mobile#14737000002087897 $user_agent = $_SERVER['HTTP_USER_AGENT']; return preg_match('/iphone/i', $user_agent) || preg_match('/android/i', $user_agent) || preg_match('/webos/i', $user_agent) || preg_match('/ios/i', $user_agent) || preg_match('/bada/i', $user_agent) || preg_match('/maemo/i', $user_agent) || preg_match('/meego/i', $user_agent) || preg_match('/fennec/i', $user_agent) || (preg_match('/symbian/i', $user_agent) && preg_match('/s60/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/symbian/i', $user_agent) && preg_match('/platform/i', $user_agent) && $browser['majorver'] >= 3) || (preg_match('/blackberry/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/opera mobile/i', $user_agent) && $browser['majorver'] >= 10) || (preg_match('/opera mini/i', $user_agent) && $browser['majorver'] >= 5); } -function isFastDevice() { - $ua = $_SERVER['HTTP_USER_AGENT']; - $fastDevices = Array( - "Mozilla/5.0 (X11;", - "Mozilla/5.0 (Windows;", - "Mozilla/5.0 (iP", - "Mozilla/5.0 (Linux; U; Android", - "Mozilla/4.0 (compatible; MSIE" - ); - $slowDevices = Array( - "J2ME", - "MIDP", - "Opera/", - "Mozilla/2.0 (compatible;", - "Mozilla/3.0 (compatible;" - ); - return true; -} function array_flatten($a, $f = array()) { if (!$a || !is_array($a)) --- a/include/db/servicealert-dao.inc.php +++ b/include/db/servicealert-dao.inc.php @@ -32,7 +32,7 @@ function getServiceAlert($alertID) { global $conn; - $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where id = :servicealert_id"; + $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from end) as end,cause,effect,header,description,url from servicealerts_alerts where id = :servicealert_id"; debug($query, "database"); $query = $conn->prepare($query); $query->bindParam(":servicealert_id", $alertID); @@ -87,7 +87,7 @@ function getCurrentAlerts() { global $conn; - $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start and NOW() < \"end\""; + $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start and NOW() < \"end\""; // debug($query, "database"); $query = $conn->prepare($query); $query->execute(); @@ -100,7 +100,7 @@ function getFutureAlerts() { global $conn; - $query = "SELECT id,extract('epoch', start) as start, extract('epoch', end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start or NOW() < \"end\""; + $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from end) as end,cause,effect,header,description,url from servicealerts_alerts where NOW() > start or NOW() < \"end\""; // debug($query, "database"); $query = $conn->prepare($query); $query->execute(); --- a/labs/stop.pdf.php +++ b/labs/stop.pdf.php @@ -34,7 +34,7 @@ $stop[2], $stop[3] ) - ), 0, "iconb", false) . ""; + ), 0, false) . ""; $url = $APIurl . "/json/stoptrips?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); $trips = json_decode(getPage($url)); $html.= "

"; --- a/lib/autocomplete.php +++ b/lib/autocomplete.php @@ -3,7 +3,7 @@ $result = Array(); if (isset($_REQUEST['term'])) { $term = filter_var($_REQUEST['term'], FILTER_SANITIZE_STRING); - $query = "Select stop_name,min(stop_lat) as stop_lat,min(stop_lon) as stop_lon from stops where stop_name LIKE :term group by stop_name"; + $query = "Select stop_name,min(stop_lat) as stop_lat,min(stop_lon) as stop_lon from stops where stop_name ILIKE :term group by stop_name"; $query = $conn->prepare($query); $term = "$term%"; $query->bindParam(":term", $term); --- a/lib/staticmaplite/.gitignore +++ /dev/null @@ -1,4 +1,1 @@ -cache/tiles -cache/map -cache/maps --- a/lib/staticmaplite/images/markers/GPlotter - Make Google Maps Easily.URL +++ /dev/null @@ -1,3 +1,1 @@ -[InternetShortcut] -URL=http://gplotter.offwhite.net/ --- a/lib/staticmaplite/images/markers/Google Maps Icons, Free!.URL +++ /dev/null @@ -1,3 +1,1 @@ -[InternetShortcut] -URL=http://brennan.offwhite.net/blog/2005/07/23/new-google-maps-icons-free/ --- a/lib/staticmaplite/index.html +++ /dev/null @@ -1,122 +1,1 @@ - - - - - - staticMapLite - - - -
- -
- -
-

- staticMapLite - simple map for your website -

-

-

-

- This image was created using the following simple <img> tag: -

<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" />
-

-
-
-
-

- Place Markers -

- -

- -

Add markers by appending them to the image URL: -

markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3
-

-
-
-
-

- Use Different Map Styles (Tile Sources) -

- -

-

- -
maptype=mapnik
-
-
- -
maptype=osmarenderer
-
-
- -
maptype=cycle
-
-
-

-
- -
- -
- - --- a/lib/staticmaplite/selinux-fix.sh +++ /dev/null @@ -1,3 +1,1 @@ -chcon -R -t httpd_sys_content_rw_t cache - --- a/lib/staticmaplite/staticmap.php +++ /dev/null @@ -1,273 +1,1 @@ - - * - * USAGE: - * - * staticmap.php?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mapnik&markers=40.702147,-74.015794,blues|40.711614,-74.012318,greeng|40.718217,-73.998284,redc - * - */ - -error_reporting(0); -ini_set('display_errors','off'); - -Class staticMapLite { - - protected $tileSize = 256; - protected $tileSrcUrl = array( 'mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', - 'cloudmade' => 'http://b.tile.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/1/256/{Z}/{X}/{Y}.png',); - - protected $tileDefaultSrc = 'cloudmade'; - protected $markerBaseDir = 'images/markers'; - protected $osmLogo = 'images/osm_logo.png'; - - protected $useTileCache = true; - protected $tileCacheBaseDir = './cache/tiles'; - - protected $useMapCache = true; - protected $mapCacheBaseDir = './cache/maps'; - protected $mapCacheID = ''; - protected $mapCacheFile = ''; - protected $mapCacheExtension = 'png'; - - protected $zoom, $lat, $lon, $width, $height, $markers, $image, $maptype; - protected $centerX, $centerY, $offsetX, $offsetY; - - public function __construct(){ - $this->zoom = 0; - $this->lat = 0; - $this->lon = 0; - $this->width = 500; - $this->height = 350; - $this->markers = array(); - $this->maptype = $this->tileDefaultSrc; - } - - public function parseParams(){ - global $_GET; - - // get zoom from GET paramter - $this->zoom = $_GET['zoom']?intval($_GET['zoom']):0; - if($this->zoom>18)$this->zoom = 18; - - // get lat and lon from GET paramter - list($this->lat,$this->lon) = split(',',$_GET['center']); - $this->lat = floatval($this->lat); - $this->lon = floatval($this->lon); - - // get zoom from GET paramter - if($_GET['size']){ - list($this->width, $this->height) = split('x',$_GET['size']); - $this->width = intval($this->width); - $this->height = intval($this->height); - } - if($_GET['markers']){ - $markers = split('%7C|\|',$_GET['markers']); - foreach($markers as $marker){ - list($markerLat, $markerLon, $markerImage) = split(',',$marker); - $markerLat = floatval($markerLat); - $markerLon = floatval($markerLon); - $markerImage = basename($markerImage); - $this->markers[] = array('lat'=>$markerLat, 'lon'=>$markerLon, 'image'=>$markerImage); - } - - } - if($_GET['maptype']){ - if(array_key_exists($_GET['maptype'],$this->tileSrcUrl)) $this->maptype = $_GET['maptype']; - } - } - - public function lonToTile($long, $zoom){ - return (($long + 180) / 360) * pow(2, $zoom); - } - - public function latToTile($lat, $zoom){ - return (1 - log(tan($lat * pi()/180) + 1 / cos($lat* pi()/180)) / pi()) /2 * pow(2, $zoom); - } - - public function initCoords(){ - $this->centerX = $this->lonToTile($this->lon, $this->zoom); - $this->centerY = $this->latToTile($this->lat, $this->zoom); - $this->offsetX = floor((floor($this->centerX)-$this->centerX)*$this->tileSize); - $this->offsetY = floor((floor($this->centerY)-$this->centerY)*$this->tileSize); - } - - public function createBaseMap(){ - $this->image = imagecreatetruecolor($this->width, $this->height); - $startX = floor($this->centerX-($this->width/$this->tileSize)/2); - $startY = floor($this->centerY-($this->height/$this->tileSize)/2); - $endX = ceil($this->centerX+($this->width/$this->tileSize)/2); - $endY = ceil($this->centerY+($this->height/$this->tileSize)/2); - $this->offsetX = -floor(($this->centerX-floor($this->centerX))*$this->tileSize); - $this->offsetY = -floor(($this->centerY-floor($this->centerY))*$this->tileSize); - $this->offsetX += floor($this->width/2); - $this->offsetY += floor($this->height/2); - $this->offsetX += floor($startX-floor($this->centerX))*$this->tileSize; - $this->offsetY += floor($startY-floor($this->centerY))*$this->tileSize; - - for($x=$startX; $x<=$endX; $x++){ - for($y=$startY; $y<=$endY; $y++){ - $url = str_replace(array('{Z}','{X}','{Y}'),array($this->zoom, $x, $y), $this->tileSrcUrl[$this->maptype]); - $tileImage = imagecreatefromstring($this->fetchTile($url)); - $destX = ($x-$startX)*$this->tileSize+$this->offsetX; - $destY = ($y-$startY)*$this->tileSize+$this->offsetY; - imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize); - } - } - } - - - public function placeMarkers(){ - foreach($this->markers as $marker){ - $markerLat = $marker['lat']; - $markerLon = $marker['lon']; - $markerImage = $marker['image']; - $markerIndex++; - $markerFilename = $markerImage?(file_exists($this->markerBaseDir.'/'.$markerImage.".png")?$markerImage:'lightblue'.$markerIndex):'lightblue'.$markerIndex; - if(file_exists($this->markerBaseDir.'/'.$markerFilename.".png")){ - $markerImg = imagecreatefrompng($this->markerBaseDir.'/'.$markerFilename.".png"); - } else { - $markerImg = imagecreatefrompng($this->markerBaseDir.'/lightblue1.png'); - } - $destX = floor(($this->width/2)-$this->tileSize*($this->centerX-$this->lonToTile($markerLon, $this->zoom))); - $destY = floor(($this->height/2)-$this->tileSize*($this->centerY-$this->latToTile($markerLat, $this->zoom))); - $destY = $destY - imagesy($markerImg); - - imagecopy($this->image, $markerImg, $destX, $destY, 0, 0, imagesx($markerImg), imagesy($markerImg)); - - }; -} - - - - public function tileUrlToFilename($url){ - return $this->tileCacheBaseDir."/".str_replace(array('http://'),'',$url); - } - - public function checkTileCache($url){ - $filename = $this->tileUrlToFilename($url); - if(file_exists($filename)){ - return file_get_contents($filename); - } - } - - public function checkMapCache(){ - $this->mapCacheID = md5($this->serializeParams()); - $filename = $this->mapCacheIDToFilename(); - if(file_exists($filename)) return true; - } - - public function serializeParams(){ - return join("&",array($this->zoom,$this->lat,$this->lon,$this->width,$this->height, serialize($this->markers),$this->maptype)); - } - - public function mapCacheIDToFilename(){ - if(!$this->mapCacheFile){ - $this->mapCacheFile = $this->mapCacheBaseDir."/".substr($this->mapCacheID,0,2)."/".substr($this->mapCacheID,2,2)."/".substr($this->mapCacheID,4); - } - return $this->mapCacheFile.".".$this->mapCacheExtension; - } - - - - public function mkdir_recursive($pathname, $mode){ - return mkdir($pathname, $mode, true); - } - public function writeTileToCache($url, $data){ - $filename = $this->tileUrlToFilename($url); - $this->mkdir_recursive(dirname($filename),0777); - file_put_contents($filename, $data); - } - - public function fetchTile($url){ - if($this->useTileCache && ($cached = $this->checkTileCache($url))) return $cached; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0"); - curl_setopt($ch, CURLOPT_URL, $url); - $tile = curl_exec($ch); - curl_close($ch); - if($this->useTileCache){ - $this->writeTileToCache($url,$tile); - } - return $tile; - - } - - public function copyrightNotice(){ - $logoImg = imagecreatefrompng($this->osmLogo); - imagecopy($this->image, $logoImg, imagesx($this->image)-imagesx($logoImg), imagesy($this->image)-imagesy($logoImg), 0, 0, imagesx($logoImg), imagesy($logoImg)); - - } - - public function sendHeader(){ - header('Content-Type: image/png'); - $expires = 60*60*24*14; - header("Pragma: public"); - header("Cache-Control: maxage=".$expires); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); - } - - public function makeMap(){ - $this->initCoords(); - $this->createBaseMap(); - if(count($this->markers))$this->placeMarkers(); - if($this->osmLogo) $this->copyrightNotice(); - } - - public function showMap(){ - $this->parseParams(); - if($this->useMapCache){ - // use map cache, so check cache for map - if(!$this->checkMapCache()){ - // map is not in cache, needs to be build - $this->makeMap(); - $this->mkdir_recursive(dirname($this->mapCacheIDToFilename()),0777); - imagepng($this->image,$this->mapCacheIDToFilename(),9); - $this->sendHeader(); - if(file_exists($this->mapCacheIDToFilename())){ - return file_get_contents($this->mapCacheIDToFilename()); - } else { - return imagepng($this->image); - } - } else { - // map is in cache - $this->sendHeader(); - return file_get_contents($this->mapCacheIDToFilename()); - } - - } else { - // no cache, make map, send headers and deliver png - $this->makeMap(); - // $this->sendHeader(); - // do some extra compression - imagetruecolortopalette($this->image, false, 256); - return imagepng($this->image, 9, PNG_ALL_FILTERS); - - } - } - -} - -$map = new staticMapLite(); -print $map->showMap(); - -?> - --- a/myway/myway_api.json.php +++ b/myway/myway_api.json.php @@ -33,8 +33,8 @@ } } */ //set POST variables -$url = 'https://www.action.act.gov.au/ARTS/use_Funcs.asp'; -//$url = 'http://localhost/myway.htm'; +$url = 'https://www.transport.act.gov.au/ARTS/use_Funcs.asp'; +//$url = 'http://localhost/myway.html'; $field_mapping = Array( "card_number" => "SRNO", "DOBmonth" => "month", @@ -81,7 +81,7 @@ curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_REFERER, "https://www.action.act.gov.au/ARTS/getbalance.asp"); + curl_setopt($ch, CURLOPT_REFERER, "https://www.transport.act.gov.au/ARTS/getbalance.asp"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //execute post @@ -90,6 +90,39 @@ $return["error"][] = "Network error " . curl_errno($ch) . " " . curl_error($ch) . " " . $url . $fields_string; //close connection curl_close($ch); +} + +function parseTable($table,$tableName) { + global $return; + $tableColumns = Array(); + $tableColumnNum = 0; + foreach ($table->find("th") as $th) { + $tableColumns[$tableColumnNum] = cleanString($th->plaintext); + $tableColumnNum++; + } + //print_r($tableColumns); + $tableRowNum = 0; + foreach ($table->find("tr") as $tr) { + $tableColumnNum = 0; + foreach ($tr->find("td") as $td) { + if ($tableName == "myway_carddetails") { + // first table has card/cardholder details + $return[$tableName][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); + } else { + // second table has transactions + + if ($tableColumns[$tableColumnNum] == "TX Reference No / Type") { + $return[$tableName][$tableRowNum]["TX Reference No"] = substr(cleanString($td->plaintext), 0, 6); + $return[$tableName][$tableRowNum]["TX Type"] = substr(cleanString($td->plaintext), 7); + } else { + $return[$tableName][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); + } + } + //print_r($return); + $tableColumnNum++; + } + $tableRowNum++; + } } if (!isset($return['error'])) { @@ -101,43 +134,12 @@ $return['error'][] = $pageAlerts[0]->plaintext; } if (!isset($return['error'])) { - $tableNum = 0; - $tableName = Array( - 1 => "myway_carddetails", - 2 => "myway_transactions" - ); - foreach ($page->find("table") as $table) { - $tableNum++; - $tableColumns = Array(); - $tableColumnNum = 0; - foreach ($table->find("th") as $th) { - $tableColumns[$tableColumnNum] = cleanString($th->plaintext); - $tableColumnNum++; - } - //print_r($tableColumns); - $tableRowNum = 0; - foreach ($table->find("tr") as $tr) { - $tableColumnNum = 0; - foreach ($tr->find("td") as $td) { - if ($tableNum == 1) { - // first table has card/cardholder details - $return[$tableName[$tableNum]][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); - } else { - // second table has transactions - - if ($tableColumns[$tableColumnNum] == "TX Reference No / Type") { - $return[$tableName[$tableNum]][$tableRowNum]["TX Reference No"] = substr(cleanString($td->plaintext), 0, 6); - $return[$tableName[$tableNum]][$tableRowNum]["TX Type"] = substr(cleanString($td->plaintext), 7); - } else { - $return[$tableName[$tableNum]][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); - } - } - //print_r($return); - $tableColumnNum++; - } - $tableRowNum++; - } - } + $tables = $page->find(".type3"); + parseTable($tables[0], "myway_carddetails"); + + $tables = $page->find(".type2"); + parseTable($tables[0], "myway_transactions"); + } } if (sizeof($return) == 0) { --- a/myway/myway_timeliness_reconcile.php +++ b/myway/myway_timeliness_reconcile.php @@ -80,7 +80,7 @@ echo "

{$myway_stop[0]}

"; $stopNameParts = explode(" ", $myway_stop[0]); $markers = array(); - $stopKey = 1; + $stopKey = 0; $foundStops = getStops(false, "", $stopNameParts[0] . " " . $stopNameParts[1]); if (sizeof($foundStops) > 0) { echo "
"; @@ -92,7 +92,7 @@ echo ""; } echo '
" . $stopKey++ . "" . $stopResult['stop_name'] . "" . $stopResult['stop_code'] . "
'; - echo "" . staticmap($markers, 0, "icong", false) . "
\n"; + echo "" . staticmap($markers,false,false,false,true) . "
\n"; } echo '
--- a/stopList.php +++ b/stopList.php @@ -77,7 +77,7 @@ $sub_stop["stop_lon"] ); } - echo staticmap($stopPositions, 0, "iconb", true, true); + echo staticmap($stopPositions, true, true); placeSettings(); echo ''; } else if (isset($suburb)) { --- a/trip.php +++ b/trip.php @@ -69,7 +69,7 @@ $tripStopTimes = getTimeInterpolatedTrip($tripid); echo '
  • ' . $tripStopTimes[0]['arrival_time'] . ' to ' . $tripStopTimes[sizeof($tripStopTimes) - 1]['arrival_time'] . ' ' . $trip['route_long_name'] . ' (' . ucwords($tripStopTimes[0]['service_id']) . ')
  • '; foreach ($tripStopTimes as $key => $tripStopTime) { - if (($tripStopTimes[$key]["stop_name"] != $tripStopTimes[$key + 1]["stop_name"]) || $key + 1 >= sizeof($tripStopTimes)) { + if ($key + 1 > sizeof($tripStopTimes) || ($tripStopTimes[$key]["stop_name"] != $tripStopTimes[$key + 1]["stop_name"])) { echo '
  • '; if (!startsWith($tripStopTime['stop_code'], "Wj")) echo 'Timing Point'; --- a/tripPlanner.php +++ b/tripPlanner.php @@ -65,7 +65,7 @@ $leg->from->lon ); } - echo '' . staticmap($legMarkers, 0, "iconb", false) . "
    \n"; + echo '' . staticmap($legMarkers, false, false, true) . "
    \n"; echo '
      '; foreach ($itinerary->legs->leg as $legNumber => $leg) { echo '
    • '; @@ -81,7 +81,7 @@ $itinerary->legs->leg->from->lat, $itinerary->legs->leg->from->lon ) - ), 0, "iconb", false) . "
      \n"; + ), false, false, true) . "
      \n"; processLeg(0, $itinerary->legs->leg); } echo "

      "; @@ -100,7 +100,7 @@ $step->lon ); } - echo "" . staticmap($walkStepMarkers, 0, "icong", false) . "
      \n"; + echo "" . staticmap($walkStepMarkers, false, false, true) . "
      \n"; foreach ($leg->steps->walkSteps as $stepNumber => $step) { echo "Walking step " . ($stepNumber + 1) . ": "; if ($step->relativeDirection == "CONTINUE") {