@@ -5,8 +5,11 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
7 | 7 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
8 | -if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
9 | -else $spotter_array = array(); |
|
8 | +if (isset($_GET['date'])) { |
|
9 | + $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
10 | +} else { |
|
11 | + $spotter_array = array(); |
|
12 | +} |
|
10 | 13 | |
11 | 14 | if (!empty($spotter_array)) |
12 | 15 | { |
@@ -15,8 +15,12 @@ discard block |
||
15 | 15 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
16 | 16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
17 | 17 | $sql_date = $end_date; |
18 | - } else $sql_date = ''; |
|
19 | -} else $sql_date = ''; |
|
18 | + } else { |
|
19 | + $sql_date = ''; |
|
20 | + } |
|
21 | + } else { |
|
22 | + $sql_date = ''; |
|
23 | +} |
|
20 | 24 | |
21 | 25 | if (isset($_GET['highest_altitude'])) { |
22 | 26 | //for altitude manipulation |
@@ -30,8 +34,12 @@ discard block |
||
30 | 34 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
31 | 35 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
32 | 36 | $sql_altitude = $start_altitude; |
33 | - } else $sql_altitude = ''; |
|
34 | -} else $sql_altitude = ''; |
|
37 | + } else { |
|
38 | + $sql_altitude = ''; |
|
39 | + } |
|
40 | + } else { |
|
41 | + $sql_altitude = ''; |
|
42 | +} |
|
35 | 43 | |
36 | 44 | //calculuation for the pagination |
37 | 45 | if(!isset($_GET['limit'])) |
@@ -49,7 +57,7 @@ discard block |
||
49 | 57 | $limit_end = $_GET['number_results']; |
50 | 58 | $absolute_difference = $_GET['number_results']; |
51 | 59 | } |
52 | -} else { |
|
60 | +} else { |
|
53 | 61 | $limit_explode = explode(",", $_GET['limit']); |
54 | 62 | $limit_start = $limit_explode[0]; |
55 | 63 | $limit_end = $limit_explode[1]; |
@@ -67,8 +75,11 @@ discard block |
||
67 | 75 | |
68 | 76 | header('Content-Type: application/json'); |
69 | 77 | |
70 | -if (isset($_GET['sort'])) $sort = $_GET['sort']; |
|
71 | -else $sort = ''; |
|
78 | +if (isset($_GET['sort'])) { |
|
79 | + $sort = $_GET['sort']; |
|
80 | +} else { |
|
81 | + $sort = ''; |
|
82 | +} |
|
72 | 83 | $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
73 | 84 | $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
74 | 85 | $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |
@@ -58,8 +58,12 @@ |
||
58 | 58 | if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) { |
59 | 59 | include('table-output.php'); |
60 | 60 | print '<div class="pagination">'; |
61 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
62 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
61 | + if ($limit_previous_1 >= 0) { |
|
62 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
63 | + } |
|
64 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
65 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
66 | + } |
|
63 | 67 | print '</div>'; |
64 | 68 | } |
65 | 69 | print '</div>'; |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<option></option>'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $aircraft_types = $Stats->getAllAircraftTypes(); |
25 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
25 | + if (empty($aircraft_types)) { |
|
26 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
27 | + } |
|
26 | 28 | foreach($aircraft_types as $aircraft_type) |
27 | 29 | { |
28 | 30 | if($aircraft_type == $aircrafttype['aircraft_icao']) |
@@ -8,8 +8,11 @@ |
||
8 | 8 | } |
9 | 9 | header('Content-Type: text/javascript'); |
10 | 10 | $timearray = array(); |
11 | -if (isset($_GET['now'])) $begin = time(); |
|
12 | -else $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
11 | +if (isset($_GET['now'])) { |
|
12 | + $begin = time(); |
|
13 | +} else { |
|
14 | + $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
15 | +} |
|
13 | 16 | for ($i =0; $i <= 288; $i++) { |
14 | 17 | $timearray[] = ($begin + $i*300)*1000; |
15 | 18 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | $METAR = new METAR(); |
47 | 47 | $metar_info = $METAR->getMETAR($airport_icao); |
48 | 48 | //print_r($metar_info); |
49 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
49 | + if (isset($metar_info[0]['metar'])) { |
|
50 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
51 | + } |
|
50 | 52 | //print_r($metar_parse); |
51 | 53 | } |
52 | 54 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | print '<option></option>'; |
61 | 63 | $Stats = new Stats(); |
62 | 64 | $airport_names = $Stats->getAllAirportNames(); |
63 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
65 | + if (empty($airport_names)) { |
|
66 | + $airport_names = $Spotter->getAllAirportNames(); |
|
67 | + } |
|
64 | 68 | ksort($airport_names); |
65 | 69 | foreach($airport_names as $airport_name) |
66 | 70 | { |
@@ -102,7 +106,9 @@ discard block |
||
102 | 106 | // Use spotter also |
103 | 107 | if (isset($globalTimezone)) { |
104 | 108 | date_default_timezone_set($globalTimezone); |
105 | - } else date_default_timezone_set('UTC'); |
|
109 | + } else { |
|
110 | + date_default_timezone_set('UTC'); |
|
111 | + } |
|
106 | 112 | if (count($all_data) > 0) { |
107 | 113 | print '<div id="chart6" class="chart" width="100%"></div> |
108 | 114 | <script> |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | $sth->closeCursor(); |
124 | 124 | if (count($row) > 0) { |
125 | 125 | return $row; |
126 | - } else return array(); |
|
126 | + } else { |
|
127 | + return array(); |
|
128 | + } |
|
127 | 129 | } |
128 | 130 | |
129 | 131 | public function checkSchedule($ident) { |
@@ -159,7 +161,9 @@ discard block |
||
159 | 161 | $Common = new Common(); |
160 | 162 | $check_date = new Datetime($date); |
161 | 163 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
162 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
164 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
165 | + return array(); |
|
166 | + } |
|
163 | 167 | $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'); |
164 | 168 | $json = $Common->getData($url); |
165 | 169 | |
@@ -186,7 +190,9 @@ discard block |
||
186 | 190 | */ |
187 | 191 | |
188 | 192 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
189 | - } else return array(); |
|
193 | + } else { |
|
194 | + return array(); |
|
195 | + } |
|
190 | 196 | } |
191 | 197 | |
192 | 198 | /** |
@@ -201,7 +207,9 @@ discard block |
||
201 | 207 | date_default_timezone_set($globalTimezone); |
202 | 208 | $check_date = new Datetime($date); |
203 | 209 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
204 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
210 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
211 | + return array(); |
|
212 | + } |
|
205 | 213 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
206 | 214 | $json = $Common->getData($url); |
207 | 215 | $parsed_json = json_decode($json); |
@@ -214,7 +222,9 @@ discard block |
||
214 | 222 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
215 | 223 | |
216 | 224 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
217 | - } else return array(); |
|
225 | + } else { |
|
226 | + return array(); |
|
227 | + } |
|
218 | 228 | } |
219 | 229 | |
220 | 230 | /** |
@@ -225,7 +235,9 @@ discard block |
||
225 | 235 | private function getRyanair($callsign) { |
226 | 236 | $Common = new Common(); |
227 | 237 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
228 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
238 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
239 | + return array(); |
|
240 | + } |
|
229 | 241 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
230 | 242 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
231 | 243 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -239,8 +251,12 @@ discard block |
||
239 | 251 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
240 | 252 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
241 | 253 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
242 | - } else return array(); |
|
243 | - } else return array(); |
|
254 | + } else { |
|
255 | + return array(); |
|
256 | + } |
|
257 | + } else { |
|
258 | + return array(); |
|
259 | + } |
|
244 | 260 | } |
245 | 261 | |
246 | 262 | /** |
@@ -251,7 +267,9 @@ discard block |
||
251 | 267 | private function getSwiss($callsign) { |
252 | 268 | $Common = new Common(); |
253 | 269 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
254 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
270 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
271 | + return array(); |
|
272 | + } |
|
255 | 273 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
256 | 274 | $json = $Common->getData($url); |
257 | 275 | $parsed_json = json_decode($json); |
@@ -271,8 +289,12 @@ discard block |
||
271 | 289 | } |
272 | 290 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
273 | 291 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
274 | - } else return array(); |
|
275 | - } else return array(); |
|
292 | + } else { |
|
293 | + return array(); |
|
294 | + } |
|
295 | + } else { |
|
296 | + return array(); |
|
297 | + } |
|
276 | 298 | } |
277 | 299 | |
278 | 300 | /** |
@@ -286,12 +308,18 @@ discard block |
||
286 | 308 | $Common = new Common(); |
287 | 309 | $check_date = new Datetime($date); |
288 | 310 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
289 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
290 | - if ($globalBritishAirwaysKey == '') return array(); |
|
311 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
312 | + return array(); |
|
313 | + } |
|
314 | + if ($globalBritishAirwaysKey == '') { |
|
315 | + return array(); |
|
316 | + } |
|
291 | 317 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
292 | 318 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
293 | 319 | $json = $Common->getData($url,'get','',$headers); |
294 | - if ($json == '') return array(); |
|
320 | + if ($json == '') { |
|
321 | + return array(); |
|
322 | + } |
|
295 | 323 | $parsed_json = json_decode($json); |
296 | 324 | $flights = $parsed_json->{'FlightsResponse'}; |
297 | 325 | if (count($flights) > 0) { |
@@ -300,7 +328,9 @@ discard block |
||
300 | 328 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
301 | 329 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
302 | 330 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
303 | - } else return array(); |
|
331 | + } else { |
|
332 | + return array(); |
|
333 | + } |
|
304 | 334 | } |
305 | 335 | |
306 | 336 | /** |
@@ -314,19 +344,27 @@ discard block |
||
314 | 344 | $Common = new Common(); |
315 | 345 | $check_date = new Datetime($date); |
316 | 346 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
317 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
318 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
347 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
348 | + return array(); |
|
349 | + } |
|
350 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
351 | + return array(); |
|
352 | + } |
|
319 | 353 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
320 | 354 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
321 | 355 | $data = $Common->getData($url,'post',$post); |
322 | 356 | $parsed_data = json_decode($data); |
323 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
357 | + if (!isset($parsed_data->{'access_token'})) { |
|
358 | + return array(); |
|
359 | + } |
|
324 | 360 | $token = $parsed_data->{'access_token'}; |
325 | 361 | |
326 | 362 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
327 | 363 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
328 | 364 | $json = $Common->getData($url,'get','',$headers); |
329 | - if ($json == '') return array(); |
|
365 | + if ($json == '') { |
|
366 | + return array(); |
|
367 | + } |
|
330 | 368 | $parsed_json = json_decode($json); |
331 | 369 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
332 | 370 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -334,7 +372,9 @@ discard block |
||
334 | 372 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
335 | 373 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
336 | 374 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
337 | - } else return array(); |
|
375 | + } else { |
|
376 | + return array(); |
|
377 | + } |
|
338 | 378 | } |
339 | 379 | |
340 | 380 | /** |
@@ -348,14 +388,20 @@ discard block |
||
348 | 388 | $Common = new Common(); |
349 | 389 | $check_date = new Datetime($date); |
350 | 390 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
351 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
352 | - if ($globalTransaviaKey == '') return array(); |
|
391 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
392 | + return array(); |
|
393 | + } |
|
394 | + if ($globalTransaviaKey == '') { |
|
395 | + return array(); |
|
396 | + } |
|
353 | 397 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
354 | 398 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
355 | 399 | $headers = array('apikey: '.$globalTransaviaKey); |
356 | 400 | $json = $Common->getData($url,'get','',$headers); |
357 | 401 | //echo 'result : '.$json; |
358 | - if ($json == '') return array(); |
|
402 | + if ($json == '') { |
|
403 | + return array(); |
|
404 | + } |
|
359 | 405 | $parsed_json = json_decode($json); |
360 | 406 | |
361 | 407 | if (isset($parsed_json->{'data'}[0])) { |
@@ -364,7 +410,9 @@ discard block |
||
364 | 410 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
365 | 411 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
366 | 412 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
367 | - } else return array(); |
|
413 | + } else { |
|
414 | + return array(); |
|
415 | + } |
|
368 | 416 | } |
369 | 417 | |
370 | 418 | /** |
@@ -375,7 +423,9 @@ discard block |
||
375 | 423 | public function getTunisair($callsign) { |
376 | 424 | $Common = new Common(); |
377 | 425 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
378 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
426 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
427 | + return array(); |
|
428 | + } |
|
379 | 429 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
380 | 430 | $data = $Common->getData($url); |
381 | 431 | $table = $Common->table2array($data); |
@@ -396,7 +446,9 @@ discard block |
||
396 | 446 | $Common = new Common(); |
397 | 447 | $check_date = new Datetime($date); |
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 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
401 | 453 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
402 | 454 | $data = $Common->getData($url); |
@@ -406,8 +458,11 @@ discard block |
||
406 | 458 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
407 | 459 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
408 | 460 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
409 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
410 | - else return array(); |
|
461 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
462 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
463 | + } else { |
|
464 | + return array(); |
|
465 | + } |
|
411 | 466 | } |
412 | 467 | return array(); |
413 | 468 | } |
@@ -422,7 +477,9 @@ discard block |
||
422 | 477 | $Common = new Common(); |
423 | 478 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
424 | 479 | $check_date = new Datetime($date); |
425 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
480 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
481 | + return array(); |
|
482 | + } |
|
426 | 483 | $url = "https://www.iberia.com/web/flightDetail.do"; |
427 | 484 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
428 | 485 | $data = $Common->getData($url,'post',$post); |
@@ -439,7 +496,9 @@ discard block |
||
439 | 496 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
440 | 497 | if ($arrivalTime == 'Hora estimada de llegada') { |
441 | 498 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
442 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
499 | + } else { |
|
500 | + $arrivalTime = substr($arrivalTime,0,5); |
|
501 | + } |
|
443 | 502 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
444 | 503 | } |
445 | 504 | } |
@@ -457,7 +516,9 @@ discard block |
||
457 | 516 | $Common = new Common(); |
458 | 517 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
459 | 518 | $check_date = new Datetime($date); |
460 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
519 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
520 | + return array(); |
|
521 | + } |
|
461 | 522 | $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'); |
462 | 523 | $data = $Common->getData($url); |
463 | 524 | if ($data != '') { |
@@ -473,7 +534,9 @@ discard block |
||
473 | 534 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
474 | 535 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
475 | 536 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
476 | - } else return array(); |
|
537 | + } else { |
|
538 | + return array(); |
|
539 | + } |
|
477 | 540 | } |
478 | 541 | |
479 | 542 | |
@@ -493,7 +556,9 @@ discard block |
||
493 | 556 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
494 | 557 | $check_date = new Datetime($date); |
495 | 558 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
496 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
559 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
560 | + return array(); |
|
561 | + } |
|
497 | 562 | $data = $Common->getData($url); |
498 | 563 | if ($data != '') { |
499 | 564 | $table = $Common->text2array($data); |
@@ -517,7 +582,9 @@ discard block |
||
517 | 582 | $check_date = new Datetime($date); |
518 | 583 | $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"; |
519 | 584 | //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"; |
520 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
585 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
586 | + return array(); |
|
587 | + } |
|
521 | 588 | $data = $Common->getData($url); |
522 | 589 | if ($data != '') { |
523 | 590 | //echo $data; |
@@ -607,7 +674,9 @@ discard block |
||
607 | 674 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
608 | 675 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
609 | 676 | //$check_date = new Datetime($date); |
610 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
677 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
678 | + return array(); |
|
679 | + } |
|
611 | 680 | $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'); |
612 | 681 | $data = $Common->getData($url,'post',$post); |
613 | 682 | if ($data != '') { |
@@ -639,11 +708,15 @@ discard block |
||
639 | 708 | $airline_icao = substr($callsign, 0, 3); |
640 | 709 | } |
641 | 710 | } |
642 | - if ($airline_icao == '') return array(); |
|
711 | + if ($airline_icao == '') { |
|
712 | + return array(); |
|
713 | + } |
|
643 | 714 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
644 | 715 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
645 | 716 | //$check_date = new Datetime($date); |
646 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
717 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
718 | + return array(); |
|
719 | + } |
|
647 | 720 | $data = $Common->getData($url); |
648 | 721 | if ($data != '') { |
649 | 722 | $table = $Common->table2array($data); |
@@ -686,7 +759,9 @@ discard block |
||
686 | 759 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
687 | 760 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
688 | 761 | //$check_date = new Datetime($date); |
689 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
762 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
763 | + return array(); |
|
764 | + } |
|
690 | 765 | $data = $Common->getData($url); |
691 | 766 | if ($data != '') { |
692 | 767 | $table = $Common->table2array($data); |
@@ -739,11 +814,15 @@ discard block |
||
739 | 814 | $check_date = new Datetime($date); |
740 | 815 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
741 | 816 | $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"; |
742 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
817 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
818 | + return array(); |
|
819 | + } |
|
743 | 820 | $data = $Common->getData($url); |
744 | 821 | $dom = new DomDocument(); |
745 | 822 | $dom->loadXML($data); |
746 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
823 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
824 | + return array(); |
|
825 | + } |
|
747 | 826 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
748 | 827 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
749 | 828 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -752,7 +831,9 @@ discard block |
||
752 | 831 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
753 | 832 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
754 | 833 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
755 | - } else return array(); |
|
834 | + } else { |
|
835 | + return array(); |
|
836 | + } |
|
756 | 837 | } |
757 | 838 | |
758 | 839 | /** |
@@ -766,7 +847,9 @@ discard block |
||
766 | 847 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
767 | 848 | $check_date = new Datetime($date); |
768 | 849 | $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."&"; |
769 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
850 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
851 | + return array(); |
|
852 | + } |
|
770 | 853 | $data = $Common->getData($url); |
771 | 854 | if ($data != '') { |
772 | 855 | $table = $Common->table2array($data); |
@@ -795,7 +878,9 @@ discard block |
||
795 | 878 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
796 | 879 | $check_date = new Datetime($date); |
797 | 880 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
798 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
881 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
882 | + return array(); |
|
883 | + } |
|
799 | 884 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
800 | 885 | $data = $Common->getData($url,'post',$post); |
801 | 886 | //echo $data; |
@@ -805,11 +890,19 @@ discard block |
||
805 | 890 | if ($data != '') { |
806 | 891 | $table = $Common->table2array($data); |
807 | 892 | $flight = $table; |
808 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
809 | - else $departureTime = ''; |
|
810 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
811 | - else $departureAirport = ''; |
|
812 | - } else return array(); |
|
893 | + if (isset($flight[5][4])) { |
|
894 | + $departureTime = $flight[5][4]; |
|
895 | + } else { |
|
896 | + $departureTime = ''; |
|
897 | + } |
|
898 | + if (isset($flight[5][2])) { |
|
899 | + $departureAirport = $flight[5][2]; |
|
900 | + } else { |
|
901 | + $departureAirport = ''; |
|
902 | + } |
|
903 | + } else { |
|
904 | + return array(); |
|
905 | + } |
|
813 | 906 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
814 | 907 | $data = $Common->getData($url,'post',$post); |
815 | 908 | if ($data != '') { |
@@ -822,10 +915,14 @@ discard block |
||
822 | 915 | $arrivalTime = ''; |
823 | 916 | $arrivalAirport = ''; |
824 | 917 | } |
825 | - } else return array(); |
|
918 | + } else { |
|
919 | + return array(); |
|
920 | + } |
|
826 | 921 | $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'; |
827 | 922 | $json = $Common->getData($url); |
828 | - if ($json == '') return array(); |
|
923 | + if ($json == '') { |
|
924 | + return array(); |
|
925 | + } |
|
829 | 926 | $parsed_json = json_decode($json); |
830 | 927 | $airports = $parsed_json->{'suggestList'}; |
831 | 928 | if (count($airports) > 0) { |
@@ -840,7 +937,9 @@ discard block |
||
840 | 937 | } |
841 | 938 | if (isset($DepartureAirportIata)) { |
842 | 939 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
843 | - } else return array(); |
|
940 | + } else { |
|
941 | + return array(); |
|
942 | + } |
|
844 | 943 | } |
845 | 944 | |
846 | 945 | |
@@ -848,7 +947,9 @@ discard block |
||
848 | 947 | public function fetchSchedule($ident,$date = 'NOW') { |
849 | 948 | global $globalSchedulesSources, $globalSchedulesFetch; |
850 | 949 | //$Common = new Common(); |
851 | - if (!$globalSchedulesFetch) return array(); |
|
950 | + if (!$globalSchedulesFetch) { |
|
951 | + return array(); |
|
952 | + } |
|
852 | 953 | $airline_icao = ''; |
853 | 954 | if (!is_numeric(substr($ident, 0, 3))) |
854 | 955 | { |
@@ -1076,14 +1177,21 @@ discard block |
||
1076 | 1177 | default: |
1077 | 1178 | // Randomly use a generic function to get hours |
1078 | 1179 | if (strlen($airline_icao) == 2) { |
1079 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1180 | + if (!isset($globalSchedulesSources)) { |
|
1181 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1182 | + } |
|
1080 | 1183 | if (count($globalSchedulesSources) > 0) { |
1081 | 1184 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1082 | 1185 | $source = $globalSchedulesSources[$rand]; |
1083 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
1084 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
1186 | + if ($source == 'flightmapper') { |
|
1187 | + return $this->getFlightMapper($ident); |
|
1188 | + } elseif ($source == 'costtotravel') { |
|
1189 | + return $this->getCostToTravel($ident); |
|
1190 | + } |
|
1085 | 1191 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1086 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident); |
|
1192 | + elseif ($source == 'flightaware') { |
|
1193 | + return $this->getFlightAware($ident); |
|
1194 | + } |
|
1087 | 1195 | } |
1088 | 1196 | } |
1089 | 1197 | } |
@@ -1015,8 +1015,11 @@ discard block |
||
1015 | 1015 | $data = file_get_contents($filename); |
1016 | 1016 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
1017 | 1017 | //print_r($matches); |
1018 | - if (isset($matches[1])) return $matches[1]; |
|
1019 | - else return array(); |
|
1018 | + if (isset($matches[1])) { |
|
1019 | + return $matches[1]; |
|
1020 | + } else { |
|
1021 | + return array(); |
|
1022 | + } |
|
1020 | 1023 | } |
1021 | 1024 | public function getAllNOTAMbyScope($scope) { |
1022 | 1025 | global $globalDBdriver; |
@@ -1053,7 +1056,9 @@ discard block |
||
1053 | 1056 | $minlong = $maxlong; |
1054 | 1057 | $maxlong = $tmplong; |
1055 | 1058 | } |
1056 | - } else return array(); |
|
1059 | + } else { |
|
1060 | + return array(); |
|
1061 | + } |
|
1057 | 1062 | if ($globalDBdriver == 'mysql') { |
1058 | 1063 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
1059 | 1064 | } else { |
@@ -1077,7 +1082,9 @@ discard block |
||
1077 | 1082 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1078 | 1083 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1079 | 1084 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1080 | - } else return array(); |
|
1085 | + } else { |
|
1086 | + return array(); |
|
1087 | + } |
|
1081 | 1088 | if ($globalDBdriver == 'mysql') { |
1082 | 1089 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
1083 | 1090 | } else { |
@@ -1104,8 +1111,11 @@ discard block |
||
1104 | 1111 | return "error : ".$e->getMessage(); |
1105 | 1112 | } |
1106 | 1113 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1107 | - if (isset($all[0])) return $all[0]; |
|
1108 | - else return array(); |
|
1114 | + if (isset($all[0])) { |
|
1115 | + return $all[0]; |
|
1116 | + } else { |
|
1117 | + return array(); |
|
1118 | + } |
|
1109 | 1119 | } |
1110 | 1120 | |
1111 | 1121 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1183,7 +1193,9 @@ discard block |
||
1183 | 1193 | foreach ($alldata as $initial_data) { |
1184 | 1194 | $data = $this->parse($initial_data); |
1185 | 1195 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1186 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1196 | + if (count($notamref) == 0) { |
|
1197 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1198 | + } |
|
1187 | 1199 | } |
1188 | 1200 | } |
1189 | 1201 | } |
@@ -1196,7 +1208,9 @@ discard block |
||
1196 | 1208 | foreach ($alldata as $initial_data) { |
1197 | 1209 | $data = $this->parse($initial_data); |
1198 | 1210 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1199 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1211 | + if (!isset($notamref['notam_id'])) { |
|
1212 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1213 | + } |
|
1200 | 1214 | } |
1201 | 1215 | } |
1202 | 1216 | } |
@@ -1208,11 +1222,15 @@ discard block |
||
1208 | 1222 | foreach (array_chunk($allairports,20) as $airport) { |
1209 | 1223 | $airports_icao = array(); |
1210 | 1224 | foreach($airport as $icao) { |
1211 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
1225 | + if (isset($icao['icao'])) { |
|
1226 | + $airports_icao[] = $icao['icao']; |
|
1227 | + } |
|
1212 | 1228 | } |
1213 | 1229 | $airport_icao = implode(',',$airports_icao); |
1214 | 1230 | $alldata = $this->downloadNOTAM($airport_icao); |
1215 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
1231 | + if ($globalTransaction) { |
|
1232 | + $this->db->beginTransaction(); |
|
1233 | + } |
|
1216 | 1234 | if (count($alldata) > 0) { |
1217 | 1235 | foreach ($alldata as $initial_data) { |
1218 | 1236 | //print_r($initial_data); |
@@ -1221,14 +1239,23 @@ discard block |
||
1221 | 1239 | if (isset($data['ref'])) { |
1222 | 1240 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1223 | 1241 | if (count($notamref) == 0) { |
1224 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1225 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1226 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1242 | + if (isset($data['ref_replaced'])) { |
|
1243 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
1244 | + } |
|
1245 | + if (isset($data['ref_cancelled'])) { |
|
1246 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
1247 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
1248 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1249 | + } |
|
1227 | 1250 | } |
1228 | 1251 | } |
1229 | 1252 | } |
1230 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1231 | - if ($globalTransaction) $this->db->commit(); |
|
1253 | + } else { |
|
1254 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
1255 | + } |
|
1256 | + if ($globalTransaction) { |
|
1257 | + $this->db->commit(); |
|
1258 | + } |
|
1232 | 1259 | sleep(5); |
1233 | 1260 | } |
1234 | 1261 | } |
@@ -1241,8 +1268,11 @@ discard block |
||
1241 | 1268 | $data = $Common->getData($url); |
1242 | 1269 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1243 | 1270 | //print_r($matches); |
1244 | - if (isset($matches[1])) return $matches[1]; |
|
1245 | - else return array(); |
|
1271 | + if (isset($matches[1])) { |
|
1272 | + return $matches[1]; |
|
1273 | + } else { |
|
1274 | + return array(); |
|
1275 | + } |
|
1246 | 1276 | } |
1247 | 1277 | |
1248 | 1278 | public function parse($data) { |
@@ -1265,89 +1295,145 @@ discard block |
||
1265 | 1295 | $rules = str_split($matches[3]); |
1266 | 1296 | foreach ($rules as $rule) { |
1267 | 1297 | if ($rule == 'I') { |
1268 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
1269 | - else $result['rules'] = 'IFR'; |
|
1298 | + if (isset($result['rules'])) { |
|
1299 | + $result['rules'] = $result['rules'].'/IFR'; |
|
1300 | + } else { |
|
1301 | + $result['rules'] = 'IFR'; |
|
1302 | + } |
|
1270 | 1303 | } elseif ($rule == 'V') { |
1271 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
1272 | - else $result['rules'] = 'VFR'; |
|
1304 | + if (isset($result['rules'])) { |
|
1305 | + $result['rules'] = $result['rules'].'/VFR'; |
|
1306 | + } else { |
|
1307 | + $result['rules'] = 'VFR'; |
|
1308 | + } |
|
1273 | 1309 | } elseif ($rule == 'K') { |
1274 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
1275 | - else $result['rules'] = 'Checklist'; |
|
1310 | + if (isset($result['rules'])) { |
|
1311 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
1312 | + } else { |
|
1313 | + $result['rules'] = 'Checklist'; |
|
1314 | + } |
|
1276 | 1315 | } |
1277 | 1316 | } |
1278 | 1317 | $attentions = str_split($matches[4]); |
1279 | 1318 | foreach ($attentions as $attention) { |
1280 | 1319 | if ($attention == 'N') { |
1281 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1282 | - else $result['rules'] = 'Immediate attention'; |
|
1320 | + if (isset($result['attention'])) { |
|
1321 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
1322 | + } else { |
|
1323 | + $result['rules'] = 'Immediate attention'; |
|
1324 | + } |
|
1283 | 1325 | } elseif ($attention == 'B') { |
1284 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
1285 | - else $result['rules'] = 'Operational significance'; |
|
1326 | + if (isset($result['attention'])) { |
|
1327 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
1328 | + } else { |
|
1329 | + $result['rules'] = 'Operational significance'; |
|
1330 | + } |
|
1286 | 1331 | } elseif ($attention == 'O') { |
1287 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
1288 | - else $result['rules'] = 'Flight operations'; |
|
1332 | + if (isset($result['attention'])) { |
|
1333 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
1334 | + } else { |
|
1335 | + $result['rules'] = 'Flight operations'; |
|
1336 | + } |
|
1289 | 1337 | } elseif ($attention == 'M') { |
1290 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
1291 | - else $result['rules'] = 'Misc'; |
|
1338 | + if (isset($result['attention'])) { |
|
1339 | + $result['attention'] = $result['attention'].' / Misc'; |
|
1340 | + } else { |
|
1341 | + $result['rules'] = 'Misc'; |
|
1342 | + } |
|
1292 | 1343 | } elseif ($attention == 'K') { |
1293 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
1294 | - else $result['rules'] = 'Checklist'; |
|
1344 | + if (isset($result['attention'])) { |
|
1345 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
1346 | + } else { |
|
1347 | + $result['rules'] = 'Checklist'; |
|
1348 | + } |
|
1295 | 1349 | } |
1296 | 1350 | } |
1297 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
1298 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
1299 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
1300 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
1301 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
1302 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
1351 | + if ($matches[5] == 'A') { |
|
1352 | + $result['scope'] = 'Airport warning'; |
|
1353 | + } elseif ($matches[5] == 'E') { |
|
1354 | + $result['scope'] = 'Enroute warning'; |
|
1355 | + } elseif ($matches[5] == 'W') { |
|
1356 | + $result['scope'] = 'Navigation warning'; |
|
1357 | + } elseif ($matches[5] == 'K') { |
|
1358 | + $result['scope'] = 'Checklist'; |
|
1359 | + } elseif ($matches[5] == 'AE') { |
|
1360 | + $result['scope'] = 'Airport/Enroute warning'; |
|
1361 | + } elseif ($matches[5] == 'AW') { |
|
1362 | + $result['scope'] = 'Airport/Navigation warning'; |
|
1363 | + } |
|
1303 | 1364 | $result['lower_limit'] = $matches[6]; |
1304 | 1365 | $result['upper_limit'] = $matches[7]; |
1305 | 1366 | $latitude = $Common->convertDec($matches[8],'latitude'); |
1306 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
1367 | + if ($matches[9] == 'S') { |
|
1368 | + $latitude = -$latitude; |
|
1369 | + } |
|
1307 | 1370 | $longitude = $Common->convertDec($matches[10],'longitude'); |
1308 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
1371 | + if ($matches[11] == 'W') { |
|
1372 | + $longitude = -$longitude; |
|
1373 | + } |
|
1309 | 1374 | $result['latitude'] = $latitude; |
1310 | 1375 | $result['longitude'] = $longitude; |
1311 | 1376 | $result['radius'] = intval($matches[12]); |
1312 | - } else echo 'ERROR : '.$line."\n"; |
|
1313 | - } |
|
1314 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1377 | + } else { |
|
1378 | + echo 'ERROR : '.$line."\n"; |
|
1379 | + } |
|
1380 | + } elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
1315 | 1381 | $result['icao'] = $matches[1]; |
1316 | - } |
|
1317 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1318 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1319 | - else $year = '20'.$matches[1]; |
|
1382 | + } elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
1383 | + if ($matches[1] > 50) { |
|
1384 | + $year = '19'.$matches[1]; |
|
1385 | + } else { |
|
1386 | + $year = '20'.$matches[1]; |
|
1387 | + } |
|
1320 | 1388 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1321 | - } |
|
1322 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1323 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1324 | - else $year = '20'.$matches[1]; |
|
1389 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
1390 | + if ($matches[1] > 50) { |
|
1391 | + $year = '19'.$matches[1]; |
|
1392 | + } else { |
|
1393 | + $year = '20'.$matches[1]; |
|
1394 | + } |
|
1325 | 1395 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1326 | 1396 | $result['permanent'] = 0; |
1327 | - } |
|
1328 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1329 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
1330 | - else $year = '20'.$matches[1]; |
|
1397 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
1398 | + if ($matches[1] > 50) { |
|
1399 | + $year = '19'.$matches[1]; |
|
1400 | + } else { |
|
1401 | + $year = '20'.$matches[1]; |
|
1402 | + } |
|
1331 | 1403 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
1332 | - if ($matches[6] == 'EST') $result['estimated'] = 1; |
|
1333 | - else $result['estimated'] = 0; |
|
1334 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; |
|
1335 | - else $result['permanent'] = 0; |
|
1336 | - } |
|
1337 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1404 | + if ($matches[6] == 'EST') { |
|
1405 | + $result['estimated'] = 1; |
|
1406 | + } else { |
|
1407 | + $result['estimated'] = 0; |
|
1408 | + } |
|
1409 | + if ($matches[6] == 'PERM') { |
|
1410 | + $result['permanent'] = 1; |
|
1411 | + } else { |
|
1412 | + $result['permanent'] = 0; |
|
1413 | + } |
|
1414 | + } elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
1338 | 1415 | $result['date_end'] = '2030/12/20 12:00'; |
1339 | - if ($matches[1] == 'EST') $result['estimated'] = 1; |
|
1340 | - else $result['estimated'] = 0; |
|
1341 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; |
|
1342 | - else $result['permanent'] = 0; |
|
1343 | - } |
|
1344 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1416 | + if ($matches[1] == 'EST') { |
|
1417 | + $result['estimated'] = 1; |
|
1418 | + } else { |
|
1419 | + $result['estimated'] = 0; |
|
1420 | + } |
|
1421 | + if ($matches[1] == 'PERM') { |
|
1422 | + $result['permanent'] = 1; |
|
1423 | + } else { |
|
1424 | + $result['permanent'] = 0; |
|
1425 | + } |
|
1426 | + } elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
1345 | 1427 | $rtext = array(); |
1346 | 1428 | $text = explode(' ',$matches[1]); |
1347 | 1429 | foreach ($text as $word) { |
1348 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
1349 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1350 | - else $rtext[] = $word; |
|
1430 | + if (isset($this->abbr[$word])) { |
|
1431 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
1432 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
1433 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1434 | + } else { |
|
1435 | + $rtext[] = $word; |
|
1436 | + } |
|
1351 | 1437 | } |
1352 | 1438 | $result['text'] = implode(' ',$rtext); |
1353 | 1439 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
@@ -1355,7 +1441,9 @@ discard block |
||
1355 | 1441 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
1356 | 1442 | $text = explode(' ',$line); |
1357 | 1443 | $result['ref'] = $text[0]; |
1358 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
1444 | + if ($matches[1] == 'NOTAMN') { |
|
1445 | + $result['type'] = 'new'; |
|
1446 | + } |
|
1359 | 1447 | if ($matches[1] == 'NOTAMC') { |
1360 | 1448 | $result['type'] = 'cancel'; |
1361 | 1449 | $result['ref_cancelled'] = $text[2]; |
@@ -1377,69 +1465,101 @@ discard block |
||
1377 | 1465 | switch ($code[1]) { |
1378 | 1466 | case 'A': |
1379 | 1467 | $result = 'Airspace organization '; |
1380 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
1468 | + if (isset($this->code_airspace[$code_fp])) { |
|
1469 | + $result .= $this->code_airspace[$code_fp]; |
|
1470 | + } |
|
1381 | 1471 | break; |
1382 | 1472 | case 'C': |
1383 | 1473 | $result = 'Communications and radar facilities '; |
1384 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
1474 | + if (isset($this->code_comradar[$code_fp])) { |
|
1475 | + $result .= $this->code_comradar[$code_fp]; |
|
1476 | + } |
|
1385 | 1477 | break; |
1386 | 1478 | case 'F': |
1387 | 1479 | $result = 'Facilities and services '; |
1388 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
1480 | + if (isset($this->code_facilities[$code_fp])) { |
|
1481 | + $result .= $this->code_facilities[$code_fp]; |
|
1482 | + } |
|
1389 | 1483 | break; |
1390 | 1484 | case 'I': |
1391 | 1485 | $result = 'Instrument and Microwave Landing System '; |
1392 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
1486 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
1487 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
1488 | + } |
|
1393 | 1489 | break; |
1394 | 1490 | case 'L': |
1395 | 1491 | $result = 'Lighting facilities '; |
1396 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
1492 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
1493 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
1494 | + } |
|
1397 | 1495 | break; |
1398 | 1496 | case 'M': |
1399 | 1497 | $result = 'Movement and landing areas '; |
1400 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
1498 | + if (isset($this->code_movementareas[$code_fp])) { |
|
1499 | + $result .= $this->code_movementareas[$code_fp]; |
|
1500 | + } |
|
1401 | 1501 | break; |
1402 | 1502 | case 'N': |
1403 | 1503 | $result = 'Terminal and En Route Navigation Facilities '; |
1404 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
1504 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
1505 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
1506 | + } |
|
1405 | 1507 | break; |
1406 | 1508 | case 'O': |
1407 | 1509 | $result = 'Other information '; |
1408 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
1510 | + if (isset($this->code_information[$code_fp])) { |
|
1511 | + $result .= $this->code_information[$code_fp]; |
|
1512 | + } |
|
1409 | 1513 | break; |
1410 | 1514 | case 'P': |
1411 | 1515 | $result = 'Air Traffic procedures '; |
1412 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
1516 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
1517 | + $result .= $this->code_airtraffic[$code_fp]; |
|
1518 | + } |
|
1413 | 1519 | break; |
1414 | 1520 | case 'R': |
1415 | 1521 | $result = 'Navigation Warnings: Airspace Restrictions '; |
1416 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
1522 | + if (isset($this->code_navigationw[$code_fp])) { |
|
1523 | + $result .= $this->code_navigationw[$code_fp]; |
|
1524 | + } |
|
1417 | 1525 | break; |
1418 | 1526 | case 'S': |
1419 | 1527 | $result = 'Air Traffic and VOLMET Services '; |
1420 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
1528 | + if (isset($this->code_volmet[$code_fp])) { |
|
1529 | + $result .= $this->code_volmet[$code_fp]; |
|
1530 | + } |
|
1421 | 1531 | break; |
1422 | 1532 | case 'W': |
1423 | 1533 | $result = 'Navigation Warnings: Warnings '; |
1424 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
1534 | + if (isset($this->code_warnings[$code_fp])) { |
|
1535 | + $result .= $this->code_warnings[$code_fp]; |
|
1536 | + } |
|
1425 | 1537 | break; |
1426 | 1538 | } |
1427 | 1539 | switch ($code[3]) { |
1428 | 1540 | case 'A': |
1429 | 1541 | // Availability |
1430 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1542 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
1543 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
1544 | + } |
|
1431 | 1545 | break; |
1432 | 1546 | case 'C': |
1433 | 1547 | // Changes |
1434 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1548 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
1549 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
1550 | + } |
|
1435 | 1551 | break; |
1436 | 1552 | case 'H': |
1437 | 1553 | // Hazardous conditions |
1438 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1554 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
1555 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
1556 | + } |
|
1439 | 1557 | break; |
1440 | 1558 | case 'L': |
1441 | 1559 | // Limitations |
1442 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1560 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
1561 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
1562 | + } |
|
1443 | 1563 | break; |
1444 | 1564 | case 'X': |
1445 | 1565 | // Other Information |