@@ -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 |
@@ -159,8 +159,9 @@ discard block |
||
159 | 159 | if ($show_attr && count($this->attr)>0) |
160 | 160 | { |
161 | 161 | echo '('; |
162 | - foreach ($this->attr as $k=>$v) |
|
163 | - echo "[$k]=>\"".$this->$k.'", '; |
|
162 | + foreach ($this->attr as $k=>$v) { |
|
163 | + echo "[$k]=>\"".$this->$k.'", '; |
|
164 | + } |
|
164 | 165 | echo ')'; |
165 | 166 | } |
166 | 167 | echo "\n"; |
@@ -218,8 +219,7 @@ discard block |
||
218 | 219 | if (isset($node->_[HDOM_INFO_INNER])) |
219 | 220 | { |
220 | 221 | $string .= $node->_[HDOM_INFO_INNER] . "'"; |
221 | - } |
|
222 | - else |
|
222 | + } else |
|
223 | 223 | { |
224 | 224 | $string .= ' NULL '; |
225 | 225 | } |
@@ -233,8 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | echo $string; |
235 | 235 | return; |
236 | - } |
|
237 | - else |
|
236 | + } else |
|
238 | 237 | { |
239 | 238 | return $string; |
240 | 239 | } |
@@ -320,12 +319,17 @@ discard block |
||
320 | 319 | // returns the previous sibling of node |
321 | 320 | function prev_sibling() |
322 | 321 | { |
323 | - if ($this->parent===null) return null; |
|
322 | + if ($this->parent===null) { |
|
323 | + return null; |
|
324 | + } |
|
324 | 325 | $idx = 0; |
325 | 326 | $count = count($this->parent->children); |
326 | - while ($idx<$count && $this!==$this->parent->children[$idx]) |
|
327 | - ++$idx; |
|
328 | - if (--$idx<0) return null; |
|
327 | + while ($idx<$count && $this!==$this->parent->children[$idx]) { |
|
328 | + ++$idx; |
|
329 | + } |
|
330 | + if (--$idx<0) { |
|
331 | + return null; |
|
332 | + } |
|
329 | 333 | return $this->parent->children[$idx]; |
330 | 334 | } |
331 | 335 | |
@@ -354,12 +358,17 @@ discard block |
||
354 | 358 | // get dom node's inner html |
355 | 359 | function innertext() |
356 | 360 | { |
357 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
358 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
361 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
362 | + return $this->_[HDOM_INFO_INNER]; |
|
363 | + } |
|
364 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
365 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
366 | + } |
|
359 | 367 | |
360 | 368 | $ret = ''; |
361 | - foreach ($this->nodes as $n) |
|
362 | - $ret .= $n->outertext(); |
|
369 | + foreach ($this->nodes as $n) { |
|
370 | + $ret .= $n->outertext(); |
|
371 | + } |
|
363 | 372 | return $ret; |
364 | 373 | } |
365 | 374 | |
@@ -380,7 +389,9 @@ discard block |
||
380 | 389 | $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text); |
381 | 390 | } |
382 | 391 | |
383 | - if ($this->tag==='root') return $this->innertext(); |
|
392 | + if ($this->tag==='root') { |
|
393 | + return $this->innertext(); |
|
394 | + } |
|
384 | 395 | |
385 | 396 | // trigger callback |
386 | 397 | if ($this->dom && $this->dom->callback!==null) |
@@ -388,8 +399,12 @@ discard block |
||
388 | 399 | call_user_func_array($this->dom->callback, array($this)); |
389 | 400 | } |
390 | 401 | |
391 | - if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER]; |
|
392 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
402 | + if (isset($this->_[HDOM_INFO_OUTER])) { |
|
403 | + return $this->_[HDOM_INFO_OUTER]; |
|
404 | + } |
|
405 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
406 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
407 | + } |
|
393 | 408 | |
394 | 409 | // render begin tag |
395 | 410 | if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) |
@@ -418,23 +433,30 @@ discard block |
||
418 | 433 | } |
419 | 434 | |
420 | 435 | // render end tag |
421 | - if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) |
|
422 | - $ret .= '</'.$this->tag.'>'; |
|
436 | + if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) { |
|
437 | + $ret .= '</'.$this->tag.'>'; |
|
438 | + } |
|
423 | 439 | return $ret; |
424 | 440 | } |
425 | 441 | |
426 | 442 | // get dom node's plain text |
427 | 443 | function text() |
428 | 444 | { |
429 | - if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER]; |
|
445 | + if (isset($this->_[HDOM_INFO_INNER])) { |
|
446 | + return $this->_[HDOM_INFO_INNER]; |
|
447 | + } |
|
430 | 448 | switch ($this->nodetype) |
431 | 449 | { |
432 | 450 | case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
433 | 451 | case HDOM_TYPE_COMMENT: return ''; |
434 | 452 | case HDOM_TYPE_UNKNOWN: return ''; |
435 | 453 | } |
436 | - if (strcasecmp($this->tag, 'script')===0) return ''; |
|
437 | - if (strcasecmp($this->tag, 'style')===0) return ''; |
|
454 | + if (strcasecmp($this->tag, 'script')===0) { |
|
455 | + return ''; |
|
456 | + } |
|
457 | + if (strcasecmp($this->tag, 'style')===0) { |
|
458 | + return ''; |
|
459 | + } |
|
438 | 460 | |
439 | 461 | $ret = ''; |
440 | 462 | // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL. |
@@ -470,7 +492,9 @@ discard block |
||
470 | 492 | function makeup() |
471 | 493 | { |
472 | 494 | // text, comment, unknown |
473 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
495 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
496 | + return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]); |
|
497 | + } |
|
474 | 498 | |
475 | 499 | $ret = '<'.$this->tag; |
476 | 500 | $i = -1; |
@@ -480,14 +504,15 @@ discard block |
||
480 | 504 | ++$i; |
481 | 505 | |
482 | 506 | // skip removed attribute |
483 | - if ($val===null || $val===false) |
|
484 | - continue; |
|
507 | + if ($val===null || $val===false) { |
|
508 | + continue; |
|
509 | + } |
|
485 | 510 | |
486 | 511 | $ret .= $this->_[HDOM_INFO_SPACE][$i][0]; |
487 | 512 | //no value attr: nowrap, checked selected... |
488 | - if ($val===true) |
|
489 | - $ret .= $key; |
|
490 | - else { |
|
513 | + if ($val===true) { |
|
514 | + $ret .= $key; |
|
515 | + } else { |
|
491 | 516 | switch ($this->_[HDOM_INFO_QUOTE][$i]) |
492 | 517 | { |
493 | 518 | case HDOM_QUOTE_DOUBLE: $quote = '"'; break; |
@@ -506,7 +531,9 @@ discard block |
||
506 | 531 | function find($selector, $idx=null, $lowercase=false) |
507 | 532 | { |
508 | 533 | $selectors = $this->parse_selector($selector); |
509 | - if (($count=count($selectors))===0) return array(); |
|
534 | + if (($count=count($selectors))===0) { |
|
535 | + return array(); |
|
536 | + } |
|
510 | 537 | $found_keys = array(); |
511 | 538 | |
512 | 539 | // find each selector |
@@ -514,8 +541,12 @@ discard block |
||
514 | 541 | { |
515 | 542 | // The change on the below line was documented on the sourceforge code tracker id 2788009 |
516 | 543 | // used to be: if (($levle=count($selectors[0]))===0) return array(); |
517 | - if (($levle=count($selectors[$c]))===0) return array(); |
|
518 | - if (!isset($this->_[HDOM_INFO_BEGIN])) return array(); |
|
544 | + if (($levle=count($selectors[$c]))===0) { |
|
545 | + return array(); |
|
546 | + } |
|
547 | + if (!isset($this->_[HDOM_INFO_BEGIN])) { |
|
548 | + return array(); |
|
549 | + } |
|
519 | 550 | |
520 | 551 | $head = array($this->_[HDOM_INFO_BEGIN]=>1); |
521 | 552 | |
@@ -545,12 +576,16 @@ discard block |
||
545 | 576 | ksort($found_keys); |
546 | 577 | |
547 | 578 | $found = array(); |
548 | - foreach ($found_keys as $k=>$v) |
|
549 | - $found[] = $this->dom->nodes[$k]; |
|
579 | + foreach ($found_keys as $k=>$v) { |
|
580 | + $found[] = $this->dom->nodes[$k]; |
|
581 | + } |
|
550 | 582 | |
551 | 583 | // return nth-element or array |
552 | - if (is_null($idx)) return $found; |
|
553 | - else if ($idx<0) $idx = count($found) + $idx; |
|
584 | + if (is_null($idx)) { |
|
585 | + return $found; |
|
586 | + } else if ($idx<0) { |
|
587 | + $idx = count($found) + $idx; |
|
588 | + } |
|
554 | 589 | return (isset($found[$idx])) ? $found[$idx] : null; |
555 | 590 | } |
556 | 591 | |
@@ -595,8 +630,9 @@ discard block |
||
595 | 630 | $pass = true; |
596 | 631 | |
597 | 632 | if ($tag==='*' && !$key) { |
598 | - if (in_array($node, $this->children, true)) |
|
599 | - $ret[$i] = 1; |
|
633 | + if (in_array($node, $this->children, true)) { |
|
634 | + $ret[$i] = 1; |
|
635 | + } |
|
600 | 636 | continue; |
601 | 637 | } |
602 | 638 | |
@@ -605,9 +641,13 @@ discard block |
||
605 | 641 | // compare key |
606 | 642 | if ($pass && $key) { |
607 | 643 | if ($no_key) { |
608 | - if (isset($node->attr[$key])) $pass=false; |
|
644 | + if (isset($node->attr[$key])) { |
|
645 | + $pass=false; |
|
646 | + } |
|
609 | 647 | } else { |
610 | - if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false; |
|
648 | + if (($key != "plaintext") && !isset($node->attr[$key])) { |
|
649 | + $pass=false; |
|
650 | + } |
|
611 | 651 | } |
612 | 652 | } |
613 | 653 | // compare value |
@@ -640,13 +680,19 @@ discard block |
||
640 | 680 | } else { |
641 | 681 | $check = $this->match($exp, $val, $k); |
642 | 682 | } |
643 | - if ($check) break; |
|
683 | + if ($check) { |
|
684 | + break; |
|
685 | + } |
|
644 | 686 | } |
645 | 687 | } |
646 | 688 | } |
647 | - if (!$check) $pass = false; |
|
689 | + if (!$check) { |
|
690 | + $pass = false; |
|
691 | + } |
|
692 | + } |
|
693 | + if ($pass) { |
|
694 | + $ret[$i] = 1; |
|
648 | 695 | } |
649 | - if ($pass) $ret[$i] = 1; |
|
650 | 696 | unset($node); |
651 | 697 | } |
652 | 698 | // It's passed by reference so this is actually what this function returns. |
@@ -696,9 +742,13 @@ discard block |
||
696 | 742 | |
697 | 743 | foreach ($matches as $m) { |
698 | 744 | $m[0] = trim($m[0]); |
699 | - if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue; |
|
745 | + if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') { |
|
746 | + continue; |
|
747 | + } |
|
700 | 748 | // for browser generated xpath |
701 | - if ($m[1]==='tbody') continue; |
|
749 | + if ($m[1]==='tbody') { |
|
750 | + continue; |
|
751 | + } |
|
702 | 752 | |
703 | 753 | list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false); |
704 | 754 | if (!empty($m[2])) {$key='id'; $val=$m[2];} |
@@ -718,8 +768,9 @@ discard block |
||
718 | 768 | $result = array(); |
719 | 769 | } |
720 | 770 | } |
721 | - if (count($result)>0) |
|
722 | - $selectors[] = $result; |
|
771 | + if (count($result)>0) { |
|
772 | + $selectors[] = $result; |
|
773 | + } |
|
723 | 774 | return $selectors; |
724 | 775 | } |
725 | 776 | |
@@ -748,7 +799,9 @@ discard block |
||
748 | 799 | { |
749 | 800 | case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value; |
750 | 801 | case 'innertext': |
751 | - if (isset($this->_[HDOM_INFO_TEXT])) return $this->_[HDOM_INFO_TEXT] = $value; |
|
802 | + if (isset($this->_[HDOM_INFO_TEXT])) { |
|
803 | + return $this->_[HDOM_INFO_TEXT] = $value; |
|
804 | + } |
|
752 | 805 | return $this->_[HDOM_INFO_INNER] = $value; |
753 | 806 | } |
754 | 807 | if (!isset($this->attr[$name])) |
@@ -772,8 +825,9 @@ discard block |
||
772 | 825 | } |
773 | 826 | |
774 | 827 | function __unset($name) { |
775 | - if (isset($this->attr[$name])) |
|
776 | - unset($this->attr[$name]); |
|
828 | + if (isset($this->attr[$name])) { |
|
829 | + unset($this->attr[$name]); |
|
830 | + } |
|
777 | 831 | } |
778 | 832 | |
779 | 833 | // PaperG - Function to convert the text from one character set to another if the two sets are not the same. |
@@ -800,8 +854,7 @@ discard block |
||
800 | 854 | if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text))) |
801 | 855 | { |
802 | 856 | $converted_text = $text; |
803 | - } |
|
804 | - else |
|
857 | + } else |
|
805 | 858 | { |
806 | 859 | $converted_text = iconv($sourceCharset, $targetCharset, $text); |
807 | 860 | } |
@@ -839,19 +892,31 @@ discard block |
||
839 | 892 | $c=ord($str[$i]); |
840 | 893 | if($c > 128) |
841 | 894 | { |
842 | - if(($c >= 254)) return false; |
|
843 | - elseif($c >= 252) $bits=6; |
|
844 | - elseif($c >= 248) $bits=5; |
|
845 | - elseif($c >= 240) $bits=4; |
|
846 | - elseif($c >= 224) $bits=3; |
|
847 | - elseif($c >= 192) $bits=2; |
|
848 | - else return false; |
|
849 | - if(($i+$bits) > $len) return false; |
|
895 | + if(($c >= 254)) { |
|
896 | + return false; |
|
897 | + } elseif($c >= 252) { |
|
898 | + $bits=6; |
|
899 | + } elseif($c >= 248) { |
|
900 | + $bits=5; |
|
901 | + } elseif($c >= 240) { |
|
902 | + $bits=4; |
|
903 | + } elseif($c >= 224) { |
|
904 | + $bits=3; |
|
905 | + } elseif($c >= 192) { |
|
906 | + $bits=2; |
|
907 | + } else { |
|
908 | + return false; |
|
909 | + } |
|
910 | + if(($i+$bits) > $len) { |
|
911 | + return false; |
|
912 | + } |
|
850 | 913 | while($bits > 1) |
851 | 914 | { |
852 | 915 | $i++; |
853 | 916 | $b=ord($str[$i]); |
854 | - if($b < 128 || $b > 191) return false; |
|
917 | + if($b < 128 || $b > 191) { |
|
918 | + return false; |
|
919 | + } |
|
855 | 920 | $bits--; |
856 | 921 | } |
857 | 922 | } |
@@ -1035,8 +1100,7 @@ discard block |
||
1035 | 1100 | if (preg_match("/^http:\/\//i",$str) || is_file($str)) |
1036 | 1101 | { |
1037 | 1102 | $this->load_file($str); |
1038 | - } |
|
1039 | - else |
|
1103 | + } else |
|
1040 | 1104 | { |
1041 | 1105 | $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText); |
1042 | 1106 | } |
@@ -1118,7 +1182,9 @@ discard block |
||
1118 | 1182 | function save($filepath='') |
1119 | 1183 | { |
1120 | 1184 | $ret = $this->root->innertext(); |
1121 | - if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX); |
|
1185 | + if ($filepath!=='') { |
|
1186 | + file_put_contents($filepath, $ret, LOCK_EX); |
|
1187 | + } |
|
1122 | 1188 | return $ret; |
1123 | 1189 | } |
1124 | 1190 | |
@@ -1134,7 +1200,10 @@ discard block |
||
1134 | 1200 | { |
1135 | 1201 | foreach ($this->nodes as $n) {$n->clear(); $n = null;} |
1136 | 1202 | // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear. |
1137 | - if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;} |
|
1203 | + if (isset($this->children)) { |
|
1204 | + foreach ($this->children as $n) {$n->clear(); |
|
1205 | + } |
|
1206 | + $n = null;} |
|
1138 | 1207 | if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);} |
1139 | 1208 | if (isset($this->root)) {$this->root->clear(); unset($this->root);} |
1140 | 1209 | unset($this->doc); |
@@ -1178,7 +1247,9 @@ discard block |
||
1178 | 1247 | $this->root->_[HDOM_INFO_BEGIN] = -1; |
1179 | 1248 | $this->root->nodetype = HDOM_TYPE_ROOT; |
1180 | 1249 | $this->parent = $this->root; |
1181 | - if ($this->size>0) $this->char = $this->doc[0]; |
|
1250 | + if ($this->size>0) { |
|
1251 | + $this->char = $this->doc[0]; |
|
1252 | + } |
|
1182 | 1253 | } |
1183 | 1254 | |
1184 | 1255 | // parse html content |
@@ -1232,8 +1303,7 @@ discard block |
||
1232 | 1303 | if ($success) |
1233 | 1304 | { |
1234 | 1305 | $charset = $matches[1]; |
1235 | - } |
|
1236 | - else |
|
1306 | + } else |
|
1237 | 1307 | { |
1238 | 1308 | // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1 |
1239 | 1309 | if (is_object($debug_object)) {$debug_object->debug_log(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');} |
@@ -1296,8 +1366,9 @@ discard block |
||
1296 | 1366 | $tag = $this->copy_until_char('>'); |
1297 | 1367 | |
1298 | 1368 | // skip attributes in end tag |
1299 | - if (($pos = strpos($tag, ' '))!==false) |
|
1300 | - $tag = substr($tag, 0, $pos); |
|
1369 | + if (($pos = strpos($tag, ' '))!==false) { |
|
1370 | + $tag = substr($tag, 0, $pos); |
|
1371 | + } |
|
1301 | 1372 | |
1302 | 1373 | $parent_lower = strtolower($this->parent->tag); |
1303 | 1374 | $tag_lower = strtolower($tag); |
@@ -1309,23 +1380,26 @@ discard block |
||
1309 | 1380 | $this->parent->_[HDOM_INFO_END] = 0; |
1310 | 1381 | $org_parent = $this->parent; |
1311 | 1382 | |
1312 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1313 | - $this->parent = $this->parent->parent; |
|
1383 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1384 | + $this->parent = $this->parent->parent; |
|
1385 | + } |
|
1314 | 1386 | |
1315 | 1387 | if (strtolower($this->parent->tag)!==$tag_lower) { |
1316 | 1388 | $this->parent = $org_parent; // restore origonal parent |
1317 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1389 | + if ($this->parent->parent) { |
|
1390 | + $this->parent = $this->parent->parent; |
|
1391 | + } |
|
1318 | 1392 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1319 | 1393 | return $this->as_text_node($tag); |
1320 | 1394 | } |
1321 | - } |
|
1322 | - else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1395 | + } else if (($this->parent->parent) && isset($this->block_tags[$tag_lower])) |
|
1323 | 1396 | { |
1324 | 1397 | $this->parent->_[HDOM_INFO_END] = 0; |
1325 | 1398 | $org_parent = $this->parent; |
1326 | 1399 | |
1327 | - while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) |
|
1328 | - $this->parent = $this->parent->parent; |
|
1400 | + while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) { |
|
1401 | + $this->parent = $this->parent->parent; |
|
1402 | + } |
|
1329 | 1403 | |
1330 | 1404 | if (strtolower($this->parent->tag)!==$tag_lower) |
1331 | 1405 | { |
@@ -1333,18 +1407,19 @@ discard block |
||
1333 | 1407 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1334 | 1408 | return $this->as_text_node($tag); |
1335 | 1409 | } |
1336 | - } |
|
1337 | - else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1410 | + } else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) |
|
1338 | 1411 | { |
1339 | 1412 | $this->parent->_[HDOM_INFO_END] = 0; |
1340 | 1413 | $this->parent = $this->parent->parent; |
1414 | + } else { |
|
1415 | + return $this->as_text_node($tag); |
|
1341 | 1416 | } |
1342 | - else |
|
1343 | - return $this->as_text_node($tag); |
|
1344 | 1417 | } |
1345 | 1418 | |
1346 | 1419 | $this->parent->_[HDOM_INFO_END] = $this->cursor; |
1347 | - if ($this->parent->parent) $this->parent = $this->parent->parent; |
|
1420 | + if ($this->parent->parent) { |
|
1421 | + $this->parent = $this->parent->parent; |
|
1422 | + } |
|
1348 | 1423 | |
1349 | 1424 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1350 | 1425 | return true; |
@@ -1367,7 +1442,9 @@ discard block |
||
1367 | 1442 | $node->nodetype = HDOM_TYPE_UNKNOWN; |
1368 | 1443 | $node->tag = 'unknown'; |
1369 | 1444 | } |
1370 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1445 | + if ($this->char==='>') { |
|
1446 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1447 | + } |
|
1371 | 1448 | $this->link_nodes($node, true); |
1372 | 1449 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1373 | 1450 | return true; |
@@ -1389,7 +1466,9 @@ discard block |
||
1389 | 1466 | return true; |
1390 | 1467 | } |
1391 | 1468 | |
1392 | - if ($this->char==='>') $node->_[HDOM_INFO_TEXT].='>'; |
|
1469 | + if ($this->char==='>') { |
|
1470 | + $node->_[HDOM_INFO_TEXT].='>'; |
|
1471 | + } |
|
1393 | 1472 | $this->link_nodes($node, false); |
1394 | 1473 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1395 | 1474 | return true; |
@@ -1455,22 +1534,26 @@ discard block |
||
1455 | 1534 | if ($name!=='/' && $name!=='') { |
1456 | 1535 | $space[1] = $this->copy_skip($this->token_blank); |
1457 | 1536 | $name = $this->restore_noise($name); |
1458 | - if ($this->lowercase) $name = strtolower($name); |
|
1537 | + if ($this->lowercase) { |
|
1538 | + $name = strtolower($name); |
|
1539 | + } |
|
1459 | 1540 | if ($this->char==='=') { |
1460 | 1541 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1461 | 1542 | $this->parse_attr($node, $name, $space); |
1462 | - } |
|
1463 | - else { |
|
1543 | + } else { |
|
1464 | 1544 | //no value attr: nowrap, checked selected... |
1465 | 1545 | $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO; |
1466 | 1546 | $node->attr[$name] = true; |
1467 | - if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev |
|
1547 | + if ($this->char!='>') { |
|
1548 | + $this->char = $this->doc[--$this->pos]; |
|
1549 | + } |
|
1550 | + // prev |
|
1468 | 1551 | } |
1469 | 1552 | $node->_[HDOM_INFO_SPACE][] = $space; |
1470 | 1553 | $space = array($this->copy_skip($this->token_blank), '', ''); |
1554 | + } else { |
|
1555 | + break; |
|
1471 | 1556 | } |
1472 | - else |
|
1473 | - break; |
|
1474 | 1557 | } while ($this->char!=='>' && $this->char!=='/'); |
1475 | 1558 | |
1476 | 1559 | $this->link_nodes($node, true); |
@@ -1481,11 +1564,12 @@ discard block |
||
1481 | 1564 | { |
1482 | 1565 | $node->_[HDOM_INFO_ENDSPACE] .= '/'; |
1483 | 1566 | $node->_[HDOM_INFO_END] = 0; |
1484 | - } |
|
1485 | - else |
|
1567 | + } else |
|
1486 | 1568 | { |
1487 | 1569 | // reset parent |
1488 | - if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node; |
|
1570 | + if (!isset($this->self_closing_tags[strtolower($node->tag)])) { |
|
1571 | + $this->parent = $node; |
|
1572 | + } |
|
1489 | 1573 | } |
1490 | 1574 | $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1491 | 1575 | |
@@ -1571,7 +1655,9 @@ discard block |
||
1571 | 1655 | $len = strspn($this->doc, $chars, $pos); |
1572 | 1656 | $this->pos += $len; |
1573 | 1657 | $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next |
1574 | - if ($len===0) return ''; |
|
1658 | + if ($len===0) { |
|
1659 | + return ''; |
|
1660 | + } |
|
1575 | 1661 | return substr($this->doc, $pos, $len); |
1576 | 1662 | } |
1577 | 1663 | |
@@ -1586,7 +1672,9 @@ discard block |
||
1586 | 1672 | |
1587 | 1673 | protected function copy_until_char($char) |
1588 | 1674 | { |
1589 | - if ($this->char===null) return ''; |
|
1675 | + if ($this->char===null) { |
|
1676 | + return ''; |
|
1677 | + } |
|
1590 | 1678 | |
1591 | 1679 | if (($pos = strpos($this->doc, $char, $this->pos))===false) { |
1592 | 1680 | $ret = substr($this->doc, $this->pos, $this->size-$this->pos); |
@@ -1595,7 +1683,9 @@ discard block |
||
1595 | 1683 | return $ret; |
1596 | 1684 | } |
1597 | 1685 | |
1598 | - if ($pos===$this->pos) return ''; |
|
1686 | + if ($pos===$this->pos) { |
|
1687 | + return ''; |
|
1688 | + } |
|
1599 | 1689 | $pos_old = $this->pos; |
1600 | 1690 | $this->char = $this->doc[$pos]; |
1601 | 1691 | $this->pos = $pos; |
@@ -1604,7 +1694,9 @@ discard block |
||
1604 | 1694 | |
1605 | 1695 | protected function copy_until_char_escape($char) |
1606 | 1696 | { |
1607 | - if ($this->char===null) return ''; |
|
1697 | + if ($this->char===null) { |
|
1698 | + return ''; |
|
1699 | + } |
|
1608 | 1700 | |
1609 | 1701 | $start = $this->pos; |
1610 | 1702 | while (1) |
@@ -1617,7 +1709,9 @@ discard block |
||
1617 | 1709 | return $ret; |
1618 | 1710 | } |
1619 | 1711 | |
1620 | - if ($pos===$this->pos) return ''; |
|
1712 | + if ($pos===$this->pos) { |
|
1713 | + return ''; |
|
1714 | + } |
|
1621 | 1715 | |
1622 | 1716 | if ($this->doc[$pos-1]==='\\') { |
1623 | 1717 | $start = $pos+1; |
@@ -1674,14 +1768,12 @@ discard block |
||
1674 | 1768 | if (isset($this->noise[$key])) |
1675 | 1769 | { |
1676 | 1770 | $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16); |
1677 | - } |
|
1678 | - else |
|
1771 | + } else |
|
1679 | 1772 | { |
1680 | 1773 | // do this to prevent an infinite loop. |
1681 | 1774 | $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16); |
1682 | 1775 | } |
1683 | - } |
|
1684 | - else |
|
1776 | + } else |
|
1685 | 1777 | { |
1686 | 1778 | // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem. |
1687 | 1779 | $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11); |
@@ -7,9 +7,13 @@ discard block |
||
7 | 7 | //echo $buffer."\n"; |
8 | 8 | $data = array(); |
9 | 9 | $typehex = substr($buffer,0,1); |
10 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
11 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
12 | - else $hex = substr($buffer,1,-1); |
|
10 | + if ($typehex == '*' || $typehex == ':') { |
|
11 | + $hex = substr($buffer,1,-1); |
|
12 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
13 | + $hex = substr($buffer,13,-13); |
|
14 | + } else { |
|
15 | + $hex = substr($buffer,1,-1); |
|
16 | + } |
|
13 | 17 | $bin = gmp_strval( gmp_init($hex,16), 2); |
14 | 18 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
15 | 19 | if (strlen($hex) == 28) { |
@@ -52,8 +56,9 @@ discard block |
||
52 | 56 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
53 | 57 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
54 | 58 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
55 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
56 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
59 | + if ($oe == 0) { |
|
60 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
61 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
57 | 62 | $cprlat_odd = $cprlat; |
58 | 63 | $cprlon_odd = $cprlon; |
59 | 64 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -62,8 +67,12 @@ discard block |
||
62 | 67 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
63 | 68 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
64 | 69 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
65 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
66 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
70 | + if ($lat_even >= 270) { |
|
71 | + $lat_even = $lat_even - 360; |
|
72 | + } |
|
73 | + if ($lat_odd >= 270) { |
|
74 | + $lat_odd = $lat_odd - 360; |
|
75 | + } |
|
67 | 76 | // check latitude zone |
68 | 77 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
69 | 78 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -71,7 +80,9 @@ discard block |
||
71 | 80 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
72 | 81 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
73 | 82 | $lat = $lat_even; |
74 | - if ($lon > 180) $lon = $lon -360; |
|
83 | + if ($lon > 180) { |
|
84 | + $lon = $lon -360; |
|
85 | + } |
|
75 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
76 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
77 | 88 | $data['latitude'] = $lat; |
@@ -82,14 +93,18 @@ discard block |
||
82 | 93 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
83 | 94 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
84 | 95 | $lat = $lat_odd; |
85 | - if ($lon > 180) $lon = $lon -360; |
|
96 | + if ($lon > 180) { |
|
97 | + $lon = $lon -360; |
|
98 | + } |
|
86 | 99 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | 100 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
88 | 101 | $data['latitude'] = $lat; |
89 | 102 | $data['longitude'] = $lon; |
90 | 103 | } |
91 | 104 | } |
92 | - } else echo "Not cprNL"; |
|
105 | + } else { |
|
106 | + echo "Not cprNL"; |
|
107 | + } |
|
93 | 108 | unset($this::$latlon[$icao]); |
94 | 109 | } |
95 | 110 | } elseif ($tc == 19) { |
@@ -98,11 +113,17 @@ discard block |
||
98 | 113 | $v_ew = intval(substr($bin,46,10),2); |
99 | 114 | $v_ns_dir = intval(substr($bin,56,1)); |
100 | 115 | $v_ns = intval(substr($bin,57,10),2); |
101 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
102 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
116 | + if ($v_ew_dir) { |
|
117 | + $v_ew = -1*$v_ew; |
|
118 | + } |
|
119 | + if ($v_ns_dir) { |
|
120 | + $v_ns = -1*$v_ns; |
|
121 | + } |
|
103 | 122 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
104 | 123 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
105 | - if ($heading <0) $heading = $heading+360; |
|
124 | + if ($heading <0) { |
|
125 | + $heading = $heading+360; |
|
126 | + } |
|
106 | 127 | $data['speed'] = $speed; |
107 | 128 | $data['heading'] = $heading; |
108 | 129 | } |
@@ -117,72 +138,194 @@ discard block |
||
117 | 138 | |
118 | 139 | public function cprNL($lat) { |
119 | 140 | //Lookup table to convert the latitude to index. |
120 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
121 | - if ($lat < 10.47047130) return 59; |
|
122 | - if ($lat < 14.82817437) return 58; |
|
123 | - if ($lat < 18.18626357) return 57; |
|
124 | - if ($lat < 21.02939493) return 56; |
|
125 | - if ($lat < 23.54504487) return 55; |
|
126 | - if ($lat < 25.82924707) return 54; |
|
127 | - if ($lat < 27.93898710) return 53; |
|
128 | - if ($lat < 29.91135686) return 52; |
|
129 | - if ($lat < 31.77209708) return 51; |
|
130 | - if ($lat < 33.53993436) return 50; |
|
131 | - if ($lat < 35.22899598) return 49; |
|
132 | - if ($lat < 36.85025108) return 48; |
|
133 | - if ($lat < 38.41241892) return 47; |
|
134 | - if ($lat < 39.92256684) return 46; |
|
135 | - if ($lat < 41.38651832) return 45; |
|
136 | - if ($lat < 42.80914012) return 44; |
|
137 | - if ($lat < 44.19454951) return 43; |
|
138 | - if ($lat < 45.54626723) return 42; |
|
139 | - if ($lat < 46.86733252) return 41; |
|
140 | - if ($lat < 48.16039128) return 40; |
|
141 | - if ($lat < 49.42776439) return 39; |
|
142 | - if ($lat < 50.67150166) return 38; |
|
143 | - if ($lat < 51.89342469) return 37; |
|
144 | - if ($lat < 53.09516153) return 36; |
|
145 | - if ($lat < 54.27817472) return 35; |
|
146 | - if ($lat < 55.44378444) return 34; |
|
147 | - if ($lat < 56.59318756) return 33; |
|
148 | - if ($lat < 57.72747354) return 32; |
|
149 | - if ($lat < 58.84763776) return 31; |
|
150 | - if ($lat < 59.95459277) return 30; |
|
151 | - if ($lat < 61.04917774) return 29; |
|
152 | - if ($lat < 62.13216659) return 28; |
|
153 | - if ($lat < 63.20427479) return 27; |
|
154 | - if ($lat < 64.26616523) return 26; |
|
155 | - if ($lat < 65.31845310) return 25; |
|
156 | - if ($lat < 66.36171008) return 24; |
|
157 | - if ($lat < 67.39646774) return 23; |
|
158 | - if ($lat < 68.42322022) return 22; |
|
159 | - if ($lat < 69.44242631) return 21; |
|
160 | - if ($lat < 70.45451075) return 20; |
|
161 | - if ($lat < 71.45986473) return 19; |
|
162 | - if ($lat < 72.45884545) return 18; |
|
163 | - if ($lat < 73.45177442) return 17; |
|
164 | - if ($lat < 74.43893416) return 16; |
|
165 | - if ($lat < 75.42056257) return 15; |
|
166 | - if ($lat < 76.39684391) return 14; |
|
167 | - if ($lat < 77.36789461) return 13; |
|
168 | - if ($lat < 78.33374083) return 12; |
|
169 | - if ($lat < 79.29428225) return 11; |
|
170 | - if ($lat < 80.24923213) return 10; |
|
171 | - if ($lat < 81.19801349) return 9; |
|
172 | - if ($lat < 82.13956981) return 8; |
|
173 | - if ($lat < 83.07199445) return 7; |
|
174 | - if ($lat < 83.99173563) return 6; |
|
175 | - if ($lat < 84.89166191) return 5; |
|
176 | - if ($lat < 85.75541621) return 4; |
|
177 | - if ($lat < 86.53536998) return 3; |
|
178 | - if ($lat < 87.00000000) return 2; |
|
141 | + if ($lat < 0) { |
|
142 | + $lat = -$lat; |
|
143 | + } |
|
144 | + // Table is simmetric about the equator. |
|
145 | + if ($lat < 10.47047130) { |
|
146 | + return 59; |
|
147 | + } |
|
148 | + if ($lat < 14.82817437) { |
|
149 | + return 58; |
|
150 | + } |
|
151 | + if ($lat < 18.18626357) { |
|
152 | + return 57; |
|
153 | + } |
|
154 | + if ($lat < 21.02939493) { |
|
155 | + return 56; |
|
156 | + } |
|
157 | + if ($lat < 23.54504487) { |
|
158 | + return 55; |
|
159 | + } |
|
160 | + if ($lat < 25.82924707) { |
|
161 | + return 54; |
|
162 | + } |
|
163 | + if ($lat < 27.93898710) { |
|
164 | + return 53; |
|
165 | + } |
|
166 | + if ($lat < 29.91135686) { |
|
167 | + return 52; |
|
168 | + } |
|
169 | + if ($lat < 31.77209708) { |
|
170 | + return 51; |
|
171 | + } |
|
172 | + if ($lat < 33.53993436) { |
|
173 | + return 50; |
|
174 | + } |
|
175 | + if ($lat < 35.22899598) { |
|
176 | + return 49; |
|
177 | + } |
|
178 | + if ($lat < 36.85025108) { |
|
179 | + return 48; |
|
180 | + } |
|
181 | + if ($lat < 38.41241892) { |
|
182 | + return 47; |
|
183 | + } |
|
184 | + if ($lat < 39.92256684) { |
|
185 | + return 46; |
|
186 | + } |
|
187 | + if ($lat < 41.38651832) { |
|
188 | + return 45; |
|
189 | + } |
|
190 | + if ($lat < 42.80914012) { |
|
191 | + return 44; |
|
192 | + } |
|
193 | + if ($lat < 44.19454951) { |
|
194 | + return 43; |
|
195 | + } |
|
196 | + if ($lat < 45.54626723) { |
|
197 | + return 42; |
|
198 | + } |
|
199 | + if ($lat < 46.86733252) { |
|
200 | + return 41; |
|
201 | + } |
|
202 | + if ($lat < 48.16039128) { |
|
203 | + return 40; |
|
204 | + } |
|
205 | + if ($lat < 49.42776439) { |
|
206 | + return 39; |
|
207 | + } |
|
208 | + if ($lat < 50.67150166) { |
|
209 | + return 38; |
|
210 | + } |
|
211 | + if ($lat < 51.89342469) { |
|
212 | + return 37; |
|
213 | + } |
|
214 | + if ($lat < 53.09516153) { |
|
215 | + return 36; |
|
216 | + } |
|
217 | + if ($lat < 54.27817472) { |
|
218 | + return 35; |
|
219 | + } |
|
220 | + if ($lat < 55.44378444) { |
|
221 | + return 34; |
|
222 | + } |
|
223 | + if ($lat < 56.59318756) { |
|
224 | + return 33; |
|
225 | + } |
|
226 | + if ($lat < 57.72747354) { |
|
227 | + return 32; |
|
228 | + } |
|
229 | + if ($lat < 58.84763776) { |
|
230 | + return 31; |
|
231 | + } |
|
232 | + if ($lat < 59.95459277) { |
|
233 | + return 30; |
|
234 | + } |
|
235 | + if ($lat < 61.04917774) { |
|
236 | + return 29; |
|
237 | + } |
|
238 | + if ($lat < 62.13216659) { |
|
239 | + return 28; |
|
240 | + } |
|
241 | + if ($lat < 63.20427479) { |
|
242 | + return 27; |
|
243 | + } |
|
244 | + if ($lat < 64.26616523) { |
|
245 | + return 26; |
|
246 | + } |
|
247 | + if ($lat < 65.31845310) { |
|
248 | + return 25; |
|
249 | + } |
|
250 | + if ($lat < 66.36171008) { |
|
251 | + return 24; |
|
252 | + } |
|
253 | + if ($lat < 67.39646774) { |
|
254 | + return 23; |
|
255 | + } |
|
256 | + if ($lat < 68.42322022) { |
|
257 | + return 22; |
|
258 | + } |
|
259 | + if ($lat < 69.44242631) { |
|
260 | + return 21; |
|
261 | + } |
|
262 | + if ($lat < 70.45451075) { |
|
263 | + return 20; |
|
264 | + } |
|
265 | + if ($lat < 71.45986473) { |
|
266 | + return 19; |
|
267 | + } |
|
268 | + if ($lat < 72.45884545) { |
|
269 | + return 18; |
|
270 | + } |
|
271 | + if ($lat < 73.45177442) { |
|
272 | + return 17; |
|
273 | + } |
|
274 | + if ($lat < 74.43893416) { |
|
275 | + return 16; |
|
276 | + } |
|
277 | + if ($lat < 75.42056257) { |
|
278 | + return 15; |
|
279 | + } |
|
280 | + if ($lat < 76.39684391) { |
|
281 | + return 14; |
|
282 | + } |
|
283 | + if ($lat < 77.36789461) { |
|
284 | + return 13; |
|
285 | + } |
|
286 | + if ($lat < 78.33374083) { |
|
287 | + return 12; |
|
288 | + } |
|
289 | + if ($lat < 79.29428225) { |
|
290 | + return 11; |
|
291 | + } |
|
292 | + if ($lat < 80.24923213) { |
|
293 | + return 10; |
|
294 | + } |
|
295 | + if ($lat < 81.19801349) { |
|
296 | + return 9; |
|
297 | + } |
|
298 | + if ($lat < 82.13956981) { |
|
299 | + return 8; |
|
300 | + } |
|
301 | + if ($lat < 83.07199445) { |
|
302 | + return 7; |
|
303 | + } |
|
304 | + if ($lat < 83.99173563) { |
|
305 | + return 6; |
|
306 | + } |
|
307 | + if ($lat < 84.89166191) { |
|
308 | + return 5; |
|
309 | + } |
|
310 | + if ($lat < 85.75541621) { |
|
311 | + return 4; |
|
312 | + } |
|
313 | + if ($lat < 86.53536998) { |
|
314 | + return 3; |
|
315 | + } |
|
316 | + if ($lat < 87.00000000) { |
|
317 | + return 2; |
|
318 | + } |
|
179 | 319 | return 1; |
180 | 320 | } |
181 | 321 | |
182 | 322 | public function cprN($lat,$isodd) { |
183 | 323 | $nl = $this->cprNL($lat) - $isodd; |
184 | - if ($nl > 1) return $nl; |
|
185 | - else return 1; |
|
324 | + if ($nl > 1) { |
|
325 | + return $nl; |
|
326 | + } else { |
|
327 | + return 1; |
|
328 | + } |
|
186 | 329 | } |
187 | 330 | |
188 | 331 | |
@@ -208,10 +351,13 @@ discard block |
||
208 | 351 | $checksum = intval(substr($msg,22,6),16); |
209 | 352 | |
210 | 353 | for ($j = 0; $j < strlen($bin); $j++) { |
211 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
354 | + if ($bin[$j]) { |
|
355 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
356 | + } |
|
212 | 357 | } |
213 | - if ($crc == $checksum) return true; |
|
214 | - else { |
|
358 | + if ($crc == $checksum) { |
|
359 | + return true; |
|
360 | + } else { |
|
215 | 361 | //echo "**** CRC ERROR ****\n"; |
216 | 362 | return false; |
217 | 363 | } |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) { |
|
30 | + $filter = array_merge($filter,$globalFilter); |
|
31 | + } |
|
30 | 32 | $filter_query_join = ''; |
31 | 33 | $filter_query_where = ''; |
32 | 34 | foreach($filters as $flt) { |
@@ -79,8 +81,11 @@ discard block |
||
79 | 81 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
80 | 82 | } |
81 | 83 | } |
82 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
83 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
84 | 89 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 90 | return $filter_query; |
86 | 91 | } |
@@ -119,7 +124,9 @@ discard block |
||
119 | 124 | } |
120 | 125 | } |
121 | 126 | |
122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
127 | + if (!isset($globalLiveInterval)) { |
|
128 | + $globalLiveInterval = '200'; |
|
129 | + } |
|
123 | 130 | if ($globalDBdriver == 'mysql') { |
124 | 131 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
125 | 132 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -144,7 +151,9 @@ discard block |
||
144 | 151 | |
145 | 152 | $filter_query = $this->getFilter($filter,true,true); |
146 | 153 | |
147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
154 | + if (!isset($globalLiveInterval)) { |
|
155 | + $globalLiveInterval = '200'; |
|
156 | + } |
|
148 | 157 | if ($globalDBdriver == 'mysql') { |
149 | 158 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
150 | 159 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -201,7 +210,9 @@ discard block |
||
201 | 210 | |
202 | 211 | $filter_query = $this->getFilter($filter,true,true); |
203 | 212 | |
204 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
213 | + if (!isset($globalLiveInterval)) { |
|
214 | + $globalLiveInterval = '200'; |
|
215 | + } |
|
205 | 216 | if ($globalDBdriver == 'mysql') { |
206 | 217 | /* |
207 | 218 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -245,7 +256,9 @@ discard block |
||
245 | 256 | global $globalDBdriver, $globalLiveInterval; |
246 | 257 | $filter_query = $this->getFilter($filter,true,true); |
247 | 258 | |
248 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
259 | + if (!isset($globalLiveInterval)) { |
|
260 | + $globalLiveInterval = '200'; |
|
261 | + } |
|
249 | 262 | if ($globalDBdriver == 'mysql') { |
250 | 263 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
251 | 264 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -275,7 +288,9 @@ discard block |
||
275 | 288 | { |
276 | 289 | global $globalDBdriver, $globalLiveInterval; |
277 | 290 | $Spotter = new Spotter($this->db); |
278 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
291 | + if (!isset($globalLiveInterval)) { |
|
292 | + $globalLiveInterval = '200'; |
|
293 | + } |
|
279 | 294 | $filter_query = $this->getFilter($filter); |
280 | 295 | |
281 | 296 | if (is_array($coord)) { |
@@ -283,7 +298,9 @@ discard block |
||
283 | 298 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
284 | 299 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
285 | 300 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
286 | - } else return array(); |
|
301 | + } else { |
|
302 | + return array(); |
|
303 | + } |
|
287 | 304 | if ($globalDBdriver == 'mysql') { |
288 | 305 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
289 | 306 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -474,11 +491,15 @@ discard block |
||
474 | 491 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
475 | 492 | if ($globalDBdriver == 'mysql') { |
476 | 493 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
477 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
494 | + if ($liveinterval) { |
|
495 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
496 | + } |
|
478 | 497 | $query .= ' ORDER BY date'; |
479 | 498 | } else { |
480 | 499 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
481 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
500 | + if ($liveinterval) { |
|
501 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
502 | + } |
|
482 | 503 | $query .= ' ORDER BY date'; |
483 | 504 | } |
484 | 505 | |
@@ -573,7 +594,9 @@ discard block |
||
573 | 594 | $i++; |
574 | 595 | $j++; |
575 | 596 | if ($j == 30) { |
576 | - if ($globalDebug) echo "."; |
|
597 | + if ($globalDebug) { |
|
598 | + echo "."; |
|
599 | + } |
|
577 | 600 | try { |
578 | 601 | |
579 | 602 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -880,7 +903,9 @@ discard block |
||
880 | 903 | { |
881 | 904 | return false; |
882 | 905 | } |
883 | - } else return ''; |
|
906 | + } else { |
|
907 | + return ''; |
|
908 | + } |
|
884 | 909 | |
885 | 910 | if ($longitude != '') |
886 | 911 | { |
@@ -888,7 +913,9 @@ discard block |
||
888 | 913 | { |
889 | 914 | return false; |
890 | 915 | } |
891 | - } else return ''; |
|
916 | + } else { |
|
917 | + return ''; |
|
918 | + } |
|
892 | 919 | |
893 | 920 | if ($waypoints != '') |
894 | 921 | { |
@@ -904,7 +931,9 @@ discard block |
||
904 | 931 | { |
905 | 932 | return false; |
906 | 933 | } |
907 | - } else $altitude = 0; |
|
934 | + } else { |
|
935 | + $altitude = 0; |
|
936 | + } |
|
908 | 937 | |
909 | 938 | if ($heading != '') |
910 | 939 | { |
@@ -912,7 +941,9 @@ discard block |
||
912 | 941 | { |
913 | 942 | return false; |
914 | 943 | } |
915 | - } else $heading = 0; |
|
944 | + } else { |
|
945 | + $heading = 0; |
|
946 | + } |
|
916 | 947 | |
917 | 948 | if ($groundspeed != '') |
918 | 949 | { |
@@ -920,9 +951,13 @@ discard block |
||
920 | 951 | { |
921 | 952 | return false; |
922 | 953 | } |
923 | - } else $groundspeed = 0; |
|
954 | + } else { |
|
955 | + $groundspeed = 0; |
|
956 | + } |
|
924 | 957 | date_default_timezone_set('UTC'); |
925 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
958 | + if ($date == '') { |
|
959 | + $date = date("Y-m-d H:i:s", time()); |
|
960 | + } |
|
926 | 961 | |
927 | 962 | |
928 | 963 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -966,10 +1001,18 @@ discard block |
||
966 | 1001 | $arrival_airport_country = ''; |
967 | 1002 | |
968 | 1003 | |
969 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
970 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
971 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
972 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1004 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1005 | + $squawk = NULL; |
|
1006 | + } |
|
1007 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1008 | + $verticalrate = NULL; |
|
1009 | + } |
|
1010 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1011 | + $groundspeed = 0; |
|
1012 | + } |
|
1013 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1014 | + $heading = 0; |
|
1015 | + } |
|
973 | 1016 | |
974 | 1017 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
975 | 1018 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -983,10 +1026,14 @@ discard block |
||
983 | 1026 | return "error : ".$e->getMessage(); |
984 | 1027 | } |
985 | 1028 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
986 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1029 | + if ($globalDebug) { |
|
1030 | + echo '(Add to SBS archive : '; |
|
1031 | + } |
|
987 | 1032 | $SpotterArchive = new SpotterArchive($this->db); |
988 | 1033 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
989 | - if ($globalDebug) echo $result.')'; |
|
1034 | + if ($globalDebug) { |
|
1035 | + echo $result.')'; |
|
1036 | + } |
|
990 | 1037 | } |
991 | 1038 | return "success"; |
992 | 1039 |
@@ -64,8 +64,11 @@ discard block |
||
64 | 64 | $globalDBSname = $globalDBname; |
65 | 65 | $globalDBSuser = $globalDBuser; |
66 | 66 | $globalDBSpass = $globalDBpass; |
67 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
68 | - else $globalDBSport = $globalDBport; |
|
67 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
68 | + $globalDBSport = 3306; |
|
69 | + } else { |
|
70 | + $globalDBSport = $globalDBport; |
|
71 | + } |
|
69 | 72 | } else { |
70 | 73 | $DBname = 'default'; |
71 | 74 | $globalDBSdriver = $globalDBdriver; |
@@ -73,8 +76,11 @@ discard block |
||
73 | 76 | $globalDBSname = $globalDBname; |
74 | 77 | $globalDBSuser = $user; |
75 | 78 | $globalDBSpass = $pass; |
76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
77 | - else $globalDBSport = $globalDBport; |
|
79 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
80 | + $globalDBSport = 3306; |
|
81 | + } else { |
|
82 | + $globalDBSport = $globalDBport; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } else { |
80 | 86 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -82,11 +88,16 @@ discard block |
||
82 | 88 | $globalDBSname = $globalDB[$DBname]['name']; |
83 | 89 | $globalDBSuser = $globalDB[$DBname]['user']; |
84 | 90 | $globalDBSpass = $globalDB[$DBname]['pass']; |
85 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
86 | - else $globalDBSport = 3306; |
|
91 | + if (isset($globalDB[$DBname]['port'])) { |
|
92 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
93 | + } else { |
|
94 | + $globalDBSport = 3306; |
|
95 | + } |
|
87 | 96 | } |
88 | 97 | // Set number of try to connect to DB |
89 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
98 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
99 | + $globalDBretry = 5; |
|
100 | + } |
|
90 | 101 | $i = 0; |
91 | 102 | while (true) { |
92 | 103 | try { |
@@ -95,10 +106,16 @@ discard block |
||
95 | 106 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
96 | 107 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
97 | 108 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
98 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
99 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
100 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
101 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
109 | + if (!isset($globalDBTimeOut)) { |
|
110 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
111 | + } else { |
|
112 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
113 | + } |
|
114 | + if (!isset($globalDBPersistent)) { |
|
115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
116 | + } else { |
|
117 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
118 | + } |
|
102 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
103 | 120 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
104 | 121 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -112,23 +129,35 @@ discard block |
||
112 | 129 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
113 | 130 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
114 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
115 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
116 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
117 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
118 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
132 | + if (!isset($globalDBTimeOut)) { |
|
133 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
134 | + } else { |
|
135 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
136 | + } |
|
137 | + if (!isset($globalDBPersistent)) { |
|
138 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
139 | + } else { |
|
140 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
141 | + } |
|
119 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
120 | 143 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
121 | 144 | } |
122 | 145 | break; |
123 | 146 | } catch(PDOException $e) { |
124 | 147 | $i++; |
125 | - if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n"; |
|
148 | + if (isset($globalDebug) && $globalDebug) { |
|
149 | + echo $e->getMessage()."\n"; |
|
150 | + } |
|
126 | 151 | //exit; |
127 | - if ($i > $globalDBretry) return false; |
|
152 | + if ($i > $globalDBretry) { |
|
153 | + return false; |
|
154 | + } |
|
128 | 155 | //return false; |
129 | 156 | } |
130 | 157 | } |
131 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
158 | + if ($DBname === 'default') { |
|
159 | + $this->db = $this->dbs['default']; |
|
160 | + } |
|
132 | 161 | return true; |
133 | 162 | } |
134 | 163 | |
@@ -140,7 +169,9 @@ discard block |
||
140 | 169 | } else { |
141 | 170 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
142 | 171 | } |
143 | - if ($this->db == NULL) return false; |
|
172 | + if ($this->db == NULL) { |
|
173 | + return false; |
|
174 | + } |
|
144 | 175 | try { |
145 | 176 | //$Connection = new Connection(); |
146 | 177 | $results = $this->db->query($query); |
@@ -149,21 +180,28 @@ discard block |
||
149 | 180 | } |
150 | 181 | if($results->rowCount()>0) { |
151 | 182 | return true; |
183 | + } else { |
|
184 | + return false; |
|
152 | 185 | } |
153 | - else return false; |
|
154 | 186 | } |
155 | 187 | |
156 | 188 | public function connectionExists() |
157 | 189 | { |
158 | 190 | global $globalDBdriver, $globalDBCheckConnection; |
159 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
191 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
192 | + return true; |
|
193 | + } |
|
160 | 194 | $query = "SELECT 1 + 1"; |
161 | - if ($this->db === null) return false; |
|
195 | + if ($this->db === null) { |
|
196 | + return false; |
|
197 | + } |
|
162 | 198 | try { |
163 | 199 | $sum = @$this->db->query($query); |
164 | 200 | if ($sum instanceof \PDOStatement) { |
165 | 201 | $sum = $sum->fetchColumn(0); |
166 | - } else $sum = 0; |
|
202 | + } else { |
|
203 | + $sum = 0; |
|
204 | + } |
|
167 | 205 | if (intval($sum) !== 2) { |
168 | 206 | return false; |
169 | 207 | } |
@@ -198,8 +236,9 @@ discard block |
||
198 | 236 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
199 | 237 | if($nb[0]['nb'] > 0) { |
200 | 238 | return true; |
239 | + } else { |
|
240 | + return false; |
|
201 | 241 | } |
202 | - else return false; |
|
203 | 242 | } |
204 | 243 | |
205 | 244 | /* |
@@ -243,9 +282,12 @@ discard block |
||
243 | 282 | } |
244 | 283 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
245 | 284 | $sth->closeCursor(); |
246 | - if ($result['nb'] > 0) return true; |
|
247 | - else return false; |
|
248 | -/* } else { |
|
285 | + if ($result['nb'] > 0) { |
|
286 | + return true; |
|
287 | + } else { |
|
288 | + return false; |
|
289 | + } |
|
290 | + /* } else { |
|
249 | 291 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
250 | 292 | try { |
251 | 293 | $results = $this->db->query($query); |
@@ -284,7 +326,9 @@ discard block |
||
284 | 326 | $sth->closeCursor(); |
285 | 327 | return $result['value']; |
286 | 328 | } |
287 | - } else return $version; |
|
329 | + } else { |
|
330 | + return $version; |
|
331 | + } |
|
288 | 332 | } |
289 | 333 | |
290 | 334 | /* |
@@ -292,8 +336,11 @@ discard block |
||
292 | 336 | * @return Boolean if latest version or not |
293 | 337 | */ |
294 | 338 | public function latest() { |
295 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
296 | - else return false; |
|
339 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
340 | + return true; |
|
341 | + } else { |
|
342 | + return false; |
|
343 | + } |
|
297 | 344 | } |
298 | 345 | |
299 | 346 | } |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | if ($Schedule->checkSchedule($operator) == 0) { |
65 | 67 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 68 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
71 | + } |
|
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
69 | 73 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
70 | 74 | // Should also check if route schedule = route from DB |
@@ -73,7 +77,9 @@ discard block |
||
73 | 77 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
74 | 78 | if (trim($airport_icao) != '') { |
75 | 79 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
80 | + if ($globalDebug) { |
|
81 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
82 | + } |
|
77 | 83 | } |
78 | 84 | } |
79 | 85 | } |
@@ -82,17 +88,25 @@ discard block |
||
82 | 88 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
83 | 89 | if (trim($airport_icao) != '') { |
84 | 90 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
91 | + if ($globalDebug) { |
|
92 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | } |
88 | 96 | } |
89 | 97 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
90 | 98 | } |
91 | - } else $scheduleexist = true; |
|
92 | - } else $scheduleexist = true; |
|
99 | + } else { |
|
100 | + $scheduleexist = true; |
|
101 | + } |
|
102 | + } else { |
|
103 | + $scheduleexist = true; |
|
104 | + } |
|
93 | 105 | // close connection, at least one way will work ? |
94 | 106 | if ($scheduleexist) { |
95 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
109 | + } |
|
96 | 110 | $sch = $Schedule->getSchedule($operator); |
97 | 111 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
98 | 112 | } |
@@ -114,7 +128,9 @@ discard block |
||
114 | 128 | |
115 | 129 | public function checkAll() { |
116 | 130 | global $globalDebug; |
117 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo "Update last seen flights data...\n"; |
|
133 | + } |
|
118 | 134 | foreach ($this->all_flights as $key => $flight) { |
119 | 135 | if (isset($this->all_flights[$key]['id'])) { |
120 | 136 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -127,24 +143,32 @@ discard block |
||
127 | 143 | |
128 | 144 | public function arrival($key) { |
129 | 145 | global $globalClosestMinDist, $globalDebug; |
130 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
146 | + if ($globalDebug) { |
|
147 | + echo 'Update arrival...'."\n"; |
|
148 | + } |
|
131 | 149 | $Spotter = new Spotter($this->db); |
132 | 150 | $airport_icao = ''; |
133 | 151 | $airport_time = ''; |
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
153 | + $globalClosestMinDist = 50; |
|
154 | + } |
|
135 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | 156 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
137 | 157 | if (isset($closestAirports[0])) { |
138 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 159 | $airport_icao = $closestAirports[0]['icao']; |
140 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } |
|
142 | 164 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
143 | 165 | foreach ($closestAirports as $airport) { |
144 | 166 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
145 | 167 | $airport_icao = $airport['icao']; |
146 | 168 | $airport_time = $this->all_flights[$key]['datetime']; |
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
171 | + } |
|
148 | 172 | break; |
149 | 173 | } |
150 | 174 | } |
@@ -152,14 +176,20 @@ discard block |
||
152 | 176 | $airport_icao = $closestAirports[0]['icao']; |
153 | 177 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 178 | } else { |
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
181 | + } |
|
156 | 182 | } |
157 | 183 | } else { |
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
186 | + } |
|
159 | 187 | } |
160 | 188 | |
161 | 189 | } else { |
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
190 | + if ($globalDebug) { |
|
191 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
192 | + } |
|
163 | 193 | } |
164 | 194 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
165 | 195 | } |
@@ -169,12 +199,16 @@ discard block |
||
169 | 199 | public function del() { |
170 | 200 | global $globalDebug; |
171 | 201 | // Delete old infos |
172 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Delete old values and update latest data...'."\n"; |
|
204 | + } |
|
173 | 205 | foreach ($this->all_flights as $key => $flight) { |
174 | 206 | if (isset($flight['lastupdate'])) { |
175 | 207 | if ($flight['lastupdate'] < (time()-3000)) { |
176 | 208 | if (isset($this->all_flights[$key]['id'])) { |
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
211 | + } |
|
178 | 212 | /* |
179 | 213 | $SpotterLive = new SpotterLive(); |
180 | 214 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -184,7 +218,9 @@ discard block |
||
184 | 218 | $Spotter = new Spotter($this->db); |
185 | 219 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | 220 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
221 | + if ($globalDebug && $result != 'success') { |
|
222 | + echo '!!! ERROR : '.$result."\n"; |
|
223 | + } |
|
188 | 224 | } |
189 | 225 | // Put in archive |
190 | 226 | // $Spotter->db = null; |
@@ -198,8 +234,10 @@ discard block |
||
198 | 234 | public function add($line) { |
199 | 235 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 236 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
202 | -/* |
|
237 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
238 | + $globalCoordMinChange = '0.02'; |
|
239 | + } |
|
240 | + /* |
|
203 | 241 | $Spotter = new Spotter(); |
204 | 242 | $dbc = $Spotter->db; |
205 | 243 | $SpotterLive = new SpotterLive($dbc); |
@@ -227,11 +265,15 @@ discard block |
||
227 | 265 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | 266 | $current_date = date('Y-m-d'); |
229 | 267 | $source = $line['source_name']; |
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
268 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
269 | + $source = $line['format_source']; |
|
270 | + } |
|
231 | 271 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
232 | 272 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
233 | 273 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
274 | + } else { |
|
275 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
276 | + } |
|
235 | 277 | } |
236 | 278 | |
237 | 279 | /* |
@@ -247,8 +289,11 @@ discard block |
||
247 | 289 | //$this->db = $dbc; |
248 | 290 | |
249 | 291 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
292 | + if (!isset($line['id'])) { |
|
293 | + $id = trim($line['hex']); |
|
294 | + } else { |
|
295 | + $id = trim($line['id']); |
|
296 | + } |
|
252 | 297 | |
253 | 298 | //print_r($this->all_flights); |
254 | 299 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -263,13 +308,20 @@ discard block |
||
263 | 308 | $Spotter = new Spotter($this->db); |
264 | 309 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 310 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
311 | + if ($globalDebugTimeElapsed) { |
|
312 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + } |
|
267 | 314 | |
268 | 315 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
316 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
317 | + $aircraft_icao = 'GLID'; |
|
318 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
319 | + $aircraft_icao = 'UHEL'; |
|
320 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
321 | + $aircraft_icao = 'TOWPLANE'; |
|
322 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
323 | + $aircraft_icao = 'POWAIRC'; |
|
324 | + } |
|
273 | 325 | } |
274 | 326 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | 327 | } else if (isset($line['aircraft_name'])) { |
@@ -277,29 +329,47 @@ discard block |
||
277 | 329 | $Spotter = new Spotter($this->db); |
278 | 330 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 331 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
332 | + if ($aircraft_icao != '') { |
|
333 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
334 | + } else { |
|
335 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
339 | + } |
|
283 | 340 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
284 | 341 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
285 | 342 | if (!isset($line['id'])) { |
286 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
287 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
343 | + if (!isset($globalDaemon)) { |
|
344 | + $globalDaemon = TRUE; |
|
345 | + } |
|
346 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
288 | 347 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
289 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
348 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
349 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
350 | + } |
|
290 | 351 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
352 | + } else { |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
354 | + } |
|
292 | 355 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
356 | + if ($globalDebug) { |
|
357 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
358 | + } |
|
359 | + if ($globalAllFlights !== FALSE) { |
|
360 | + $dataFound = true; |
|
361 | + } |
|
295 | 362 | } |
296 | 363 | |
297 | 364 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
298 | 365 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
299 | 366 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
300 | 367 | } else { |
301 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
302 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
368 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
369 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
370 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
371 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
372 | + } |
|
303 | 373 | /* |
304 | 374 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
305 | 375 | print_r($this->all_flights[$id]); |
@@ -307,7 +377,9 @@ discard block |
||
307 | 377 | */ |
308 | 378 | return ''; |
309 | 379 | } |
310 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
380 | + } else { |
|
381 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
382 | + } |
|
311 | 383 | |
312 | 384 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
313 | 385 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -328,15 +400,25 @@ discard block |
||
328 | 400 | $timeelapsed = microtime(true); |
329 | 401 | $Spotter = new Spotter($this->db); |
330 | 402 | $fromsource = NULL; |
331 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
332 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
333 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
334 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
335 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
403 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
404 | + $fromsource = $globalAirlinesSource; |
|
405 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
406 | + $fromsource = 'vatsim'; |
|
407 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
408 | + $fromsource = 'ivao'; |
|
409 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
410 | + $fromsource = 'vatsim'; |
|
411 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
412 | + $fromsource = 'ivao'; |
|
413 | + } |
|
336 | 414 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
337 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
415 | + if ($globalDebug && $result != 'success') { |
|
416 | + echo '!!! ERROR : '.$result."\n"; |
|
417 | + } |
|
338 | 418 | $Spotter->db = null; |
339 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) { |
|
420 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + } |
|
340 | 422 | } |
341 | 423 | |
342 | 424 | /* |
@@ -347,7 +429,9 @@ discard block |
||
347 | 429 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
348 | 430 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
349 | 431 | */ |
350 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
432 | + if (!isset($this->all_flights[$id]['id'])) { |
|
433 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
434 | + } |
|
351 | 435 | |
352 | 436 | //$putinarchive = true; |
353 | 437 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -364,7 +448,9 @@ discard block |
||
364 | 448 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
365 | 449 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
366 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
367 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
451 | + if ($globalDebugTimeElapsed) { |
|
452 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
453 | + } |
|
368 | 454 | |
369 | 455 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
370 | 456 | $timeelapsed = microtime(true); |
@@ -377,7 +463,9 @@ discard block |
||
377 | 463 | $Translation->db = null; |
378 | 464 | } |
379 | 465 | $Spotter->db = null; |
380 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
466 | + if ($globalDebugTimeElapsed) { |
|
467 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
468 | + } |
|
381 | 469 | |
382 | 470 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
383 | 471 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -386,9 +474,13 @@ discard block |
||
386 | 474 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
387 | 475 | } |
388 | 476 | } |
389 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
477 | + if (!isset($globalFork)) { |
|
478 | + $globalFork = TRUE; |
|
479 | + } |
|
390 | 480 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
391 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
481 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
482 | + $this->get_Schedule($id,trim($line['ident'])); |
|
483 | + } |
|
392 | 484 | } |
393 | 485 | } |
394 | 486 | } |
@@ -404,16 +496,23 @@ discard block |
||
404 | 496 | // use datetime |
405 | 497 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
406 | 498 | $speed = $speed*3.6; |
407 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
408 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
499 | + if ($speed < 1000) { |
|
500 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
501 | + } |
|
502 | + if ($globalDebug) { |
|
503 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
504 | + } |
|
409 | 505 | } |
410 | 506 | } |
411 | 507 | |
412 | 508 | |
413 | 509 | |
414 | 510 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
415 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
416 | - else unset($timediff); |
|
511 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
512 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
513 | + } else { |
|
514 | + unset($timediff); |
|
515 | + } |
|
417 | 516 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
418 | 517 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
419 | 518 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -421,21 +520,31 @@ discard block |
||
421 | 520 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
422 | 521 | $this->all_flights[$id]['putinarchive'] = true; |
423 | 522 | |
424 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
523 | + if ($globalDebug) { |
|
524 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
525 | + } |
|
425 | 526 | $timeelapsed = microtime(true); |
426 | 527 | $Spotter = new Spotter($this->db); |
427 | 528 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
428 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
529 | + if (!empty($all_country)) { |
|
530 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
531 | + } |
|
429 | 532 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
533 | + if ($globalDebugTimeElapsed) { |
|
534 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + } |
|
431 | 536 | $this->tmd = 0; |
432 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
537 | + if ($globalDebug) { |
|
538 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
539 | + } |
|
433 | 540 | } |
434 | 541 | } |
435 | 542 | |
436 | 543 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
437 | 544 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
438 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
545 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
546 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
547 | + } |
|
439 | 548 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
440 | 549 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
441 | 550 | $dataFound = true; |
@@ -457,9 +566,13 @@ discard block |
||
457 | 566 | */ |
458 | 567 | } |
459 | 568 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
460 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
569 | + if ($line['longitude'] > 180) { |
|
570 | + $line['longitude'] = $line['longitude'] - 360; |
|
571 | + } |
|
461 | 572 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
462 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
573 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
574 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
575 | + } |
|
463 | 576 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
464 | 577 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
465 | 578 | $dataFound = true; |
@@ -490,7 +603,9 @@ discard block |
||
490 | 603 | } |
491 | 604 | } |
492 | 605 | if (isset($line['last_update']) && $line['last_update'] != '') { |
493 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
606 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
607 | + $dataFound = true; |
|
608 | + } |
|
494 | 609 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
495 | 610 | } |
496 | 611 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -512,11 +627,17 @@ discard block |
||
512 | 627 | // Here we force archive of flight because after ground it's a new one (or should be) |
513 | 628 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
514 | 629 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
515 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
516 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
517 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
630 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
631 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
632 | + } elseif (isset($line['id'])) { |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
634 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
636 | + } |
|
637 | + } |
|
638 | + if ($line['ground'] != 1) { |
|
639 | + $line['ground'] = 0; |
|
518 | 640 | } |
519 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
520 | 641 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
521 | 642 | //$dataFound = true; |
522 | 643 | } |
@@ -524,28 +645,40 @@ discard block |
||
524 | 645 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
525 | 646 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
526 | 647 | $highlight = ''; |
527 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
528 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
529 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
648 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
649 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
650 | + } |
|
651 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
652 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
653 | + } |
|
654 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
655 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
656 | + } |
|
530 | 657 | if ($highlight != '') { |
531 | 658 | $timeelapsed = microtime(true); |
532 | 659 | $Spotter = new Spotter($this->db); |
533 | 660 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
534 | 661 | $Spotter->db = null; |
535 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
662 | + if ($globalDebugTimeElapsed) { |
|
663 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
664 | + } |
|
536 | 665 | |
537 | 666 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 667 | //$putinarchive = true; |
539 | 668 | //$highlight = ''; |
540 | 669 | } |
541 | 670 | |
542 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
671 | + } else { |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
673 | + } |
|
543 | 674 | //$dataFound = true; |
544 | 675 | } |
545 | 676 | |
546 | 677 | if (isset($line['altitude']) && $line['altitude'] != '') { |
547 | 678 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
548 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
679 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
680 | + $this->all_flights[$id]['putinarchive'] = true; |
|
681 | + } |
|
549 | 682 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
550 | 683 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
551 | 684 | //$dataFound = true; |
@@ -557,21 +690,30 @@ discard block |
||
557 | 690 | } |
558 | 691 | |
559 | 692 | if (isset($line['heading']) && $line['heading'] != '') { |
560 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
693 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
694 | + $this->all_flights[$id]['putinarchive'] = true; |
|
695 | + } |
|
561 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
562 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
563 | 698 | //$dataFound = true; |
564 | 699 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
565 | 700 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
566 | 701 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
567 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
702 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
703 | + $this->all_flights[$id]['putinarchive'] = true; |
|
704 | + } |
|
705 | + if ($globalDebug) { |
|
706 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
707 | + } |
|
569 | 708 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
570 | 709 | // If not enough messages and ACARS set heading to 0 |
571 | 710 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
572 | 711 | } |
573 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
574 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
712 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
713 | + $dataFound = false; |
|
714 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
715 | + $dataFound = false; |
|
716 | + } |
|
575 | 717 | |
576 | 718 | // print_r($this->all_flights[$id]); |
577 | 719 | //gets the callsign from the last hour |
@@ -586,23 +728,36 @@ discard block |
||
586 | 728 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
587 | 729 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
588 | 730 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
589 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
731 | + if ($globalDebug) { |
|
732 | + echo "Check if aircraft is already in DB..."; |
|
733 | + } |
|
590 | 734 | $timeelapsed = microtime(true); |
591 | 735 | $SpotterLive = new SpotterLive($this->db); |
592 | 736 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
593 | 737 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
738 | + if ($globalDebugTimeElapsed) { |
|
739 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
740 | + } |
|
595 | 741 | } elseif (isset($line['id'])) { |
596 | 742 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
597 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
743 | + if ($globalDebugTimeElapsed) { |
|
744 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
745 | + } |
|
598 | 746 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
599 | 747 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
600 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
601 | - } else $recent_ident = ''; |
|
748 | + if ($globalDebugTimeElapsed) { |
|
749 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
750 | + } |
|
751 | + } else { |
|
752 | + $recent_ident = ''; |
|
753 | + } |
|
602 | 754 | $SpotterLive->db=null; |
603 | 755 | |
604 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
605 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
756 | + if ($globalDebug && $recent_ident == '') { |
|
757 | + echo " Not in DB.\n"; |
|
758 | + } elseif ($globalDebug && $recent_ident != '') { |
|
759 | + echo " Already in DB.\n"; |
|
760 | + } |
|
606 | 761 | } else { |
607 | 762 | $recent_ident = ''; |
608 | 763 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -610,7 +765,9 @@ discard block |
||
610 | 765 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
611 | 766 | if($recent_ident == "") |
612 | 767 | { |
613 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
768 | + if ($globalDebug) { |
|
769 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
770 | + } |
|
614 | 771 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
615 | 772 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
616 | 773 | //adds the spotter data for the archive |
@@ -654,26 +811,44 @@ discard block |
||
654 | 811 | |
655 | 812 | if (!$ignoreImport) { |
656 | 813 | $highlight = ''; |
657 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
658 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
659 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
660 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
814 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
815 | + $highlight = 'Squawk 7500 : Hijack'; |
|
816 | + } |
|
817 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
818 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
819 | + } |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
821 | + $highlight = 'Squawk 7700 : Emergency'; |
|
822 | + } |
|
823 | + if (!isset($this->all_flights[$id]['id'])) { |
|
824 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
825 | + } |
|
661 | 826 | $timeelapsed = microtime(true); |
662 | 827 | $Spotter = new Spotter($this->db); |
663 | 828 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
664 | 829 | $Spotter->db = null; |
665 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
666 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
830 | + if ($globalDebug && isset($result)) { |
|
831 | + echo $result."\n"; |
|
832 | + } |
|
833 | + if ($globalDebugTimeElapsed) { |
|
834 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | + } |
|
667 | 836 | |
668 | 837 | // Add source stat in DB |
669 | 838 | $Stats = new Stats($this->db); |
670 | 839 | if (!empty($this->stats)) { |
671 | - if ($globalDebug) echo 'Add source stats : '; |
|
840 | + if ($globalDebug) { |
|
841 | + echo 'Add source stats : '; |
|
842 | + } |
|
672 | 843 | foreach($this->stats as $date => $data) { |
673 | 844 | foreach($data as $source => $sourced) { |
674 | 845 | //print_r($sourced); |
675 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
676 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | + if (isset($sourced['polar'])) { |
|
847 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
848 | + } |
|
849 | + if (isset($sourced['hist'])) { |
|
850 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
851 | + } |
|
677 | 852 | if (isset($sourced['msg'])) { |
678 | 853 | if (time() - $sourced['msg']['date'] > 10) { |
679 | 854 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -686,13 +861,17 @@ discard block |
||
686 | 861 | unset($this->stats[$date]); |
687 | 862 | } |
688 | 863 | } |
689 | - if ($globalDebug) echo 'Done'."\n"; |
|
864 | + if ($globalDebug) { |
|
865 | + echo 'Done'."\n"; |
|
866 | + } |
|
690 | 867 | |
691 | 868 | } |
692 | 869 | $Stats->db = null; |
693 | 870 | |
694 | 871 | $this->del(); |
695 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
872 | + } elseif ($globalDebug) { |
|
873 | + echo 'Ignore data'."\n"; |
|
874 | + } |
|
696 | 875 | //$ignoreImport = false; |
697 | 876 | $this->all_flights[$id]['addedSpotter'] = 1; |
698 | 877 | //print_r($this->all_flights[$id]); |
@@ -709,12 +888,16 @@ discard block |
||
709 | 888 | */ |
710 | 889 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
711 | 890 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
712 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
891 | + if ($globalDebug) { |
|
892 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
893 | + } |
|
713 | 894 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
714 | 895 | $SpotterLive = new SpotterLive($this->db); |
715 | 896 | $SpotterLive->deleteLiveSpotterData(); |
716 | 897 | $SpotterLive->db=null; |
717 | - if ($globalDebug) echo " Done\n"; |
|
898 | + if ($globalDebug) { |
|
899 | + echo " Done\n"; |
|
900 | + } |
|
718 | 901 | $this->last_delete = time(); |
719 | 902 | } |
720 | 903 | } else { |
@@ -737,11 +920,17 @@ discard block |
||
737 | 920 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
738 | 921 | if ($globalDebug) { |
739 | 922 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
740 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
741 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
923 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
924 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
925 | + } else { |
|
926 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
927 | + } |
|
742 | 928 | } else { |
743 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
744 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
929 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
930 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
931 | + } else { |
|
932 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
933 | + } |
|
745 | 934 | } |
746 | 935 | } |
747 | 936 | $ignoreImport = false; |
@@ -787,19 +976,25 @@ discard block |
||
787 | 976 | |
788 | 977 | if (!$ignoreImport) { |
789 | 978 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
790 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
979 | + if ($globalDebug) { |
|
980 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
981 | + } |
|
791 | 982 | $timeelapsed = microtime(true); |
792 | 983 | $SpotterLive = new SpotterLive($this->db); |
793 | 984 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
794 | 985 | $SpotterLive->db = null; |
795 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
986 | + if ($globalDebugTimeElapsed) { |
|
987 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
988 | + } |
|
796 | 989 | |
797 | 990 | // Put statistics in $this->stats variable |
798 | 991 | //if ($line['format_source'] != 'aprs') { |
799 | 992 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
800 | 993 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
801 | 994 | $source = $this->all_flights[$id]['source_name']; |
802 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
995 | + if ($source == '') { |
|
996 | + $source = $this->all_flights[$id]['format_source']; |
|
997 | + } |
|
803 | 998 | if (!isset($this->source_location[$source])) { |
804 | 999 | $Location = new Source(); |
805 | 1000 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -820,7 +1015,9 @@ discard block |
||
820 | 1015 | $stats_heading = round($stats_heading/22.5); |
821 | 1016 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
822 | 1017 | $current_date = date('Y-m-d'); |
823 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1018 | + if ($stats_heading == 16) { |
|
1019 | + $stats_heading = 0; |
|
1020 | + } |
|
824 | 1021 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
825 | 1022 | for ($i=0;$i<=15;$i++) { |
826 | 1023 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -838,7 +1035,9 @@ discard block |
||
838 | 1035 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
839 | 1036 | end($this->stats[$current_date][$source]['hist']); |
840 | 1037 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
841 | - } else $mini = 0; |
|
1038 | + } else { |
|
1039 | + $mini = 0; |
|
1040 | + } |
|
842 | 1041 | for ($i=$mini;$i<=$distance;$i+=10) { |
843 | 1042 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
844 | 1043 | } |
@@ -849,20 +1048,30 @@ discard block |
||
849 | 1048 | } |
850 | 1049 | |
851 | 1050 | $this->all_flights[$id]['lastupdate'] = time(); |
852 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1051 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1052 | + $send = true; |
|
1053 | + } |
|
853 | 1054 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
854 | - if ($globalDebug) echo $result."\n"; |
|
855 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1055 | + if ($globalDebug) { |
|
1056 | + echo $result."\n"; |
|
1057 | + } |
|
1058 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1059 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1060 | + } |
|
856 | 1061 | //$this->del(); |
857 | 1062 | |
858 | 1063 | |
859 | 1064 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
860 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1065 | + if ($globalDebug) { |
|
1066 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1067 | + } |
|
861 | 1068 | $SpotterLive = new SpotterLive($this->db); |
862 | 1069 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
863 | 1070 | $SpotterLive->db = null; |
864 | 1071 | //SpotterLive->deleteLiveSpotterData(); |
865 | - if ($globalDebug) echo " Done\n"; |
|
1072 | + if ($globalDebug) { |
|
1073 | + echo " Done\n"; |
|
1074 | + } |
|
866 | 1075 | $this->last_delete_hourly = time(); |
867 | 1076 | } |
868 | 1077 | |
@@ -870,7 +1079,9 @@ discard block |
||
870 | 1079 | //$ignoreImport = false; |
871 | 1080 | } |
872 | 1081 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
873 | - if ($send) return $this->all_flights[$id]; |
|
1082 | + if ($send) { |
|
1083 | + return $this->all_flights[$id]; |
|
1084 | + } |
|
874 | 1085 | } |
875 | 1086 | } |
876 | 1087 | } |
@@ -28,16 +28,25 @@ discard block |
||
28 | 28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
29 | 29 | //$airline_icao = substr($ident, 0, 3); |
30 | 30 | return $ident; |
31 | - } else return $ident; |
|
32 | - } else return $ident; |
|
31 | + } else { |
|
32 | + return $ident; |
|
33 | + } |
|
34 | + } else { |
|
35 | + return $ident; |
|
36 | + } |
|
33 | 37 | if ($airline_icao == 'AF') { |
34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
38 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
39 | + $icao = $ident; |
|
40 | + } else { |
|
41 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
42 | + } |
|
36 | 43 | } else { |
37 | 44 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
38 | 45 | if (isset($identicao[0])) { |
39 | 46 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
40 | - } else $icao = $ident; |
|
47 | + } else { |
|
48 | + $icao = $ident; |
|
49 | + } |
|
41 | 50 | } |
42 | 51 | return $icao; |
43 | 52 | } |
@@ -56,7 +65,9 @@ discard block |
||
56 | 65 | $sth->closeCursor(); |
57 | 66 | if (count($row) > 0) { |
58 | 67 | return $row['operator_correct']; |
59 | - } else return $ident; |
|
68 | + } else { |
|
69 | + return $ident; |
|
70 | + } |
|
60 | 71 | } |
61 | 72 | |
62 | 73 | public function addOperator($ident,$correct_ident,$source) { |
@@ -85,7 +96,9 @@ discard block |
||
85 | 96 | global $globalTranslationSources, $globalTranslationFetch; |
86 | 97 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
87 | 98 | $globalTranslationSources = array(); |
88 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
99 | + if (!isset($globalTranslationFetch)) { |
|
100 | + $globalTranslationFetch = TRUE; |
|
101 | + } |
|
89 | 102 | //echo "Check Translation for ".$ident."..."; |
90 | 103 | $correct = $this->getOperator($ident); |
91 | 104 | if ($correct != '' && $correct != $ident) { |