Fix stops by suburb
--- a/feedback.php
+++ b/feedback.php
@@ -31,7 +31,7 @@
} else {
$stopid = "";
$stopcode = "";
-$urlparts = explode("?",$_SERVER["HTTP_REFERER"]);
+if (isset($_SERVER["HTTP_REFERER"])) $urlparts = explode("?",$_SERVER["HTTP_REFERER"]);
if (isset($urlparts[1])) {
$getparams = explode("&",$urlparts[1]);
foreach ($getparams as $param) {
@@ -60,7 +60,7 @@
</textarea>
<textarea name="extrainfo" id="extrainfo">
<?php
- echo "Referrer URL: ".$_SERVER["HTTP_REFERER"];
+ echo "Referrer URL: ".($_SERVER["HTTP_REFERER"] ? $_SERVER["HTTP_REFERER"] : "");
echo "\nCurrent page URL: ".curPageURL();
echo "\nUser Agent: ".$_SERVER["HTTP_USER_AGENT"];
echo "\nUser host/IP: ".$_SERVER["HTTP_X_FORWARDED_FOR"]." ".$_SERVER["REMOTE_ADDR"];
--- a/include/common-db.inc.php
+++ b/include/common-db.inc.php
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-if (php_uname('n') == "actbus-www") {
+if (strstr(php_uname('n'),"actbus")) {
$conn = new PDO("pgsql:dbname=transitdata;user=transitdata;password=transitdata;host=bus-main.lambdacomplex.org");
} else if (isDebugServer()) {
$conn = new PDO("pgsql:dbname=transitdata;user=postgres;password=snmc;host=localhost");
--- a/include/common-request.inc.php
+++ b/include/common-request.inc.php
@@ -58,7 +58,7 @@
$stopids = explode(",", filter_var($_REQUEST['stopids'], FILTER_SANITIZE_STRING));
}
if (isset($_REQUEST['tripid'])) {
- $tripid = filter_var($_REQUEST['tripid'], FILTER_SANITIZE_NUMBER_INT);
+ $tripid = filter_var($_REQUEST['tripid'], FILTER_SANITIZE_STRING);
}
if (isset($_REQUEST['stopid'])) {
$stopid = filter_var($_REQUEST['stopid'], FILTER_SANITIZE_NUMBER_INT);
--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -27,7 +27,7 @@
$url.= $GA_PIXEL . "?";
$url.= "utmac=" . $GA_ACCOUNT;
$url.= "&utmn=" . rand(0, 0x7fffffff);
- $referer = $_SERVER["HTTP_REFERER"];
+ $referer = (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "");
$query = $_SERVER["QUERY_STRING"];
$path = $_SERVER["REQUEST_URI"];
if (empty($referer)) {
@@ -241,5 +241,36 @@
}
}
+//stop list collapsing
+function stopCompare($stopName) {
+ return substr(trim(preg_replace("/\(Platform.*/", "", $stopName)),0,9);
+}
+function stopGroupTitle($stopName,$stopdesc) {
+ if (preg_match("/Dr |Cct |Cir |Av |St |Cr |Parade |Way |Bank /",$stopName)) {
+ $descParts = explode("<br>",$stopdesc);
+ return trim(str_replace("Street: ","",$descParts[0]));
+ } else {
+ return trim(preg_replace("/\(Platform.*/", "",$stopName));
+ }
+}
+
+function viaPointNames($tripid, $stop_sequence = "") {
+ $viaPointNames = Array();
+ foreach (viaPoints($tripid, $stop_sequence) as $point) {
+ if (strstr($point['stop_name'], "Station")
+ || strstr($point['stop_name'], "Shops")
+ || strstr($point['stop_name'], "CIT")
+ || strstr($point['stop_name'], "School")
+ || strstr($point['stop_name'], "University")
+ ) {
+ $viaPointNames[] = $point['stop_name'];
+ }
+ }
+ if (sizeof($viaPointNames) > 0) {
+ return r_implode(", ", $viaPointNames);
+ } else {
+ return "";
+ }
+}
?>
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -31,7 +31,7 @@
$cloudmadeAPIkey = "daa03470bb8740298d4b10e3f03d63e6";
$googleMapsAPIkey = "ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q";
$otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/';
-if (isDebug("awsotp") || php_uname('n') == "maxious.xen.prgmr.com") {
+if (isDebug("awsotp") || php_uname('n') == "maxious.xen.prgmr.com" || strstr(php_uname('n'),"actbus")) {
$otpAPIurl = 'http://bus-main.lambdacomplex.org:8080/opentripplanner-api-webapp/';
}
if (isDebug("dotcloudotp") || php_uname('n') == "actbus-www") {
@@ -56,7 +56,7 @@
function isDebugServer() {
- return php_sapi_name() == "cli" || isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "azusa" || $_SERVER['SERVER_NAME'] == "vanille"
+ return php_sapi_name() == "cli" || strstr(php_uname('n'),"actbus") || isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "azusa" || $_SERVER['SERVER_NAME'] == "vanille"
|| $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" || $_SERVER['SERVER_NAME'] == "192.168.1.8");
}
--- a/include/db/stop-dao.inc.php
+++ b/include/db/stop-dao.inc.php
@@ -101,10 +101,10 @@
function getStopsBySuburb($suburb) {
global $conn;
- $query = "Select * from stops where zone_id LIKE :suburb order by stop_name;";
- debug($query, "database");
- $query = $conn->prepare($query);
- $suburb = "%" . $suburb . ";%";
+ $query = "Select * from stops where stop_desc LIKE :suburb order by stop_name;";
+ debug($query, "database");
+ $query = $conn->prepare($query);
+ $suburb = "%<br>Suburb: %" . $suburb . "%";
$query->bindParam(":suburb", $suburb);
$query->execute();
if (!$query) {
--- a/include/db/trip-dao.inc.php
+++ b/include/db/trip-dao.inc.php
@@ -28,6 +28,7 @@
$query->execute();
if (!$query) {
databaseError($conn->errorInfo());
+
return Array();
}
return $query->fetch(PDO :: FETCH_ASSOC);
@@ -56,7 +57,8 @@
function getTripStopTimes($tripID) {
global $conn;
- $query = "SELECT stop_times.trip_id,trip_headsign,arrival_time,stop_times.stop_id,stop_lat,stop_lon,stop_name,stop_code,
+ $query = "SELECT stop_times.trip_id,trip_headsign,arrival_time,stop_times.stop_id
+ ,stop_lat,stop_lon,stop_name,stop_desc,stop_code,
stop_sequence,service_id,trips.route_id,route_short_name,route_long_name
FROM stop_times
join trips on trips.trip_id = stop_times.trip_id
@@ -83,6 +85,7 @@
}
return Array();
}
+
function getTripStartTime($tripID) {
global $conn;
$query = "Select * from stop_times
@@ -154,16 +157,5 @@
return $query->fetchAll();
}
-function viaPointNames($tripid, $stop_sequence = "") {
- $viaPointNames = Array();
- foreach (viaPoints($tripid, $stop_sequence) as $point) {
- $viaPointNames[] = $point['stop_name'];
- }
- if (sizeof($viaPointNames) > 0) {
- return r_implode(", ", $viaPointNames);
- } else {
- return "";
- }
-}
?>
--- a/stopList.php
+++ b/stopList.php
@@ -17,17 +17,7 @@
*/
include ('include/common.inc.php');
$stops = Array();
-function stopCompare($stopName) {
- return substr(trim(preg_replace("/\(Platform.*/", "", $stopName)),0,9);
-}
-function stopGroupTitle($stopName,$stopdesc) {
- if (preg_match("/Dr |Cct |Cir |Av |St |Cr |Parade |Way |Bank /",$stopName)) {
- $descParts = explode("<br>",$stopdesc);
- return trim(str_replace("Street: ","",$descParts[0]));
- } else {
- return trim(preg_replace("/\(Platform.*/", "",$stopName));
- }
-}
+
function navbar() {
echo '
<div data-role="navbar">
@@ -149,7 +139,7 @@
} else {
// subsequent duplicates
$stopsGrouped["stop_ids"][] = $stop['stop_id'];
- ;
+
}
}
}
--- a/trip.php
+++ b/trip.php
@@ -24,7 +24,6 @@
$trip = getTrip($tripid);
$routeid = $trip["route_id"];
}
-
include_header("Stops on " . $trip['route_short_name'] . ' ' . $trip['route_long_name'], "trip");
trackEvent("Route/Trip View", "View Route", $trip['route_short_name'] . ' ' . $trip['route_long_name'], $routeid);
echo '<span class="content-secondary">';
@@ -69,9 +68,9 @@
$tripStopTimes = getTripStopTimes($tripid);
echo '<li data-role="list-divider">' . $tripStopTimes[0]['arrival_time'] . ' to ' . $tripStopTimes[sizeof($tripStopTimes) - 1]['arrival_time'] . ' ' . $trip['route_long_name'] . ' (' . ucwords($tripStopTimes[0]['service_id']) . ')</li>';
foreach ($tripStopTimes as $key => $tripStopTime) {
- if ($key + 1 > sizeof($tripStopTimes) || ($tripStopTimes[$key]["stop_name"] != $tripStopTimes[$key + 1]["stop_name"])) {
+ if ($key + 1 > sizeof($tripStopTimes) || stopCompare($tripStopTimes[$key]["stop_name"]) != stopCompare($tripStopTimes[$key + 1]["stop_name"])) {
echo '<li>';
-
+
if (sizeof($stopsGrouped) > 0) {
// print and empty grouped stops
// subsequent duplicates
@@ -83,7 +82,8 @@
echo '<br>' . distance($tripStopTime['stop_lat'], $tripStopTime['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away';
}
echo '</p>';
- echo $tripStopTime["stop_name"];
+ echo stopGroupTitle($tripStopTime['stop_name'],$tripStopTime['stop_desc']) . '<br><small>' . sizeof($stopsGrouped["stop_ids"]) . ' stops</small>';
+
echo '</a></li>';
flush();
@ob_flush();
@@ -103,10 +103,10 @@
}
} else {
// this is a duplicated line item
- if ($key - 1 <= 0 || ($tripStopTimes[$key]['stop_name'] != $tripStopTimes[$key - 1]['stop_name'])) {
+ if ($key - 1 <= 0 || stopCompare($tripStopTimes[$key]['stop_name']) != stopCompare($tripStopTimes[$key - 1]['stop_name'])) {
// first duplicate
$stopsGrouped = Array(
- "name" => $tripStopTime['stop_name'],
+ "name" => trim(preg_replace("/\(Platform.*/", "", $stop['stop_name'])),
"startTime" => $tripStopTime['arrival_time'],
"stop_ids" => Array(
$tripStopTime['stop_id']