Stop using session for time/day
Stop using session for time/day

--- a/include/common-session.inc.php
+++ b/include/common-session.inc.php
@@ -17,14 +17,6 @@
  */
 // you have to open the session to be able to modify or remove it
 session_start();
-if (isset($_REQUEST['service_period'])) {
-    $_SESSION['service_period'] = filter_var($_REQUEST['service_period'], FILTER_SANITIZE_STRING);
-    sessionUpdated();
-}
-if (isset($_REQUEST['time'])) {
-    $_SESSION['time'] = filter_var($_REQUEST['time'], FILTER_SANITIZE_STRING);
-    sessionUpdated();
-}
 if (isset($_REQUEST['geolocate']) && $_REQUEST['geolocate'] != "Enter co-ordinates or address here") {
     $geocoded = false;
     if (isset($_REQUEST['lat']) && isset($_REQUEST['lon'])) {
@@ -70,7 +62,7 @@
 
 //debug(print_r($_SESSION, true) , "session");
 function current_time() {
-    return ($_SESSION['time'] ? $_SESSION['time'] : date("H:i:s"));
+    return ($_REQUEST['time'] ? $_REQUEST['time'] : date("H:i:s"));
 }
 
 ?>

--- a/include/common-transit.inc.php
+++ b/include/common-transit.inc.php
@@ -26,8 +26,8 @@
 }
 function service_period($date = "") {
 
-    if (isset($_SESSION['service_period']))
-        return $_SESSION['service_period'];
+    if (isset($_REQUEST['service_period']))
+        return $_REQUEST['service_period'];
     $override = getServiceOverride($date);
     if ($override['service_id']) {
         return service_period_day ($override['service_id']);

file:a/stop.php -> file:b/stop.php
--- a/stop.php
+++ b/stop.php
@@ -98,12 +98,14 @@
 
 // time settings
 echo '<div id="settings" data-role="collapsible" data-collapsed="true">
-<h3>Change Time (' . (isset($_SESSION['time']) ? $_SESSION['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3>
-        <form action="' . basename($_SERVER['PHP_SELF']) . "?" . $_SERVER['QUERY_STRING'] . '" method="post">
+<h3>Change Time (' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...</h3>
+        <form action="' . basename($_SERVER['PHP_SELF']) . '" method="GET">
+            <input type="hidden" name="stopid" id="stopid" value="' . (isset($_REQUEST['stopid']) ? $_REQUEST['stopid'] : "") . '"/>
+                 <input type="hidden" name="stopcode" id="stopcode" value="' . (isset($_REQUEST['stopcode']) ? $_REQUEST['stopcode'] : "") . '"/>
         <div class="ui-body"> 
     		<div data-role="fieldcontain">
 		        <label for="time"> Time: </label>
-		    	<input type="time" name="time" id="time" value="' . (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:i")) . '"/>
+		    	<input type="time" name="time" id="time" value="' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : date("H:i")) . '"/>
 			<a href="#" name="currentTime" id="currentTime" onClick="var d = new Date();' . "$('#time').val(d.getHours() +':'+ (d.getMinutes().toString().length == 1 ? '0'+ d.getMinutes():  d.getMinutes()));" . '">Current Time?</a>
 	        </div>
 		<div data-role="fieldcontain">
@@ -128,13 +130,33 @@
 } else {
     $trips = getStopTripsWithTimes($stopid);
 }
+echo "<div class='ui-header' style='overflow: visible; height: 2.5em'>";
+// later/earlier button setup
+if (sizeof($trips) == 0) {
+    $time = isset($_REQUEST['time']) ? strtotime($_REQUEST['time']) : time();
+    $earlierTime = $time - (90 * 60);
+    $laterTime = $time + (90 * 60);
+} else {
+    $earlierTime = strtotime($trips[0]['arrival_time']) - (90 * 60);
+    $laterTime = strtotime($trips[sizeof($trips) - 1]['arrival_time']) - 60;
+}
+if (sizeof($stopids) > 0) {
+    $stopidurl = "stopids=" . implode(",", $stopids);
+} else {
+    $stopidurl = "stopid=$stopid";
+}
+if (sizeof($trips) > 10) {
+    echo '<a href="stop.php?' . $stopidurl . '&service_period=' . service_period() . '&time=' . date("H:i", $laterTime) . '" data-icon="arrow-r" class="ui-btn-right">Later Trips</a>';
+}
+echo '<a href="stop.php?' . $stopidurl . '&service_period=' . service_period() . '&time=' . date("H:i", $earlierTime) . '" data-icon="arrow-l" class="ui-btn-left">Earlier Trips</a>';
+echo "</div>";
 if (sizeof($trips) == 0) {
     echo "<li style='text-align: center;'>No trips in the near future.</li>";
 } else {
     foreach ($trips as $trip) {
         echo '<li>';
-        
-                $destination = getTripDestination($trip['trip_id']);
+
+        $destination = getTripDestination($trip['trip_id']);
         echo '<a href="trip.php?stopid=' . $stopid . '&amp;tripid=' . $trip['trip_id'] . '"><h3>' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "</h3><p>";
         $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']);
         if ($viaPoints != "")

--- a/stopList.php
+++ b/stopList.php
@@ -102,7 +102,7 @@
                     // subsequent duplicates
                     $stopsGrouped["stop_ids"][] = $stop['stop_id'];
                     echo '<li>';
-                    echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '">';
+                    echo '<a href="stop.php?stopids=' . implode(",", $stopsGrouped['stop_ids']) . '&stopcodes=' . implode(",", $stopsGrouped['stop_codes']) . '">';
                     if (isset($_SESSION['lat']) && isset($_SESSION['lon'])) {
                         echo '<span class="ui-li-count">' . distance($stop['stop_lat'], $stop['stop_lon'], $_SESSION['lat'], $_SESSION['lon'], true) . 'm away</span>';
                     }