From: Alexander Sadleir Date: Tue, 20 Sep 2011 08:33:51 +0000 Subject: Fix some minor warning issues (index outside range etc.) X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=2fb1aedb00480c64cc9644de49f95d91151be897 --- Fix some minor warning issues (index outside range etc.) --- --- a/aws/busuiphp.sh +++ b/aws/busuiphp.sh @@ -1,4 +1,6 @@ cp /root/aws.php /tmp/ +chmod 777 /var/cache/lighttpd/compress/ + 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/* @@ -15,3 +17,4 @@ wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ -O /var/www/cbrfeed.zip + --- 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 ' @@ -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,8 @@ $basePath = ""; if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "myway/") + || strstr($_SERVER['PHP_SELF'], "lib/") + || strstr($_SERVER['PHP_SELF'], "include/") || strstr($_SERVER['PHP_SELF'], "servicealerts/")) $basePath = "../"; --- 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/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';