Display which routes are modified when a stop is moved or deleted
[bus.git] / busui / tripPlanner.php
blob:a/busui/tripPlanner.php -> blob:b/busui/tripPlanner.php
--- a/busui/tripPlanner.php
+++ b/busui/tripPlanner.php
@@ -6,7 +6,8 @@
       $from = (isset($_REQUEST['from']) ? $_REQUEST['from'] : "Brigalow");
       $to = (isset($_REQUEST['to']) ? $_REQUEST['to'] : "Barry");
       $date = (isset($_REQUEST['date']) ? $_REQUEST['date'] : date("m/d/Y"));
-      $time = (isset($_REQUEST['time']) ? $_REQUEST['time'] : date("h:ia"));
+      $time = (isset($_REQUEST['time']) ? $_REQUEST['time'] : date("H:m"));
+      # todo: convert date from form to h:ia?
       echo "<font color=red>$errorMessage</font>";
       echo '<form action="tripPlanner.php" method="post">
     <div data-role="fieldcontain">
@@ -100,8 +101,11 @@
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($ch, CURLOPT_HEADER, 0);
           curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
+          curl_setopt($ch,CURLOPT_TIMEOUT,5); 
           $page = curl_exec($ch);
-          curl_close($ch);
+
+          if(curl_errno($ch)) { tripPlanForm("Trip planner temporarily unavailable: ".curl_errno($ch)." ".curl_error($ch));}
+          else {
           $tripplan = json_decode($page);
           debug(print_r($triplan,true));
           echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>";
@@ -116,7 +120,8 @@
           } else {
               processItinerary(0, $tripplan->plan->itineraries->itinerary);
           }
-          
+          }
+                    curl_close($ch);
       }
   } else {
       tripPlanForm();