--- a/busui/tripPlanner.php +++ b/busui/tripPlanner.php @@ -1,31 +1,41 @@ $errorMessage"; echo '
+
+
- +
- +
'; + echo ""; } function processItinerary($itineraryNumber, $itinerary) @@ -86,14 +96,18 @@ $errorMessage .= urlencode($_REQUEST['from']) . " not found.
\n"; tripPlanForm($errorMessage); } else { - $url = "http://localhost:8080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; + $url = "http://10.1.0.243:5080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; $ch = curl_init($url); 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 "

From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name}

"; echo "

At: {$tripplan->plan->date}

"; @@ -106,10 +120,12 @@ } else { processItinerary(0, $tripplan->plan->itineraries->itinerary); } - + } + curl_close($ch); } } else { tripPlanForm(); } include_footer(); ?> +