@@ -37,8 +37,11 @@ discard block |
||
| 37 | 37 | } else { |
| 38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
| 39 | 39 | } |
| 40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 40 | + if ($timeout == '') { |
|
| 41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 42 | + } else { |
|
| 43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 44 | + } |
|
| 42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
| 43 | 46 | if ($type == 'post') { |
| 44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
| 86 | 89 | //global $cookies; |
| 87 | 90 | $cookies = array(); |
| 88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
| 89 | - $cookies[] = $cookie; |
|
| 91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
| 92 | + $cookies[] = $cookie; |
|
| 93 | + } |
|
| 90 | 94 | return strlen($headerLine); // Needed by curl |
| 91 | 95 | } |
| 92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
| 97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
| 98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 104 | + if ($referer != '') { |
|
| 105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 106 | + } |
|
| 101 | 107 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 103 | 109 | curl_exec($ch); |
| 104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
| 110 | + if (curl_errno($ch) && $globalDebug) { |
|
| 111 | + echo 'Download error: '.curl_error($ch); |
|
| 112 | + } |
|
| 105 | 113 | curl_close($ch); |
| 106 | 114 | fclose($fp); |
| 107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
| 109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
| 110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 111 | 119 | $buffer_size = 4096; // read 4kb at a time |
| 112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 120 | + if ($out_file_name == '') { |
|
| 121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 122 | + } |
|
| 113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
| 114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 117 | - else { |
|
| 125 | + if (function_exists('gzopen')) { |
|
| 126 | + $file = gzopen($in_file,'rb'); |
|
| 127 | + } elseif (function_exists('gzopen64')) { |
|
| 128 | + $file = gzopen64($in_file,'rb'); |
|
| 129 | + } else { |
|
| 118 | 130 | echo 'gzopen not available'; |
| 119 | 131 | die; |
| 120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
| 130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
| 131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 132 | 144 | $buffer_size = 4096; // read 4kb at a time |
| 133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 145 | + if ($out_file_name == '') { |
|
| 146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 147 | + } |
|
| 134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
| 135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
| 137 | - else { |
|
| 150 | + if (function_exists('bzopen')) { |
|
| 151 | + $file = bzopen($in_file,'rb'); |
|
| 152 | + } else { |
|
| 138 | 153 | echo 'bzopen not available'; |
| 139 | 154 | die; |
| 140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
| 153 | 168 | * @return Array array of the tables in HTML page |
| 154 | 169 | */ |
| 155 | 170 | public function table2array($data) { |
| 156 | - if (!is_string($data)) return array(); |
|
| 157 | - if ($data == '') return array(); |
|
| 171 | + if (!is_string($data)) { |
|
| 172 | + return array(); |
|
| 173 | + } |
|
| 174 | + if ($data == '') { |
|
| 175 | + return array(); |
|
| 176 | + } |
|
| 158 | 177 | $html = str_get_html($data); |
| 159 | - if ($html === false) return array(); |
|
| 178 | + if ($html === false) { |
|
| 179 | + return array(); |
|
| 180 | + } |
|
| 160 | 181 | $tabledata=array(); |
| 161 | 182 | foreach($html->find('tr') as $element) |
| 162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
| 191 | 212 | */ |
| 192 | 213 | public function text2array($data) { |
| 193 | 214 | $html = str_get_html($data); |
| 194 | - if ($html === false) return array(); |
|
| 215 | + if ($html === false) { |
|
| 216 | + return array(); |
|
| 217 | + } |
|
| 195 | 218 | $tabledata=array(); |
| 196 | 219 | foreach($html->find('p') as $element) |
| 197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
| 212 | 235 | * @return Float Distance in $unit |
| 213 | 236 | */ |
| 214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
| 238 | + if ($lat == $latc && $lon == $lonc) { |
|
| 239 | + return 0; |
|
| 240 | + } |
|
| 216 | 241 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
| 217 | 242 | if ($unit == "km") { |
| 218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
| 236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
| 237 | 262 | $x = abs($timeDifference); |
| 238 | 263 | $d = abs($distance); |
| 239 | - if ($x == 0 || $d == 0) return true; |
|
| 264 | + if ($x == 0 || $d == 0) { |
|
| 265 | + return true; |
|
| 266 | + } |
|
| 240 | 267 | // may be due to Internet jitter; distance is realistic |
| 241 | - if ($x < 0.7 && $d < 2000) return true; |
|
| 242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
| 268 | + if ($x < 0.7 && $d < 2000) { |
|
| 269 | + return true; |
|
| 270 | + } else { |
|
| 271 | + return $d/$x < 1500*0.27778; |
|
| 272 | + } |
|
| 273 | + // 1500 km/h max |
|
| 243 | 274 | } |
| 244 | 275 | |
| 245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
| 267 | 298 | |
| 268 | 299 | public function convertDM($coord,$latlong) { |
| 269 | 300 | if ($latlong == 'latitude') { |
| 270 | - if ($coord < 0) $NSEW = 'S'; |
|
| 271 | - else $NSEW = 'N'; |
|
| 301 | + if ($coord < 0) { |
|
| 302 | + $NSEW = 'S'; |
|
| 303 | + } else { |
|
| 304 | + $NSEW = 'N'; |
|
| 305 | + } |
|
| 272 | 306 | } else { |
| 273 | - if ($coord < 0) $NSEW = 'W'; |
|
| 274 | - else $NSEW = 'E'; |
|
| 307 | + if ($coord < 0) { |
|
| 308 | + $NSEW = 'W'; |
|
| 309 | + } else { |
|
| 310 | + $NSEW = 'E'; |
|
| 311 | + } |
|
| 275 | 312 | } |
| 276 | 313 | $coord = abs($coord); |
| 277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
| 314 | 351 | public function hex2str($hex) { |
| 315 | 352 | $str = ''; |
| 316 | 353 | $hexln = strlen($hex); |
| 317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 354 | + for($i=0;$i<$hexln;$i+=2) { |
|
| 355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 356 | + } |
|
| 318 | 357 | return $str; |
| 319 | 358 | } |
| 320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
| 351 | 390 | $b = $lat2 - $lat1; |
| 352 | 391 | $c = -($a*$lat1+$b*$lon1); |
| 353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
| 354 | - if ($d > -$approx && $d < $approx) return true; |
|
| 355 | - else return false; |
|
| 393 | + if ($d > -$approx && $d < $approx) { |
|
| 394 | + return true; |
|
| 395 | + } else { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 356 | 398 | } |
| 357 | 399 | |
| 358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
| 411 | 453 | return $result; |
| 412 | 454 | } |
| 413 | 455 | $handle = @opendir('./locale'); |
| 414 | - if ($handle === false) return $result; |
|
| 456 | + if ($handle === false) { |
|
| 457 | + return $result; |
|
| 458 | + } |
|
| 415 | 459 | while (false !== ($file = readdir($handle))) { |
| 416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
| 417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
| 478 | 522 | $error = false; |
| 479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
| 480 | 524 | if ($fp_in = fopen($source,'rb')) { |
| 481 | - while (!feof($fp_in)) |
|
| 482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 525 | + while (!feof($fp_in)) { |
|
| 526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 527 | + } |
|
| 483 | 528 | fclose($fp_in); |
| 484 | 529 | } else { |
| 485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
| 488 | 533 | } else { |
| 489 | 534 | $error = true; |
| 490 | 535 | } |
| 491 | - if ($error) |
|
| 492 | - return false; |
|
| 493 | - else |
|
| 494 | - return $dest; |
|
| 536 | + if ($error) { |
|
| 537 | + return false; |
|
| 538 | + } else { |
|
| 539 | + return $dest; |
|
| 540 | + } |
|
| 495 | 541 | } |
| 496 | 542 | |
| 497 | 543 | public function remove_accents($string) { |
| 498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
| 545 | + return $string; |
|
| 546 | + } |
|
| 499 | 547 | $chars = array( |
| 500 | 548 | // Decompositions for Latin-1 Supplement |
| 501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
| 619 | 667 | $ip = gethostbyname($host); |
| 620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 621 | 669 | $r = @socket_connect($s, $ip, $port); |
| 622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 670 | + if (!socket_set_nonblock($s)) { |
|
| 671 | + echo "Unable to set nonblock on socket\n"; |
|
| 672 | + } |
|
| 623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 624 | 674 | return $s; |
| 625 | 675 | } |
@@ -664,18 +714,22 @@ discard block |
||
| 664 | 714 | //NOTE: use a trailing slash for folders!!! |
| 665 | 715 | //see http://bugs.php.net/bug.php?id=27609 |
| 666 | 716 | //see http://bugs.php.net/bug.php?id=30931 |
| 667 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
| 717 | + if ($path{strlen($path)-1}=='/') { |
|
| 718 | + // recursively return a temporary file path |
|
| 668 | 719 | return is__writable($path.uniqid(mt_rand()).'.tmp'); |
| 669 | - else if (is_dir($path)) |
|
| 670 | - return is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
| 720 | + } else if (is_dir($path)) { |
|
| 721 | + return is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
| 722 | + } |
|
| 671 | 723 | // check tmp file for read/write capabilities |
| 672 | 724 | $rm = file_exists($path); |
| 673 | 725 | $f = @fopen($path, 'a'); |
| 674 | - if ($f===false) |
|
| 675 | - return false; |
|
| 726 | + if ($f===false) { |
|
| 727 | + return false; |
|
| 728 | + } |
|
| 676 | 729 | fclose($f); |
| 677 | - if (!$rm) |
|
| 678 | - unlink($path); |
|
| 730 | + if (!$rm) { |
|
| 731 | + unlink($path); |
|
| 732 | + } |
|
| 679 | 733 | return true; |
| 680 | 734 | } |
| 681 | 735 | } |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | public function __construct($dbc = null) { |
| 13 | 13 | $Connection = new Connection($dbc); |
| 14 | 14 | $this->db = $Connection->db(); |
| 15 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 15 | + if ($this->db === null) { |
|
| 16 | + die('Error: No DB connection.'); |
|
| 17 | + } |
|
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | /** |
@@ -124,7 +126,9 @@ discard block |
||
| 124 | 126 | $sth->closeCursor(); |
| 125 | 127 | if (count($row) > 0) { |
| 126 | 128 | return $row; |
| 127 | - } else return array(); |
|
| 129 | + } else { |
|
| 130 | + return array(); |
|
| 131 | + } |
|
| 128 | 132 | } |
| 129 | 133 | |
| 130 | 134 | public function checkSchedule($ident) { |
@@ -160,7 +164,9 @@ discard block |
||
| 160 | 164 | $Common = new Common(); |
| 161 | 165 | $check_date = new Datetime($date); |
| 162 | 166 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 167 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 168 | + return array(); |
|
| 169 | + } |
|
| 164 | 170 | $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'); |
| 165 | 171 | $json = $Common->getData($url); |
| 166 | 172 | |
@@ -187,7 +193,9 @@ discard block |
||
| 187 | 193 | */ |
| 188 | 194 | |
| 189 | 195 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 190 | - } else return array(); |
|
| 196 | + } else { |
|
| 197 | + return array(); |
|
| 198 | + } |
|
| 191 | 199 | } |
| 192 | 200 | |
| 193 | 201 | /** |
@@ -202,7 +210,9 @@ discard block |
||
| 202 | 210 | date_default_timezone_set($globalTimezone); |
| 203 | 211 | $check_date = new Datetime($date); |
| 204 | 212 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 213 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 214 | + return array(); |
|
| 215 | + } |
|
| 206 | 216 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 207 | 217 | $json = $Common->getData($url); |
| 208 | 218 | $parsed_json = json_decode($json); |
@@ -215,7 +225,9 @@ discard block |
||
| 215 | 225 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 216 | 226 | |
| 217 | 227 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 218 | - } else return array(); |
|
| 228 | + } else { |
|
| 229 | + return array(); |
|
| 230 | + } |
|
| 219 | 231 | } |
| 220 | 232 | |
| 221 | 233 | /** |
@@ -226,7 +238,9 @@ discard block |
||
| 226 | 238 | private function getRyanair($callsign) { |
| 227 | 239 | $Common = new Common(); |
| 228 | 240 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 241 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 242 | + return array(); |
|
| 243 | + } |
|
| 230 | 244 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 231 | 245 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 232 | 246 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -240,8 +254,12 @@ discard block |
||
| 240 | 254 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 241 | 255 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 242 | 256 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 243 | - } else return array(); |
|
| 244 | - } else return array(); |
|
| 257 | + } else { |
|
| 258 | + return array(); |
|
| 259 | + } |
|
| 260 | + } else { |
|
| 261 | + return array(); |
|
| 262 | + } |
|
| 245 | 263 | } |
| 246 | 264 | |
| 247 | 265 | /** |
@@ -252,7 +270,9 @@ discard block |
||
| 252 | 270 | private function getSwiss($callsign) { |
| 253 | 271 | $Common = new Common(); |
| 254 | 272 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 273 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 274 | + return array(); |
|
| 275 | + } |
|
| 256 | 276 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 257 | 277 | $json = $Common->getData($url); |
| 258 | 278 | $parsed_json = json_decode($json); |
@@ -272,8 +292,12 @@ discard block |
||
| 272 | 292 | } |
| 273 | 293 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 274 | 294 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 275 | - } else return array(); |
|
| 276 | - } else return array(); |
|
| 295 | + } else { |
|
| 296 | + return array(); |
|
| 297 | + } |
|
| 298 | + } else { |
|
| 299 | + return array(); |
|
| 300 | + } |
|
| 277 | 301 | } |
| 278 | 302 | |
| 279 | 303 | /** |
@@ -287,12 +311,18 @@ discard block |
||
| 287 | 311 | $Common = new Common(); |
| 288 | 312 | $check_date = new Datetime($date); |
| 289 | 313 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 291 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 314 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 315 | + return array(); |
|
| 316 | + } |
|
| 317 | + if ($globalBritishAirwaysKey == '') { |
|
| 318 | + return array(); |
|
| 319 | + } |
|
| 292 | 320 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 293 | 321 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 294 | 322 | $json = $Common->getData($url,'get','',$headers); |
| 295 | - if ($json == '') return array(); |
|
| 323 | + if ($json == '') { |
|
| 324 | + return array(); |
|
| 325 | + } |
|
| 296 | 326 | $parsed_json = json_decode($json); |
| 297 | 327 | $flights = $parsed_json->{'FlightsResponse'}; |
| 298 | 328 | if (count($flights) > 0) { |
@@ -301,7 +331,9 @@ discard block |
||
| 301 | 331 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 302 | 332 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 303 | 333 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 304 | - } else return array(); |
|
| 334 | + } else { |
|
| 335 | + return array(); |
|
| 336 | + } |
|
| 305 | 337 | } |
| 306 | 338 | |
| 307 | 339 | /** |
@@ -315,19 +347,27 @@ discard block |
||
| 315 | 347 | $Common = new Common(); |
| 316 | 348 | $check_date = new Datetime($date); |
| 317 | 349 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 319 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 350 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 351 | + return array(); |
|
| 352 | + } |
|
| 353 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 354 | + return array(); |
|
| 355 | + } |
|
| 320 | 356 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 321 | 357 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 322 | 358 | $data = $Common->getData($url,'post',$post); |
| 323 | 359 | $parsed_data = json_decode($data); |
| 324 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 360 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 361 | + return array(); |
|
| 362 | + } |
|
| 325 | 363 | $token = $parsed_data->{'access_token'}; |
| 326 | 364 | |
| 327 | 365 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 328 | 366 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 329 | 367 | $json = $Common->getData($url,'get','',$headers); |
| 330 | - if ($json == '') return array(); |
|
| 368 | + if ($json == '') { |
|
| 369 | + return array(); |
|
| 370 | + } |
|
| 331 | 371 | $parsed_json = json_decode($json); |
| 332 | 372 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 333 | 373 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -335,7 +375,9 @@ discard block |
||
| 335 | 375 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 336 | 376 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 337 | 377 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 338 | - } else return array(); |
|
| 378 | + } else { |
|
| 379 | + return array(); |
|
| 380 | + } |
|
| 339 | 381 | } |
| 340 | 382 | |
| 341 | 383 | /** |
@@ -349,14 +391,20 @@ discard block |
||
| 349 | 391 | $Common = new Common(); |
| 350 | 392 | $check_date = new Datetime($date); |
| 351 | 393 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 353 | - if ($globalTransaviaKey == '') return array(); |
|
| 394 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 395 | + return array(); |
|
| 396 | + } |
|
| 397 | + if ($globalTransaviaKey == '') { |
|
| 398 | + return array(); |
|
| 399 | + } |
|
| 354 | 400 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 355 | 401 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 356 | 402 | $headers = array('apikey: '.$globalTransaviaKey); |
| 357 | 403 | $json = $Common->getData($url,'get','',$headers); |
| 358 | 404 | //echo 'result : '.$json; |
| 359 | - if ($json == '') return array(); |
|
| 405 | + if ($json == '') { |
|
| 406 | + return array(); |
|
| 407 | + } |
|
| 360 | 408 | $parsed_json = json_decode($json); |
| 361 | 409 | |
| 362 | 410 | if (isset($parsed_json->{'data'}[0])) { |
@@ -365,7 +413,9 @@ discard block |
||
| 365 | 413 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 366 | 414 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 367 | 415 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 368 | - } else return array(); |
|
| 416 | + } else { |
|
| 417 | + return array(); |
|
| 418 | + } |
|
| 369 | 419 | } |
| 370 | 420 | |
| 371 | 421 | /** |
@@ -376,7 +426,9 @@ discard block |
||
| 376 | 426 | public function getTunisair($callsign) { |
| 377 | 427 | $Common = new Common(); |
| 378 | 428 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 429 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 430 | + return array(); |
|
| 431 | + } |
|
| 380 | 432 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 381 | 433 | $data = $Common->getData($url); |
| 382 | 434 | $table = $Common->table2array($data); |
@@ -397,7 +449,9 @@ discard block |
||
| 397 | 449 | $Common = new Common(); |
| 398 | 450 | $check_date = new Datetime($date); |
| 399 | 451 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 452 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 453 | + return array(); |
|
| 454 | + } |
|
| 401 | 455 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 402 | 456 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 403 | 457 | $data = $Common->getData($url); |
@@ -407,8 +461,11 @@ discard block |
||
| 407 | 461 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 408 | 462 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 409 | 463 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 411 | - else return array(); |
|
| 464 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 465 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 466 | + } else { |
|
| 467 | + return array(); |
|
| 468 | + } |
|
| 412 | 469 | } |
| 413 | 470 | return array(); |
| 414 | 471 | } |
@@ -423,7 +480,9 @@ discard block |
||
| 423 | 480 | $Common = new Common(); |
| 424 | 481 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 425 | 482 | $check_date = new Datetime($date); |
| 426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 483 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 484 | + return array(); |
|
| 485 | + } |
|
| 427 | 486 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 428 | 487 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 429 | 488 | $data = $Common->getData($url,'post',$post); |
@@ -440,7 +499,9 @@ discard block |
||
| 440 | 499 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 441 | 500 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 442 | 501 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 502 | + } else { |
|
| 503 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 504 | + } |
|
| 444 | 505 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 445 | 506 | } |
| 446 | 507 | } |
@@ -458,7 +519,9 @@ discard block |
||
| 458 | 519 | $Common = new Common(); |
| 459 | 520 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 460 | 521 | $check_date = new Datetime($date); |
| 461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 522 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 523 | + return array(); |
|
| 524 | + } |
|
| 462 | 525 | $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'); |
| 463 | 526 | $data = $Common->getData($url); |
| 464 | 527 | if ($data != '') { |
@@ -474,7 +537,9 @@ discard block |
||
| 474 | 537 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 475 | 538 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 476 | 539 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 477 | - } else return array(); |
|
| 540 | + } else { |
|
| 541 | + return array(); |
|
| 542 | + } |
|
| 478 | 543 | } |
| 479 | 544 | |
| 480 | 545 | |
@@ -494,7 +559,9 @@ discard block |
||
| 494 | 559 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 495 | 560 | $check_date = new Datetime($date); |
| 496 | 561 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 562 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 563 | + return array(); |
|
| 564 | + } |
|
| 498 | 565 | $data = $Common->getData($url); |
| 499 | 566 | if ($data != '') { |
| 500 | 567 | $table = $Common->text2array($data); |
@@ -518,7 +585,9 @@ discard block |
||
| 518 | 585 | $check_date = new Datetime($date); |
| 519 | 586 | $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"; |
| 520 | 587 | //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"; |
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 588 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 589 | + return array(); |
|
| 590 | + } |
|
| 522 | 591 | $data = $Common->getData($url); |
| 523 | 592 | if ($data != '') { |
| 524 | 593 | //echo $data; |
@@ -608,7 +677,9 @@ discard block |
||
| 608 | 677 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 609 | 678 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 610 | 679 | //$check_date = new Datetime($date); |
| 611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 680 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 681 | + return array(); |
|
| 682 | + } |
|
| 612 | 683 | $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'); |
| 613 | 684 | $data = $Common->getData($url,'post',$post); |
| 614 | 685 | if ($data != '') { |
@@ -640,11 +711,15 @@ discard block |
||
| 640 | 711 | $airline_icao = substr($callsign, 0, 3); |
| 641 | 712 | } |
| 642 | 713 | } |
| 643 | - if ($airline_icao == '') return array(); |
|
| 714 | + if ($airline_icao == '') { |
|
| 715 | + return array(); |
|
| 716 | + } |
|
| 644 | 717 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 645 | 718 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 646 | 719 | //$check_date = new Datetime($date); |
| 647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 720 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 721 | + return array(); |
|
| 722 | + } |
|
| 648 | 723 | $data = $Common->getData($url); |
| 649 | 724 | if ($data != '') { |
| 650 | 725 | $table = $Common->table2array($data); |
@@ -687,7 +762,9 @@ discard block |
||
| 687 | 762 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 688 | 763 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
| 689 | 764 | //$check_date = new Datetime($date); |
| 690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 765 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 766 | + return array(); |
|
| 767 | + } |
|
| 691 | 768 | $data = $Common->getData($url); |
| 692 | 769 | if ($data != '') { |
| 693 | 770 | $table = $Common->table2array($data); |
@@ -736,16 +813,22 @@ discard block |
||
| 736 | 813 | */ |
| 737 | 814 | private function getAirCanada($callsign,$date = 'NOW') { |
| 738 | 815 | $Common = new Common(); |
| 739 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
| 816 | + if (class_exists("DomDocument") === FALSE) { |
|
| 817 | + return array(); |
|
| 818 | + } |
|
| 740 | 819 | date_default_timezone_set('UTC'); |
| 741 | 820 | $check_date = new Datetime($date); |
| 742 | 821 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 743 | 822 | $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"; |
| 744 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 823 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 824 | + return array(); |
|
| 825 | + } |
|
| 745 | 826 | $data = $Common->getData($url); |
| 746 | 827 | $dom = new DomDocument(); |
| 747 | 828 | $dom->loadXML($data); |
| 748 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 829 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 830 | + return array(); |
|
| 831 | + } |
|
| 749 | 832 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 750 | 833 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 751 | 834 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -754,7 +837,9 @@ discard block |
||
| 754 | 837 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 755 | 838 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 756 | 839 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 757 | - } else return array(); |
|
| 840 | + } else { |
|
| 841 | + return array(); |
|
| 842 | + } |
|
| 758 | 843 | } |
| 759 | 844 | |
| 760 | 845 | /** |
@@ -768,7 +853,9 @@ discard block |
||
| 768 | 853 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 769 | 854 | $check_date = new Datetime($date); |
| 770 | 855 | $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."&"; |
| 771 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 856 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 857 | + return array(); |
|
| 858 | + } |
|
| 772 | 859 | $data = $Common->getData($url); |
| 773 | 860 | if ($data != '') { |
| 774 | 861 | $table = $Common->table2array($data); |
@@ -797,7 +884,9 @@ discard block |
||
| 797 | 884 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 798 | 885 | $check_date = new Datetime($date); |
| 799 | 886 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 800 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 887 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 888 | + return array(); |
|
| 889 | + } |
|
| 801 | 890 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 802 | 891 | $data = $Common->getData($url,'post',$post); |
| 803 | 892 | //echo $data; |
@@ -807,11 +896,19 @@ discard block |
||
| 807 | 896 | if ($data != '') { |
| 808 | 897 | $table = $Common->table2array($data); |
| 809 | 898 | $flight = $table; |
| 810 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 811 | - else $departureTime = ''; |
|
| 812 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 813 | - else $departureAirport = ''; |
|
| 814 | - } else return array(); |
|
| 899 | + if (isset($flight[5][4])) { |
|
| 900 | + $departureTime = $flight[5][4]; |
|
| 901 | + } else { |
|
| 902 | + $departureTime = ''; |
|
| 903 | + } |
|
| 904 | + if (isset($flight[5][2])) { |
|
| 905 | + $departureAirport = $flight[5][2]; |
|
| 906 | + } else { |
|
| 907 | + $departureAirport = ''; |
|
| 908 | + } |
|
| 909 | + } else { |
|
| 910 | + return array(); |
|
| 911 | + } |
|
| 815 | 912 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 816 | 913 | $data = $Common->getData($url,'post',$post); |
| 817 | 914 | if ($data != '') { |
@@ -824,10 +921,14 @@ discard block |
||
| 824 | 921 | $arrivalTime = ''; |
| 825 | 922 | $arrivalAirport = ''; |
| 826 | 923 | } |
| 827 | - } else return array(); |
|
| 924 | + } else { |
|
| 925 | + return array(); |
|
| 926 | + } |
|
| 828 | 927 | $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'; |
| 829 | 928 | $json = $Common->getData($url); |
| 830 | - if ($json == '') return array(); |
|
| 929 | + if ($json == '') { |
|
| 930 | + return array(); |
|
| 931 | + } |
|
| 831 | 932 | $parsed_json = json_decode($json); |
| 832 | 933 | $airports = $parsed_json->{'suggestList'}; |
| 833 | 934 | if (count($airports) > 0) { |
@@ -842,7 +943,9 @@ discard block |
||
| 842 | 943 | } |
| 843 | 944 | if (isset($DepartureAirportIata)) { |
| 844 | 945 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 845 | - } else return array(); |
|
| 946 | + } else { |
|
| 947 | + return array(); |
|
| 948 | + } |
|
| 846 | 949 | } |
| 847 | 950 | |
| 848 | 951 | |
@@ -850,7 +953,9 @@ discard block |
||
| 850 | 953 | public function fetchSchedule($ident,$date = 'NOW') { |
| 851 | 954 | global $globalSchedulesSources, $globalSchedulesFetch; |
| 852 | 955 | //$Common = new Common(); |
| 853 | - if (!$globalSchedulesFetch) return array(); |
|
| 956 | + if (!$globalSchedulesFetch) { |
|
| 957 | + return array(); |
|
| 958 | + } |
|
| 854 | 959 | $airline_icao = ''; |
| 855 | 960 | if (!is_numeric(substr($ident, 0, 3))) |
| 856 | 961 | { |
@@ -1078,14 +1183,21 @@ discard block |
||
| 1078 | 1183 | default: |
| 1079 | 1184 | // Randomly use a generic function to get hours |
| 1080 | 1185 | if (strlen($airline_icao) == 2) { |
| 1081 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1186 | + if (!isset($globalSchedulesSources)) { |
|
| 1187 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
| 1188 | + } |
|
| 1082 | 1189 | if (count($globalSchedulesSources) > 0) { |
| 1083 | 1190 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1084 | 1191 | $source = $globalSchedulesSources[$rand]; |
| 1085 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1086 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1192 | + if ($source == 'flightmapper') { |
|
| 1193 | + return $this->getFlightMapper($ident); |
|
| 1194 | + } elseif ($source == 'costtotravel') { |
|
| 1195 | + return $this->getCostToTravel($ident); |
|
| 1196 | + } |
|
| 1087 | 1197 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1088 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
| 1198 | + elseif ($source == 'flightaware') { |
|
| 1199 | + return $this->getFlightAware($ident); |
|
| 1200 | + } |
|
| 1089 | 1201 | } |
| 1090 | 1202 | } |
| 1091 | 1203 | } |