@@ -24,7 +24,9 @@ discard block |
||
24 | 24 | public function __construct($dbc = null) { |
25 | 25 | $Connection = new Connection($dbc); |
26 | 26 | $this->db = $Connection->db(); |
27 | - if ($this->db === null) die('Error: No DB connection.'); |
|
27 | + if ($this->db === null) { |
|
28 | + die('Error: No DB connection.'); |
|
29 | + } |
|
28 | 30 | } |
29 | 31 | |
30 | 32 | /** |
@@ -139,7 +141,9 @@ discard block |
||
139 | 141 | $sth->closeCursor(); |
140 | 142 | if (count($row) > 0) { |
141 | 143 | return $row; |
142 | - } else return array(); |
|
144 | + } else { |
|
145 | + return array(); |
|
146 | + } |
|
143 | 147 | } |
144 | 148 | |
145 | 149 | /* |
@@ -180,7 +184,9 @@ discard block |
||
180 | 184 | $Common = new Common(); |
181 | 185 | $check_date = new Datetime($date); |
182 | 186 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
183 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
187 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
188 | + return array(); |
|
189 | + } |
|
184 | 190 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
185 | 191 | $json = $Common->getData($url); |
186 | 192 | var_dump($json); |
@@ -207,7 +213,9 @@ discard block |
||
207 | 213 | */ |
208 | 214 | |
209 | 215 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
210 | - } else return array(); |
|
216 | + } else { |
|
217 | + return array(); |
|
218 | + } |
|
211 | 219 | } |
212 | 220 | |
213 | 221 | /** |
@@ -222,7 +230,9 @@ discard block |
||
222 | 230 | date_default_timezone_set($globalTimezone); |
223 | 231 | $check_date = new Datetime($date); |
224 | 232 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
225 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
233 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
234 | + return array(); |
|
235 | + } |
|
226 | 236 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
227 | 237 | $json = $Common->getData($url); |
228 | 238 | $parsed_json = json_decode($json); |
@@ -235,7 +245,9 @@ discard block |
||
235 | 245 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
236 | 246 | |
237 | 247 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
238 | - } else return array(); |
|
248 | + } else { |
|
249 | + return array(); |
|
250 | + } |
|
239 | 251 | } |
240 | 252 | |
241 | 253 | /** |
@@ -246,7 +258,9 @@ discard block |
||
246 | 258 | private function getRyanair($callsign) { |
247 | 259 | $Common = new Common(); |
248 | 260 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
249 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
261 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
262 | + return array(); |
|
263 | + } |
|
250 | 264 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
251 | 265 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
252 | 266 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -260,8 +274,12 @@ discard block |
||
260 | 274 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
261 | 275 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
262 | 276 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
263 | - } else return array(); |
|
264 | - } else return array(); |
|
277 | + } else { |
|
278 | + return array(); |
|
279 | + } |
|
280 | + } else { |
|
281 | + return array(); |
|
282 | + } |
|
265 | 283 | } |
266 | 284 | |
267 | 285 | /** |
@@ -272,7 +290,9 @@ discard block |
||
272 | 290 | private function getSwiss($callsign) { |
273 | 291 | $Common = new Common(); |
274 | 292 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
275 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
293 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
294 | + return array(); |
|
295 | + } |
|
276 | 296 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
277 | 297 | $json = $Common->getData($url); |
278 | 298 | $parsed_json = json_decode($json); |
@@ -292,8 +312,12 @@ discard block |
||
292 | 312 | } |
293 | 313 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
294 | 314 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
295 | - } else return array(); |
|
296 | - } else return array(); |
|
315 | + } else { |
|
316 | + return array(); |
|
317 | + } |
|
318 | + } else { |
|
319 | + return array(); |
|
320 | + } |
|
297 | 321 | } |
298 | 322 | |
299 | 323 | /** |
@@ -307,12 +331,18 @@ discard block |
||
307 | 331 | $Common = new Common(); |
308 | 332 | $check_date = new Datetime($date); |
309 | 333 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
310 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
311 | - if ($globalBritishAirwaysKey == '') return array(); |
|
334 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
335 | + return array(); |
|
336 | + } |
|
337 | + if ($globalBritishAirwaysKey == '') { |
|
338 | + return array(); |
|
339 | + } |
|
312 | 340 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
313 | 341 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
314 | 342 | $json = $Common->getData($url,'get','',$headers); |
315 | - if ($json == '') return array(); |
|
343 | + if ($json == '') { |
|
344 | + return array(); |
|
345 | + } |
|
316 | 346 | $parsed_json = json_decode($json); |
317 | 347 | $flights = $parsed_json->{'FlightsResponse'}; |
318 | 348 | if (count($flights) > 0) { |
@@ -321,7 +351,9 @@ discard block |
||
321 | 351 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
322 | 352 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
323 | 353 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
324 | - } else return array(); |
|
354 | + } else { |
|
355 | + return array(); |
|
356 | + } |
|
325 | 357 | } |
326 | 358 | |
327 | 359 | /** |
@@ -335,19 +367,27 @@ discard block |
||
335 | 367 | $Common = new Common(); |
336 | 368 | $check_date = new Datetime($date); |
337 | 369 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
338 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
339 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
370 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
371 | + return array(); |
|
372 | + } |
|
373 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
374 | + return array(); |
|
375 | + } |
|
340 | 376 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
341 | 377 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
342 | 378 | $data = $Common->getData($url,'post',$post); |
343 | 379 | $parsed_data = json_decode($data); |
344 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
380 | + if (!isset($parsed_data->{'access_token'})) { |
|
381 | + return array(); |
|
382 | + } |
|
345 | 383 | $token = $parsed_data->{'access_token'}; |
346 | 384 | |
347 | 385 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
348 | 386 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
349 | 387 | $json = $Common->getData($url,'get','',$headers); |
350 | - if ($json == '') return array(); |
|
388 | + if ($json == '') { |
|
389 | + return array(); |
|
390 | + } |
|
351 | 391 | $parsed_json = json_decode($json); |
352 | 392 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
353 | 393 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -355,7 +395,9 @@ discard block |
||
355 | 395 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
356 | 396 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
357 | 397 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
358 | - } else return array(); |
|
398 | + } else { |
|
399 | + return array(); |
|
400 | + } |
|
359 | 401 | } |
360 | 402 | |
361 | 403 | /** |
@@ -369,14 +411,20 @@ discard block |
||
369 | 411 | $Common = new Common(); |
370 | 412 | $check_date = new Datetime($date); |
371 | 413 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
372 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
373 | - if ($globalTransaviaKey == '') return array(); |
|
414 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
415 | + return array(); |
|
416 | + } |
|
417 | + if ($globalTransaviaKey == '') { |
|
418 | + return array(); |
|
419 | + } |
|
374 | 420 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
375 | 421 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
376 | 422 | $headers = array('apikey: '.$globalTransaviaKey); |
377 | 423 | $json = $Common->getData($url,'get','',$headers); |
378 | 424 | //echo 'result : '.$json; |
379 | - if ($json == '') return array(); |
|
425 | + if ($json == '') { |
|
426 | + return array(); |
|
427 | + } |
|
380 | 428 | $parsed_json = json_decode($json); |
381 | 429 | |
382 | 430 | if (isset($parsed_json->{'data'}[0])) { |
@@ -385,7 +433,9 @@ discard block |
||
385 | 433 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
386 | 434 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
387 | 435 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
388 | - } else return array(); |
|
436 | + } else { |
|
437 | + return array(); |
|
438 | + } |
|
389 | 439 | } |
390 | 440 | |
391 | 441 | /** |
@@ -396,7 +446,9 @@ discard block |
||
396 | 446 | public function getTunisair($callsign) { |
397 | 447 | $Common = new Common(); |
398 | 448 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
399 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
449 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
450 | + return array(); |
|
451 | + } |
|
400 | 452 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
401 | 453 | $data = $Common->getData($url); |
402 | 454 | $table = $Common->table2array($data); |
@@ -417,7 +469,9 @@ discard block |
||
417 | 469 | $Common = new Common(); |
418 | 470 | $check_date = new Datetime($date); |
419 | 471 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
420 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
472 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
473 | + return array(); |
|
474 | + } |
|
421 | 475 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
422 | 476 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
423 | 477 | $data = $Common->getData($url); |
@@ -427,8 +481,11 @@ discard block |
||
427 | 481 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
428 | 482 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
429 | 483 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
430 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
431 | - else return array(); |
|
484 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
485 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
486 | + } else { |
|
487 | + return array(); |
|
488 | + } |
|
432 | 489 | } |
433 | 490 | return array(); |
434 | 491 | } |
@@ -443,7 +500,9 @@ discard block |
||
443 | 500 | $Common = new Common(); |
444 | 501 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
445 | 502 | $check_date = new Datetime($date); |
446 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
503 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
504 | + return array(); |
|
505 | + } |
|
447 | 506 | $url = "https://www.iberia.com/web/flightDetail.do"; |
448 | 507 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
449 | 508 | $data = $Common->getData($url,'post',$post); |
@@ -460,7 +519,9 @@ discard block |
||
460 | 519 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
461 | 520 | if ($arrivalTime == 'Hora estimada de llegada') { |
462 | 521 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
463 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
522 | + } else { |
|
523 | + $arrivalTime = substr($arrivalTime,0,5); |
|
524 | + } |
|
464 | 525 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
465 | 526 | } |
466 | 527 | } |
@@ -478,7 +539,9 @@ discard block |
||
478 | 539 | $Common = new Common(); |
479 | 540 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
480 | 541 | $check_date = new Datetime($date); |
481 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
542 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
543 | + return array(); |
|
544 | + } |
|
482 | 545 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
483 | 546 | $data = $Common->getData($url); |
484 | 547 | if ($data != '') { |
@@ -494,7 +557,9 @@ discard block |
||
494 | 557 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
495 | 558 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
496 | 559 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
497 | - } else return array(); |
|
560 | + } else { |
|
561 | + return array(); |
|
562 | + } |
|
498 | 563 | } |
499 | 564 | |
500 | 565 | |
@@ -514,7 +579,9 @@ discard block |
||
514 | 579 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
515 | 580 | $check_date = new Datetime($date); |
516 | 581 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
517 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
582 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
583 | + return array(); |
|
584 | + } |
|
518 | 585 | $data = $Common->getData($url); |
519 | 586 | if ($data != '') { |
520 | 587 | $table = $Common->text2array($data); |
@@ -538,7 +605,9 @@ discard block |
||
538 | 605 | $check_date = new Datetime($date); |
539 | 606 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
540 | 607 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
541 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
608 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
609 | + return array(); |
|
610 | + } |
|
542 | 611 | $data = $Common->getData($url); |
543 | 612 | if ($data != '') { |
544 | 613 | //echo $data; |
@@ -628,7 +697,9 @@ discard block |
||
628 | 697 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
629 | 698 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
630 | 699 | //$check_date = new Datetime($date); |
631 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
700 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
701 | + return array(); |
|
702 | + } |
|
632 | 703 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
633 | 704 | $data = $Common->getData($url,'post',$post); |
634 | 705 | if ($data != '') { |
@@ -660,11 +731,15 @@ discard block |
||
660 | 731 | $airline_icao = substr($callsign, 0, 3); |
661 | 732 | } |
662 | 733 | } |
663 | - if ($airline_icao == '') return array(); |
|
734 | + if ($airline_icao == '') { |
|
735 | + return array(); |
|
736 | + } |
|
664 | 737 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
665 | 738 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
666 | 739 | //$check_date = new Datetime($date); |
667 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
740 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
741 | + return array(); |
|
742 | + } |
|
668 | 743 | $data = $Common->getData($url); |
669 | 744 | if ($data != '') { |
670 | 745 | $table = $Common->table2array($data); |
@@ -757,10 +832,16 @@ discard block |
||
757 | 832 | if ($data != '') { |
758 | 833 | $table = $Common->table2array($data); |
759 | 834 | if (isset($table[11][1])) { |
760 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
761 | - else $departureTime = ''; |
|
762 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
763 | - else $arrivalTime = ''; |
|
835 | + if (is_numeric(substr($table[11][1],0,1))) { |
|
836 | + $departureTime = substr($table[11][1],0,5); |
|
837 | + } else { |
|
838 | + $departureTime = ''; |
|
839 | + } |
|
840 | + if (is_numeric(substr($table[17][1],0,1))) { |
|
841 | + $arrivalTime = substr($table[17][1],0,5); |
|
842 | + } else { |
|
843 | + $arrivalTime = ''; |
|
844 | + } |
|
764 | 845 | $DepartureAirportIata = substr($table[13][1],0,3); |
765 | 846 | $ArrivalAirportIata = substr($table[15][1],0,3); |
766 | 847 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
@@ -777,16 +858,22 @@ discard block |
||
777 | 858 | */ |
778 | 859 | private function getAirCanada($callsign,$date = 'NOW') { |
779 | 860 | $Common = new Common(); |
780 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
861 | + if (class_exists("DomDocument") === FALSE) { |
|
862 | + return array(); |
|
863 | + } |
|
781 | 864 | date_default_timezone_set('UTC'); |
782 | 865 | $check_date = new Datetime($date); |
783 | 866 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
784 | 867 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
785 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
868 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
869 | + return array(); |
|
870 | + } |
|
786 | 871 | $data = $Common->getData($url); |
787 | 872 | $dom = new DomDocument(); |
788 | 873 | $dom->loadXML($data); |
789 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
874 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
875 | + return array(); |
|
876 | + } |
|
790 | 877 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
791 | 878 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
792 | 879 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -795,7 +882,9 @@ discard block |
||
795 | 882 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
796 | 883 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
797 | 884 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
798 | - } else return array(); |
|
885 | + } else { |
|
886 | + return array(); |
|
887 | + } |
|
799 | 888 | } |
800 | 889 | |
801 | 890 | /** |
@@ -809,7 +898,9 @@ discard block |
||
809 | 898 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
810 | 899 | $check_date = new Datetime($date); |
811 | 900 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
812 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
901 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
902 | + return array(); |
|
903 | + } |
|
813 | 904 | $data = $Common->getData($url); |
814 | 905 | if ($data != '') { |
815 | 906 | $table = $Common->table2array($data); |
@@ -838,7 +929,9 @@ discard block |
||
838 | 929 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
839 | 930 | $check_date = new Datetime($date); |
840 | 931 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
841 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
932 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
933 | + return array(); |
|
934 | + } |
|
842 | 935 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
843 | 936 | $data = $Common->getData($url,'post',$post); |
844 | 937 | //echo $data; |
@@ -848,11 +941,19 @@ discard block |
||
848 | 941 | if ($data != '') { |
849 | 942 | $table = $Common->table2array($data); |
850 | 943 | $flight = $table; |
851 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
852 | - else $departureTime = ''; |
|
853 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
854 | - else $departureAirport = ''; |
|
855 | - } else return array(); |
|
944 | + if (isset($flight[5][4])) { |
|
945 | + $departureTime = $flight[5][4]; |
|
946 | + } else { |
|
947 | + $departureTime = ''; |
|
948 | + } |
|
949 | + if (isset($flight[5][2])) { |
|
950 | + $departureAirport = $flight[5][2]; |
|
951 | + } else { |
|
952 | + $departureAirport = ''; |
|
953 | + } |
|
954 | + } else { |
|
955 | + return array(); |
|
956 | + } |
|
856 | 957 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
857 | 958 | $data = $Common->getData($url,'post',$post); |
858 | 959 | if ($data != '') { |
@@ -865,10 +966,14 @@ discard block |
||
865 | 966 | $arrivalTime = ''; |
866 | 967 | $arrivalAirport = ''; |
867 | 968 | } |
868 | - } else return array(); |
|
969 | + } else { |
|
970 | + return array(); |
|
971 | + } |
|
869 | 972 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
870 | 973 | $json = $Common->getData($url); |
871 | - if ($json == '') return array(); |
|
974 | + if ($json == '') { |
|
975 | + return array(); |
|
976 | + } |
|
872 | 977 | $parsed_json = json_decode($json); |
873 | 978 | $airports = $parsed_json->{'suggestList'}; |
874 | 979 | if (count($airports) > 0) { |
@@ -883,7 +988,9 @@ discard block |
||
883 | 988 | } |
884 | 989 | if (isset($DepartureAirportIata)) { |
885 | 990 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
886 | - } else return array(); |
|
991 | + } else { |
|
992 | + return array(); |
|
993 | + } |
|
887 | 994 | } |
888 | 995 | |
889 | 996 | /* |
@@ -895,7 +1002,9 @@ discard block |
||
895 | 1002 | public function fetchSchedule($ident,$date = 'NOW') { |
896 | 1003 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
897 | 1004 | //$Common = new Common(); |
898 | - if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
|
1005 | + if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
1006 | + return array(); |
|
1007 | + } |
|
899 | 1008 | $airline_icao = ''; |
900 | 1009 | if (!is_numeric(substr($ident, 0, 3))) |
901 | 1010 | { |
@@ -1130,18 +1239,27 @@ discard block |
||
1130 | 1239 | if (strlen($airline_icao) == 3) { |
1131 | 1240 | $Spotter = new Spotter($this->db); |
1132 | 1241 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
1133 | - if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata']; |
|
1242 | + if (isset($airline_info[0]['iata'])) { |
|
1243 | + $airline_icao = $airline_info[0]['iata']; |
|
1244 | + } |
|
1134 | 1245 | } |
1135 | 1246 | // Randomly use a generic function to get hours |
1136 | 1247 | if (strlen($airline_icao) == 2) { |
1137 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
1248 | + if (!isset($globalSchedulesSources)) { |
|
1249 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
1250 | + } |
|
1138 | 1251 | if (count($globalSchedulesSources) > 0) { |
1139 | 1252 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1140 | 1253 | $source = $globalSchedulesSources[$rand]; |
1141 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
1142 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
1254 | + if ($source == 'flightmapper') { |
|
1255 | + return $this->getFlightMapper($ident); |
|
1256 | + } elseif ($source == 'costtotravel') { |
|
1257 | + return $this->getCostToTravel($ident); |
|
1258 | + } |
|
1143 | 1259 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1144 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
1260 | + elseif ($source == 'flightaware') { |
|
1261 | + return $this->getFlightAware($ident); |
|
1262 | + } |
|
1145 | 1263 | } |
1146 | 1264 | } |
1147 | 1265 | } |