--- a/busui/tripPlanner.php +++ b/busui/tripPlanner.php @@ -100,8 +100,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 "

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

"; @@ -116,7 +119,8 @@ } else { processItinerary(0, $tripplan->plan->itineraries->itinerary); } - + } + curl_close($ch); } } else { tripPlanForm();