@@ -22,11 +22,15 @@ discard block |
||
22 | 22 | require_once('require/class.Spotter.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($filter_name)) $filter_name = ''; |
|
25 | +if (!isset($filter_name)) { |
|
26 | + $filter_name = ''; |
|
27 | +} |
|
26 | 28 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
27 | 29 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
28 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
29 | -} |
|
30 | + if (isset($globalFilter['airline'])) { |
|
31 | + $airline_icao = $globalFilter['airline'][0]; |
|
32 | + } |
|
33 | + } |
|
30 | 34 | if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') { |
31 | 35 | $Spotter = new Spotter(); |
32 | 36 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -61,7 +65,12 @@ discard block |
||
61 | 65 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
62 | 66 | <div class="column"> |
63 | 67 | <div class="info"> |
64 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
68 | + <h1><?php if (isset($airline_name)) { |
|
69 | + echo _("Statistics for ").$airline_name; |
|
70 | +} else { |
|
71 | + echo _("Statistics"); |
|
72 | +} |
|
73 | +?></h1> |
|
65 | 74 | <?php |
66 | 75 | if ($type == 'aircraft') { |
67 | 76 | $last_update = $Stats->getLastStatsUpdate(); |
@@ -69,7 +78,9 @@ discard block |
||
69 | 78 | if (isset($last_update[0]['value'])) { |
70 | 79 | date_default_timezone_set('UTC'); |
71 | 80 | $lastupdate = strtotime($last_update[0]['value']); |
72 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
81 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
82 | + date_default_timezone_set($globalTimezone); |
|
83 | + } |
|
73 | 84 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
74 | 85 | } |
75 | 86 | } |
@@ -154,8 +165,11 @@ discard block |
||
154 | 165 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
155 | 166 | $aircraft_data = ''; |
156 | 167 | foreach($aircraft_array as $aircraft_item) { |
157 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
158 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
168 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
169 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
170 | + } else { |
|
171 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
172 | + } |
|
159 | 173 | } |
160 | 174 | $aircraft_data = substr($aircraft_data, 0, -1); |
161 | 175 | print 'var series = ['.$aircraft_data.'];'; |
@@ -172,11 +186,17 @@ discard block |
||
172 | 186 | <?php |
173 | 187 | if ($year != '' && $month != '') { |
174 | 188 | ?> |
175 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
189 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
190 | + echo '/'.$airline_icao; |
|
191 | +} |
|
192 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
176 | 193 | <?php |
177 | 194 | } else { |
178 | 195 | ?> |
179 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
196 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
197 | + echo '/'.$airline_icao; |
|
198 | +} |
|
199 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
180 | 200 | <?php |
181 | 201 | } |
182 | 202 | ?> |
@@ -205,11 +225,15 @@ discard block |
||
205 | 225 | print '</script>'; |
206 | 226 | if ($year != '' && $month != '') { |
207 | 227 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
208 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
228 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
229 | + echo '/'.$airline_icao; |
|
230 | + } |
|
209 | 231 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
210 | 232 | } else { |
211 | 233 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
212 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
234 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
235 | + echo '/'.$airline_icao; |
|
236 | + } |
|
213 | 237 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
214 | 238 | } |
215 | 239 | print '</div>'; |
@@ -229,8 +253,9 @@ discard block |
||
229 | 253 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
230 | 254 | <?php |
231 | 255 | $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month); |
232 | - if (count($marine_array) == 0) print _("No data available"); |
|
233 | - else { |
|
256 | + if (count($marine_array) == 0) { |
|
257 | + print _("No data available"); |
|
258 | + } else { |
|
234 | 259 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
235 | 260 | $marine_data = ''; |
236 | 261 | foreach($marine_array as $marine_item) { |
@@ -274,8 +299,9 @@ discard block |
||
274 | 299 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
275 | 300 | <?php |
276 | 301 | $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
277 | - if (count($tracker_array) == 0) print _("No data available"); |
|
278 | - else { |
|
302 | + if (count($tracker_array) == 0) { |
|
303 | + print _("No data available"); |
|
304 | + } else { |
|
279 | 305 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
280 | 306 | $tracker_data = ''; |
281 | 307 | foreach($tracker_array as $tracker_item) { |
@@ -319,8 +345,9 @@ discard block |
||
319 | 345 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
320 | 346 | <?php |
321 | 347 | $owner_array = $Satellite->countAllOwners(true); |
322 | - if (count($owner_array) == 0) print _("No data available"); |
|
323 | - else { |
|
348 | + if (count($owner_array) == 0) { |
|
349 | + print _("No data available"); |
|
350 | + } else { |
|
324 | 351 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
325 | 352 | $owner_data = ''; |
326 | 353 | foreach($owner_array as $owner_item) { |
@@ -339,7 +366,10 @@ discard block |
||
339 | 366 | ?> |
340 | 367 | <!-- |
341 | 368 | <div class="more"> |
342 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
369 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
370 | + echo '/'.$airline_icao; |
|
371 | +} |
|
372 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
343 | 373 | </div> |
344 | 374 | --> |
345 | 375 | </div> |
@@ -348,8 +378,9 @@ discard block |
||
348 | 378 | <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2> |
349 | 379 | <?php |
350 | 380 | $countries_array = $Satellite->countAllCountriesOwners(true); |
351 | - if (count($countries_array) == 0) print _("No data available"); |
|
352 | - else { |
|
381 | + if (count($countries_array) == 0) { |
|
382 | + print _("No data available"); |
|
383 | + } else { |
|
353 | 384 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
354 | 385 | $owner_data = ''; |
355 | 386 | foreach($countries_array as $owner_item) { |
@@ -368,7 +399,10 @@ discard block |
||
368 | 399 | ?> |
369 | 400 | <!-- |
370 | 401 | <div class="more"> |
371 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
402 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
403 | + echo '/'.$airline_icao; |
|
404 | +} |
|
405 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
372 | 406 | </div> |
373 | 407 | --> |
374 | 408 | </div> |
@@ -380,8 +414,9 @@ discard block |
||
380 | 414 | <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2> |
381 | 415 | <?php |
382 | 416 | $launch_site_array = $Satellite->countAllLaunchSite(true); |
383 | - if (count($launch_site_array) == 0) print _("No data available"); |
|
384 | - else { |
|
417 | + if (count($launch_site_array) == 0) { |
|
418 | + print _("No data available"); |
|
419 | + } else { |
|
385 | 420 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
386 | 421 | $launch_site_data = ''; |
387 | 422 | foreach($launch_site_array as $launch_site_item) { |
@@ -400,7 +435,10 @@ discard block |
||
400 | 435 | ?> |
401 | 436 | <!-- |
402 | 437 | <div class="more"> |
403 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
438 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
439 | + echo '/'.$airline_icao; |
|
440 | +} |
|
441 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
404 | 442 | </div> |
405 | 443 | --> |
406 | 444 | </div> |
@@ -423,8 +461,9 @@ discard block |
||
423 | 461 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
424 | 462 | <?php |
425 | 463 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
426 | - if (count($pilot_array) == 0) print _("No data available"); |
|
427 | - else { |
|
464 | + if (count($pilot_array) == 0) { |
|
465 | + print _("No data available"); |
|
466 | + } else { |
|
428 | 467 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
429 | 468 | $pilot_data = ''; |
430 | 469 | foreach($pilot_array as $pilot_item) { |
@@ -442,7 +481,9 @@ discard block |
||
442 | 481 | } |
443 | 482 | print '<div class="more">'; |
444 | 483 | print '<a href="'.$globalURL.'/statistics/pilot'; |
445 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
484 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
485 | + echo '/'.$airline_icao; |
|
486 | + } |
|
446 | 487 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
447 | 488 | print '</div>'; |
448 | 489 | ?> |
@@ -458,8 +499,9 @@ discard block |
||
458 | 499 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
459 | 500 | <?php |
460 | 501 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
461 | - if (count($owner_array) == 0) print _("No data available"); |
|
462 | - else { |
|
502 | + if (count($owner_array) == 0) { |
|
503 | + print _("No data available"); |
|
504 | + } else { |
|
463 | 505 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
464 | 506 | $owner_data = ''; |
465 | 507 | foreach($owner_array as $owner_item) { |
@@ -477,7 +519,10 @@ discard block |
||
477 | 519 | } |
478 | 520 | ?> |
479 | 521 | <div class="more"> |
480 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
522 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
523 | + echo '/'.$airline_icao; |
|
524 | +} |
|
525 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
481 | 526 | </div> |
482 | 527 | </div> |
483 | 528 | |
@@ -490,8 +535,9 @@ discard block |
||
490 | 535 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
491 | 536 | <?php |
492 | 537 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
493 | - if (count($flightover_array) == 0) print _("No data available"); |
|
494 | - else { |
|
538 | + if (count($flightover_array) == 0) { |
|
539 | + print _("No data available"); |
|
540 | + } else { |
|
495 | 541 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
496 | 542 | print 'var series = ['; |
497 | 543 | $flightover_data = ''; |
@@ -533,7 +579,10 @@ discard block |
||
533 | 579 | } |
534 | 580 | ?> |
535 | 581 | <div class="more"> |
536 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
582 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
583 | + echo '/'.$airline_icao; |
|
584 | +} |
|
585 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
537 | 586 | </div> |
538 | 587 | </div> |
539 | 588 | <?php |
@@ -551,8 +600,9 @@ discard block |
||
551 | 600 | <div class="col-md-6"> |
552 | 601 | <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2> |
553 | 602 | <?php |
554 | - if (count($flightover_array) == 0) print _("No data available"); |
|
555 | - else { |
|
603 | + if (count($flightover_array) == 0) { |
|
604 | + print _("No data available"); |
|
605 | + } else { |
|
556 | 606 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
557 | 607 | print 'var series = ['; |
558 | 608 | $flightover_data = ''; |
@@ -608,8 +658,9 @@ discard block |
||
608 | 658 | <div class="col-md-6"> |
609 | 659 | <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2> |
610 | 660 | <?php |
611 | - if (count($flightover_array) == 0) print _("No data available"); |
|
612 | - else { |
|
661 | + if (count($flightover_array) == 0) { |
|
662 | + print _("No data available"); |
|
663 | + } else { |
|
613 | 664 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
614 | 665 | print 'var series = ['; |
615 | 666 | $flightover_data = ''; |
@@ -715,7 +766,9 @@ discard block |
||
715 | 766 | });"; |
716 | 767 | print '</script>'; |
717 | 768 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
718 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
769 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
770 | + echo '/'.$airline_icao; |
|
771 | + } |
|
719 | 772 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
720 | 773 | } |
721 | 774 | ?> |
@@ -777,7 +830,9 @@ discard block |
||
777 | 830 | });"; |
778 | 831 | print '</script>'; |
779 | 832 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
780 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
833 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
834 | + echo '/'.$airline_icao; |
|
835 | + } |
|
781 | 836 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
782 | 837 | } |
783 | 838 | ?> |
@@ -796,8 +851,9 @@ discard block |
||
796 | 851 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
797 | 852 | <?php |
798 | 853 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
799 | - if (count($year_array) == 0) print _("No data available"); |
|
800 | - else { |
|
854 | + if (count($year_array) == 0) { |
|
855 | + print _("No data available"); |
|
856 | + } else { |
|
801 | 857 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
802 | 858 | $year_data = ''; |
803 | 859 | $year_cnt = ''; |
@@ -816,7 +872,10 @@ discard block |
||
816 | 872 | } |
817 | 873 | ?> |
818 | 874 | <div class="more"> |
819 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
875 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
876 | + echo '/'.$airline_icao; |
|
877 | +} |
|
878 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
820 | 879 | </div> |
821 | 880 | </div> |
822 | 881 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -824,8 +883,9 @@ discard block |
||
824 | 883 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
825 | 884 | <?php |
826 | 885 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
827 | - if (count($month_array) == 0) print _("No data available"); |
|
828 | - else { |
|
886 | + if (count($month_array) == 0) { |
|
887 | + print _("No data available"); |
|
888 | + } else { |
|
829 | 889 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
830 | 890 | $month_data = ''; |
831 | 891 | $month_cnt = ''; |
@@ -844,7 +904,10 @@ discard block |
||
844 | 904 | } |
845 | 905 | ?> |
846 | 906 | <div class="more"> |
847 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
907 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
908 | + echo '/'.$airline_icao; |
|
909 | +} |
|
910 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
848 | 911 | </div> |
849 | 912 | </div> |
850 | 913 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -853,8 +916,9 @@ discard block |
||
853 | 916 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
854 | 917 | <?php |
855 | 918 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
856 | - if (empty($date_array)) print _("No data available"); |
|
857 | - else { |
|
919 | + if (empty($date_array)) { |
|
920 | + print _("No data available"); |
|
921 | + } else { |
|
858 | 922 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
859 | 923 | $date_data = ''; |
860 | 924 | $date_cnt = ''; |
@@ -873,7 +937,10 @@ discard block |
||
873 | 937 | } |
874 | 938 | ?> |
875 | 939 | <div class="more"> |
876 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
940 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
941 | + echo '/'.$airline_icao; |
|
942 | +} |
|
943 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
877 | 944 | </div> |
878 | 945 | </div> |
879 | 946 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -881,8 +948,9 @@ discard block |
||
881 | 948 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
882 | 949 | <?php |
883 | 950 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
884 | - if (empty($hour_array)) print _("No data available"); |
|
885 | - else { |
|
951 | + if (empty($hour_array)) { |
|
952 | + print _("No data available"); |
|
953 | + } else { |
|
886 | 954 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
887 | 955 | $hour_data = ''; |
888 | 956 | $hour_cnt = ''; |
@@ -901,7 +969,10 @@ discard block |
||
901 | 969 | } |
902 | 970 | ?> |
903 | 971 | <div class="more"> |
904 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
972 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
973 | + echo '/'.$airline_icao; |
|
974 | +} |
|
975 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
905 | 976 | </div> |
906 | 977 | </div> |
907 | 978 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -921,8 +992,9 @@ discard block |
||
921 | 992 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
922 | 993 | <?php |
923 | 994 | $year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
924 | - if (count($year_array) == 0) print _("No data available"); |
|
925 | - else { |
|
995 | + if (count($year_array) == 0) { |
|
996 | + print _("No data available"); |
|
997 | + } else { |
|
926 | 998 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
927 | 999 | $year_data = ''; |
928 | 1000 | $year_cnt = ''; |
@@ -950,8 +1022,9 @@ discard block |
||
950 | 1022 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
951 | 1023 | <?php |
952 | 1024 | $month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name); |
953 | - if (count($month_array) == 0) print _("No data available"); |
|
954 | - else { |
|
1025 | + if (count($month_array) == 0) { |
|
1026 | + print _("No data available"); |
|
1027 | + } else { |
|
955 | 1028 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
956 | 1029 | $month_data = ''; |
957 | 1030 | $month_cnt = ''; |
@@ -979,8 +1052,9 @@ discard block |
||
979 | 1052 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
980 | 1053 | <?php |
981 | 1054 | $date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name); |
982 | - if (empty($date_array)) print _("No data available"); |
|
983 | - else { |
|
1055 | + if (empty($date_array)) { |
|
1056 | + print _("No data available"); |
|
1057 | + } else { |
|
984 | 1058 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
985 | 1059 | $date_data = ''; |
986 | 1060 | $date_cnt = ''; |
@@ -1007,8 +1081,9 @@ discard block |
||
1007 | 1081 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1008 | 1082 | <?php |
1009 | 1083 | $hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name); |
1010 | - if (empty($hour_array)) print _("No data available"); |
|
1011 | - else { |
|
1084 | + if (empty($hour_array)) { |
|
1085 | + print _("No data available"); |
|
1086 | + } else { |
|
1012 | 1087 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1013 | 1088 | $hour_data = ''; |
1014 | 1089 | $hour_cnt = ''; |
@@ -1047,8 +1122,9 @@ discard block |
||
1047 | 1122 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
1048 | 1123 | <?php |
1049 | 1124 | $year_array = $Tracker->countAllMonthsLastYear(true); |
1050 | - if (count($year_array) == 0) print _("No data available"); |
|
1051 | - else { |
|
1125 | + if (count($year_array) == 0) { |
|
1126 | + print _("No data available"); |
|
1127 | + } else { |
|
1052 | 1128 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
1053 | 1129 | $year_data = ''; |
1054 | 1130 | $year_cnt = ''; |
@@ -1076,8 +1152,9 @@ discard block |
||
1076 | 1152 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
1077 | 1153 | <?php |
1078 | 1154 | $month_array = $Tracker->countAllDatesLastMonth(); |
1079 | - if (count($month_array) == 0) print _("No data available"); |
|
1080 | - else { |
|
1155 | + if (count($month_array) == 0) { |
|
1156 | + print _("No data available"); |
|
1157 | + } else { |
|
1081 | 1158 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
1082 | 1159 | $month_data = ''; |
1083 | 1160 | $month_cnt = ''; |
@@ -1105,8 +1182,9 @@ discard block |
||
1105 | 1182 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
1106 | 1183 | <?php |
1107 | 1184 | $date_array = $Tracker->countAllDatesLast7Days(); |
1108 | - if (empty($date_array)) print _("No data available"); |
|
1109 | - else { |
|
1185 | + if (empty($date_array)) { |
|
1186 | + print _("No data available"); |
|
1187 | + } else { |
|
1110 | 1188 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
1111 | 1189 | $date_data = ''; |
1112 | 1190 | $date_cnt = ''; |
@@ -1133,8 +1211,9 @@ discard block |
||
1133 | 1211 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1134 | 1212 | <?php |
1135 | 1213 | $hour_array = $Tracker->countAllHours('hour',true); |
1136 | - if (empty($hour_array)) print _("No data available"); |
|
1137 | - else { |
|
1214 | + if (empty($hour_array)) { |
|
1215 | + print _("No data available"); |
|
1216 | + } else { |
|
1138 | 1217 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1139 | 1218 | $hour_data = ''; |
1140 | 1219 | $hour_cnt = ''; |
@@ -1173,8 +1252,9 @@ discard block |
||
1173 | 1252 | <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2> |
1174 | 1253 | <?php |
1175 | 1254 | $year_array = $Satellite->countAllMonthsLastYear(); |
1176 | - if (count($year_array) == 0) print _("No data available"); |
|
1177 | - else { |
|
1255 | + if (count($year_array) == 0) { |
|
1256 | + print _("No data available"); |
|
1257 | + } else { |
|
1178 | 1258 | print '<div id="chart21" class="chart" width="100%"></div><script>'; |
1179 | 1259 | $year_data = ''; |
1180 | 1260 | $year_cnt = ''; |
@@ -1204,8 +1284,9 @@ discard block |
||
1204 | 1284 | <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2> |
1205 | 1285 | <?php |
1206 | 1286 | $year_array = $Satellite->countAllYears(); |
1207 | - if (count($year_array) == 0) print _("No data available"); |
|
1208 | - else { |
|
1287 | + if (count($year_array) == 0) { |
|
1288 | + print _("No data available"); |
|
1289 | + } else { |
|
1209 | 1290 | print '<div id="chart22" class="chart" width="100%"></div><script>'; |
1210 | 1291 | $year_data = ''; |
1211 | 1292 | $year_cnt = ''; |
@@ -1247,8 +1328,9 @@ discard block |
||
1247 | 1328 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
1248 | 1329 | <?php |
1249 | 1330 | $year_array = $Stats->countFatalitiesByYear(); |
1250 | - if (count($year_array) == 0) print _("No data available"); |
|
1251 | - else { |
|
1331 | + if (count($year_array) == 0) { |
|
1332 | + print _("No data available"); |
|
1333 | + } else { |
|
1252 | 1334 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
1253 | 1335 | $year_data = ''; |
1254 | 1336 | $year_cnt = ''; |
@@ -1277,8 +1359,9 @@ discard block |
||
1277 | 1359 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
1278 | 1360 | <?php |
1279 | 1361 | $year_array = $Stats->countFatalitiesLast12Months(); |
1280 | - if (count($year_array) == 0) print _("No data available"); |
|
1281 | - else { |
|
1362 | + if (count($year_array) == 0) { |
|
1363 | + print _("No data available"); |
|
1364 | + } else { |
|
1282 | 1365 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
1283 | 1366 | $year_data = ''; |
1284 | 1367 | $year_cnt = ''; |
@@ -1349,8 +1432,11 @@ discard block |
||
1349 | 1432 | $distance = $distance; |
1350 | 1433 | $unit = 'km'; |
1351 | 1434 | } |
1352 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1353 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1435 | + if (!isset($polar_data)) { |
|
1436 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1437 | + } else { |
|
1438 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
1439 | + } |
|
1354 | 1440 | } |
1355 | 1441 | ?> |
1356 | 1442 | <div class="col-md-6"> |
@@ -1414,9 +1500,12 @@ discard block |
||
1414 | 1500 | foreach ($msg as $eachmsg) { |
1415 | 1501 | //$eachmsg = $msg[0]; |
1416 | 1502 | $data = $eachmsg['source_data']; |
1417 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
1418 | - else $max = 500; |
|
1419 | -?> |
|
1503 | + if ($data > 500) { |
|
1504 | + $max = (round(($data+100)/100))*100; |
|
1505 | + } else { |
|
1506 | + $max = 500; |
|
1507 | + } |
|
1508 | + ?> |
|
1420 | 1509 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
1421 | 1510 | <script> |
1422 | 1511 | var g = new JustGage({ |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,17 +108,25 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $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']); |
108 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $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'])); |
116 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
132 | 148 | |
133 | 149 | public function checkAll() { |
134 | 150 | global $globalDebug, $globalNoImport; |
135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Update last seen flights data...\n"; |
|
153 | + } |
|
136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | 155 | foreach ($this->all_flights as $key => $flight) { |
138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 158 | $Spotter = new Spotter($this->db); |
141 | 159 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']); |
|
160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
161 | + $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']); |
|
162 | + } |
|
143 | 163 | } |
144 | 164 | } |
145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
147 | 167 | |
148 | 168 | public function arrival($key) { |
149 | 169 | global $globalClosestMinDist, $globalDebug; |
150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo 'Update arrival...'."\n"; |
|
172 | + } |
|
151 | 173 | $Spotter = new Spotter($this->db); |
152 | 174 | $airport_icao = ''; |
153 | 175 | $airport_time = ''; |
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
177 | + $globalClosestMinDist = 50; |
|
178 | + } |
|
155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
157 | 181 | if (isset($closestAirports[0])) { |
158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
187 | + } |
|
162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
163 | 189 | foreach ($closestAirports as $airport) { |
164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
165 | 191 | $airport_icao = $airport['icao']; |
166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
195 | + } |
|
168 | 196 | break; |
169 | 197 | } |
170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 202 | } else { |
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
205 | + } |
|
176 | 206 | } |
177 | 207 | } else { |
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
210 | + } |
|
179 | 211 | } |
180 | 212 | |
181 | 213 | } else { |
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
216 | + } |
|
183 | 217 | } |
184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
189 | 223 | public function del() { |
190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 225 | // Delete old infos |
192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
226 | + if ($globalDebug) { |
|
227 | + echo 'Delete old values and update latest data...'."\n"; |
|
228 | + } |
|
193 | 229 | foreach ($this->all_flights as $key => $flight) { |
194 | 230 | if (isset($flight['lastupdate'])) { |
195 | 231 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -203,13 +239,17 @@ discard block |
||
203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 240 | // Delete old infos |
205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
244 | + } |
|
207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
208 | 246 | $real_arrival = $this->arrival($key); |
209 | 247 | $Spotter = new Spotter($this->db); |
210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | 249 | $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']); |
212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
250 | + if ($globalDebug && $result != 'success') { |
|
251 | + echo '!!! ERROR : '.$result."\n"; |
|
252 | + } |
|
213 | 253 | } |
214 | 254 | } |
215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
219 | 259 | public function add($line) { |
220 | 260 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224 | -/* |
|
262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
263 | + $globalCoordMinChange = '0.02'; |
|
264 | + } |
|
265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
266 | + $globalAircraftMaxUpdate = 3000; |
|
267 | + } |
|
268 | + /* |
|
225 | 269 | $Spotter = new Spotter(); |
226 | 270 | $dbc = $Spotter->db; |
227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
243 | 287 | // SBS format is CSV format |
244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | 289 | //print_r($line); |
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
290 | + if (isset($line['hex'])) { |
|
291 | + $line['hex'] = strtoupper($line['hex']); |
|
292 | + } |
|
247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
248 | 294 | |
249 | 295 | // Increment message number |
250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | 297 | $current_date = date('Y-m-d'); |
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
298 | + if (isset($line['source_name'])) { |
|
299 | + $source = $line['source_name']; |
|
300 | + } else { |
|
301 | + $source = ''; |
|
302 | + } |
|
303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
304 | + $source = $line['format_source']; |
|
305 | + } |
|
255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
309 | + } else { |
|
310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
311 | + } |
|
259 | 312 | } |
260 | 313 | |
261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
271 | 324 | //$this->db = $dbc; |
272 | 325 | |
273 | 326 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
327 | + if (!isset($line['id'])) { |
|
328 | + $id = trim($line['hex']); |
|
329 | + } else { |
|
330 | + $id = trim($line['id']); |
|
331 | + } |
|
276 | 332 | |
277 | 333 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'New flight...'."\n"; |
|
336 | + } |
|
279 | 337 | $this->all_flights[$id] = array(); |
280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
281 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', '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,'source_type' => '')); |
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
342 | + } |
|
283 | 343 | if (!isset($line['id'])) { |
284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285 | -// 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'))); |
|
344 | + if (!isset($globalDaemon)) { |
|
345 | + $globalDaemon = TRUE; |
|
346 | + } |
|
347 | + // 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'))); |
|
286 | 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') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
349 | + 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' || $line['format_source'] === 'famaprs')) { |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
351 | + } |
|
288 | 352 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
353 | + } else { |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
355 | + } |
|
356 | + if ($globalAllFlights !== FALSE) { |
|
357 | + $dataFound = true; |
|
358 | + } |
|
291 | 359 | } |
292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 378 | } |
311 | 379 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
383 | + if ($aircraft_icao != '') { |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
385 | + } |
|
314 | 386 | } |
315 | 387 | } |
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
388 | + if ($globalAllFlights !== FALSE) { |
|
389 | + $dataFound = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
393 | + } |
|
318 | 394 | } |
319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -322,7 +398,9 @@ discard block |
||
322 | 398 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 399 | $icao = $line['aircraft_icao']; |
324 | 400 | $Spotter = new Spotter($this->db); |
325 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
401 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
402 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
403 | + } |
|
326 | 404 | $Spotter->db = null; |
327 | 405 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
328 | 406 | } |
@@ -332,15 +410,24 @@ discard block |
||
332 | 410 | $Spotter = new Spotter($this->db); |
333 | 411 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
334 | 412 | $Spotter->db = null; |
335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
413 | + if ($aircraft_icao != '') { |
|
414 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
415 | + } |
|
336 | 416 | } |
337 | 417 | } |
338 | 418 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
339 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
340 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
341 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
342 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
419 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
420 | + $aircraft_icao = 'GLID'; |
|
421 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
422 | + $aircraft_icao = 'UHEL'; |
|
423 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
424 | + $aircraft_icao = 'TOWPLANE'; |
|
425 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
426 | + $aircraft_icao = 'POWAIRC'; |
|
427 | + } |
|
428 | + if (isset($aircraft_icao)) { |
|
429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
430 | + } |
|
344 | 431 | } |
345 | 432 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
346 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -350,8 +437,11 @@ discard block |
||
350 | 437 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
351 | 438 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
352 | 439 | } else { |
353 | - 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"; |
|
354 | - 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"; |
|
440 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
441 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
442 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
443 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
444 | + } |
|
355 | 445 | /* |
356 | 446 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
357 | 447 | print_r($this->all_flights[$id]); |
@@ -360,16 +450,22 @@ discard block |
||
360 | 450 | return ''; |
361 | 451 | } |
362 | 452 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
363 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
453 | + if ($globalDebug) { |
|
454 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
455 | + } |
|
364 | 456 | return ''; |
365 | 457 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
366 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
458 | + if ($globalDebug) { |
|
459 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
460 | + } |
|
367 | 461 | return ''; |
368 | 462 | } elseif (!isset($line['datetime'])) { |
369 | 463 | date_default_timezone_set('UTC'); |
370 | 464 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
371 | 465 | } else { |
372 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
466 | + if ($globalDebug) { |
|
467 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
468 | + } |
|
373 | 469 | return ''; |
374 | 470 | } |
375 | 471 | |
@@ -390,30 +486,48 @@ discard block |
||
390 | 486 | |
391 | 487 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
392 | 488 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
393 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
489 | + if ($globalDebug) { |
|
490 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
491 | + } |
|
394 | 492 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
395 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
396 | - 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
398 | - 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'])); |
|
494 | + 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' || $line['format_source'] === 'famaprs')) { |
|
495 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
496 | + } elseif (isset($line['id'])) { |
|
497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
498 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
499 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
500 | + } |
|
399 | 501 | } else { |
400 | 502 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
401 | 503 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
402 | 504 | $timeelapsed = microtime(true); |
403 | 505 | $Spotter = new Spotter($this->db); |
404 | 506 | $fromsource = NULL; |
405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
408 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
409 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
507 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
508 | + $fromsource = $globalAirlinesSource; |
|
509 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
510 | + $fromsource = 'vatsim'; |
|
511 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
512 | + $fromsource = 'ivao'; |
|
513 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
514 | + $fromsource = 'vatsim'; |
|
515 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
516 | + $fromsource = 'ivao'; |
|
517 | + } |
|
410 | 518 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
411 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
519 | + if ($globalDebug && $result != 'success') { |
|
520 | + echo '!!! ERROR : '.$result."\n"; |
|
521 | + } |
|
412 | 522 | $Spotter->db = null; |
413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
523 | + if ($globalDebugTimeElapsed) { |
|
524 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
525 | + } |
|
414 | 526 | } |
415 | 527 | } |
416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
528 | + } else { |
|
529 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
530 | + } |
|
417 | 531 | |
418 | 532 | /* |
419 | 533 | if (!isset($line['id'])) { |
@@ -423,7 +537,9 @@ discard block |
||
423 | 537 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
424 | 538 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
425 | 539 | */ |
426 | - 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'])); |
|
540 | + if (!isset($this->all_flights[$id]['id'])) { |
|
541 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
542 | + } |
|
427 | 543 | |
428 | 544 | //$putinarchive = true; |
429 | 545 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -441,7 +557,9 @@ discard block |
||
441 | 557 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
442 | 558 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
443 | 559 | $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' => '')); |
444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
560 | + if ($globalDebugTimeElapsed) { |
|
561 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
562 | + } |
|
445 | 563 | } |
446 | 564 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
447 | 565 | $timeelapsed = microtime(true); |
@@ -455,7 +573,9 @@ discard block |
||
455 | 573 | $Translation->db = null; |
456 | 574 | } |
457 | 575 | $Spotter->db = null; |
458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
576 | + if ($globalDebugTimeElapsed) { |
|
577 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
578 | + } |
|
459 | 579 | } |
460 | 580 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
461 | 581 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -464,9 +584,13 @@ discard block |
||
464 | 584 | $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'])); |
465 | 585 | } |
466 | 586 | } |
467 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
587 | + if (!isset($globalFork)) { |
|
588 | + $globalFork = TRUE; |
|
589 | + } |
|
468 | 590 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
591 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
592 | + $this->get_Schedule($id,trim($line['ident'])); |
|
593 | + } |
|
470 | 594 | } |
471 | 595 | } |
472 | 596 | } |
@@ -484,9 +608,13 @@ discard block |
||
484 | 608 | $speed = $speed*3.6; |
485 | 609 | if ($speed < 1000) { |
486 | 610 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
487 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
611 | + if ($globalDebug) { |
|
612 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
613 | + } |
|
488 | 614 | } else { |
489 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
615 | + if ($globalDebug) { |
|
616 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
617 | + } |
|
490 | 618 | } |
491 | 619 | } |
492 | 620 | } |
@@ -495,13 +623,21 @@ discard block |
||
495 | 623 | |
496 | 624 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
497 | 625 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
626 | + if ($globalDebug) { |
|
627 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
628 | + } |
|
499 | 629 | return false; |
500 | 630 | } |
501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | - else unset($timediff); |
|
503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | - else unset($timediff_archive); |
|
631 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
632 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
633 | + } else { |
|
634 | + unset($timediff); |
|
635 | + } |
|
636 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
637 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
638 | + } else { |
|
639 | + unset($timediff_archive); |
|
640 | + } |
|
505 | 641 | if ($this->tmd > 5 |
506 | 642 | || (isset($line['format_source']) |
507 | 643 | && $line['format_source'] == 'airwhere' |
@@ -537,16 +673,25 @@ discard block |
||
537 | 673 | $this->all_flights[$id]['putinarchive'] = true; |
538 | 674 | $this->tmd = 0; |
539 | 675 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
676 | + if ($globalDebug) { |
|
677 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
678 | + } |
|
541 | 679 | $timeelapsed = microtime(true); |
542 | 680 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
543 | 681 | $Spotter = new Spotter($this->db); |
544 | 682 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
545 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
546 | - else $this->all_flights[$id]['over_country'] = ''; |
|
683 | + if (!empty($all_country)) { |
|
684 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
685 | + } else { |
|
686 | + $this->all_flights[$id]['over_country'] = ''; |
|
687 | + } |
|
547 | 688 | $Spotter->db = null; |
548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
549 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
689 | + if ($globalDebugTimeElapsed) { |
|
690 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
691 | + } |
|
692 | + if ($globalDebug) { |
|
693 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
694 | + } |
|
550 | 695 | } |
551 | 696 | } |
552 | 697 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -592,7 +737,9 @@ discard block |
||
592 | 737 | */ |
593 | 738 | } |
594 | 739 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
740 | + if ($line['longitude'] > 180) { |
|
741 | + $line['longitude'] = $line['longitude'] - 360; |
|
742 | + } |
|
596 | 743 | //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) { |
597 | 744 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
598 | 745 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -629,7 +776,9 @@ discard block |
||
629 | 776 | } |
630 | 777 | } |
631 | 778 | if (isset($line['last_update']) && $line['last_update'] != '') { |
632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
779 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
780 | + $dataFound = true; |
|
781 | + } |
|
633 | 782 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
634 | 783 | } |
635 | 784 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -651,35 +800,53 @@ discard block |
||
651 | 800 | // Here we force archive of flight because after ground it's a new one (or should be) |
652 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
653 | 802 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
654 | - 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
656 | - 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'])); |
|
803 | + 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' || $line['format_source'] === 'famaprs')) { |
|
804 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
805 | + } elseif (isset($line['id'])) { |
|
806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
807 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
809 | + } |
|
810 | + } |
|
811 | + if ($line['ground'] != 1) { |
|
812 | + $line['ground'] = 0; |
|
657 | 813 | } |
658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
659 | 814 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
660 | 815 | //$dataFound = true; |
661 | 816 | } |
662 | 817 | if (isset($line['squawk']) && $line['squawk'] != '') { |
663 | 818 | 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'])) { |
664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
819 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
820 | + $this->all_flights[$id]['putinarchive'] = true; |
|
821 | + } |
|
665 | 822 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
666 | 823 | $highlight = ''; |
667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
824 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
825 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
826 | + } |
|
827 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
828 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
829 | + } |
|
830 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
831 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
832 | + } |
|
670 | 833 | if ($highlight != '') { |
671 | 834 | $timeelapsed = microtime(true); |
672 | 835 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
673 | 836 | $Spotter = new Spotter($this->db); |
674 | 837 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
675 | 838 | $Spotter->db = null; |
676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
839 | + if ($globalDebugTimeElapsed) { |
|
840 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
841 | + } |
|
677 | 842 | } |
678 | 843 | //$putinarchive = true; |
679 | 844 | //$highlight = ''; |
680 | 845 | } |
681 | 846 | |
682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
847 | + } else { |
|
848 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
849 | + } |
|
683 | 850 | //$dataFound = true; |
684 | 851 | } |
685 | 852 | |
@@ -692,19 +859,27 @@ discard block |
||
692 | 859 | } |
693 | 860 | } |
694 | 861 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
862 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
863 | + $this->all_flights[$id]['putinarchive'] = true; |
|
864 | + } |
|
696 | 865 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
697 | 866 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
698 | 867 | //$dataFound = true; |
699 | 868 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
700 | 869 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
701 | 870 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
702 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
871 | + if ($globalDebug) { |
|
872 | + echo '--- Reset because of altitude'."\n"; |
|
873 | + } |
|
703 | 874 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
704 | 875 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
705 | - 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
707 | - 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'])); |
|
876 | + 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' || $line['format_source'] === 'famaprs')) { |
|
877 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
878 | + } elseif (isset($line['id'])) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
880 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
882 | + } |
|
708 | 883 | } |
709 | 884 | } |
710 | 885 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -715,22 +890,32 @@ discard block |
||
715 | 890 | } |
716 | 891 | |
717 | 892 | if (isset($line['heading']) && $line['heading'] != '') { |
718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
893 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
894 | + $this->all_flights[$id]['putinarchive'] = true; |
|
895 | + } |
|
719 | 896 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
720 | 897 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
721 | 898 | //$dataFound = true; |
722 | 899 | } 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']) { |
723 | 900 | $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']); |
724 | 901 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
902 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
903 | + $this->all_flights[$id]['putinarchive'] = true; |
|
904 | + } |
|
905 | + if ($globalDebug) { |
|
906 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
907 | + } |
|
727 | 908 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
728 | 909 | // If not enough messages and ACARS set heading to 0 |
729 | 910 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
730 | 911 | } |
731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
912 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
913 | + $dataFound = false; |
|
914 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
915 | + $dataFound = false; |
|
916 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
917 | + $dataFound = false; |
|
918 | + } |
|
734 | 919 | |
735 | 920 | // print_r($this->all_flights[$id]); |
736 | 921 | //gets the callsign from the last hour |
@@ -747,23 +932,38 @@ discard block |
||
747 | 932 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
748 | 933 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
749 | 934 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
935 | + if ($globalDebug) { |
|
936 | + echo "Check if aircraft is already in DB..."; |
|
937 | + } |
|
751 | 938 | $timeelapsed = microtime(true); |
752 | 939 | $SpotterLive = new SpotterLive($this->db); |
753 | 940 | 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' || $line['format_source'] === 'famaprs')) { |
754 | 941 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
942 | + if ($globalDebugTimeElapsed) { |
|
943 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
944 | + } |
|
756 | 945 | } elseif (isset($line['id'])) { |
757 | 946 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
947 | + if ($globalDebugTimeElapsed) { |
|
948 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
949 | + } |
|
759 | 950 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
760 | 951 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
762 | - } else $recent_ident = ''; |
|
952 | + if ($globalDebugTimeElapsed) { |
|
953 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
954 | + } |
|
955 | + } else { |
|
956 | + $recent_ident = ''; |
|
957 | + } |
|
763 | 958 | $SpotterLive->db=null; |
764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
766 | - } else $recent_ident = ''; |
|
959 | + if ($globalDebug && $recent_ident == '') { |
|
960 | + echo " Not in DB.\n"; |
|
961 | + } elseif ($globalDebug && $recent_ident != '') { |
|
962 | + echo " Already in DB.\n"; |
|
963 | + } |
|
964 | + } else { |
|
965 | + $recent_ident = ''; |
|
966 | + } |
|
767 | 967 | } else { |
768 | 968 | $recent_ident = ''; |
769 | 969 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -771,7 +971,9 @@ discard block |
||
771 | 971 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
772 | 972 | if($recent_ident == "") |
773 | 973 | { |
774 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
974 | + if ($globalDebug) { |
|
975 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
976 | + } |
|
775 | 977 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
776 | 978 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
777 | 979 | //adds the spotter data for the archive |
@@ -815,31 +1017,49 @@ discard block |
||
815 | 1017 | |
816 | 1018 | if (!$ignoreImport) { |
817 | 1019 | $highlight = ''; |
818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
821 | - 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'))); |
|
1020 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1021 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1022 | + } |
|
1023 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1024 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1025 | + } |
|
1026 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1027 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1028 | + } |
|
1029 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1030 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1031 | + } |
|
822 | 1032 | $timeelapsed = microtime(true); |
823 | 1033 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
824 | 1034 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
825 | 1035 | $Spotter = new Spotter($this->db); |
826 | 1036 | $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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']); |
827 | 1037 | $Spotter->db = null; |
828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
1038 | + if ($globalDebug && isset($result)) { |
|
1039 | + echo $result."\n"; |
|
1040 | + } |
|
829 | 1041 | } |
830 | 1042 | } |
831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1043 | + if ($globalDebugTimeElapsed) { |
|
1044 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1045 | + } |
|
832 | 1046 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
833 | 1047 | |
834 | 1048 | // Add source stat in DB |
835 | 1049 | $Stats = new Stats($this->db); |
836 | 1050 | if (!empty($this->stats)) { |
837 | - if ($globalDebug) echo 'Add source stats : '; |
|
1051 | + if ($globalDebug) { |
|
1052 | + echo 'Add source stats : '; |
|
1053 | + } |
|
838 | 1054 | foreach($this->stats as $date => $data) { |
839 | 1055 | foreach($data as $source => $sourced) { |
840 | 1056 | //print_r($sourced); |
841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1057 | + if (isset($sourced['polar'])) { |
|
1058 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1059 | + } |
|
1060 | + if (isset($sourced['hist'])) { |
|
1061 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1062 | + } |
|
843 | 1063 | if (isset($sourced['msg'])) { |
844 | 1064 | if (time() - $sourced['msg']['date'] > 10) { |
845 | 1065 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -852,13 +1072,17 @@ discard block |
||
852 | 1072 | unset($this->stats[$date]); |
853 | 1073 | } |
854 | 1074 | } |
855 | - if ($globalDebug) echo 'Done'."\n"; |
|
1075 | + if ($globalDebug) { |
|
1076 | + echo 'Done'."\n"; |
|
1077 | + } |
|
856 | 1078 | |
857 | 1079 | } |
858 | 1080 | $Stats->db = null; |
859 | 1081 | } |
860 | 1082 | $this->del(); |
861 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1083 | + } elseif ($globalDebug) { |
|
1084 | + echo 'Ignore data'."\n"; |
|
1085 | + } |
|
862 | 1086 | //$ignoreImport = false; |
863 | 1087 | $this->all_flights[$id]['addedSpotter'] = 1; |
864 | 1088 | //print_r($this->all_flights[$id]); |
@@ -875,7 +1099,9 @@ discard block |
||
875 | 1099 | */ |
876 | 1100 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
877 | 1101 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1102 | + if ($globalDebug) { |
|
1103 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1104 | + } |
|
879 | 1105 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
880 | 1106 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
881 | 1107 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -884,7 +1110,9 @@ discard block |
||
884 | 1110 | $SpotterLive->db=null; |
885 | 1111 | } |
886 | 1112 | } |
887 | - if ($globalDebug) echo " Done\n"; |
|
1113 | + if ($globalDebug) { |
|
1114 | + echo " Done\n"; |
|
1115 | + } |
|
888 | 1116 | $this->last_delete = time(); |
889 | 1117 | } |
890 | 1118 | } else { |
@@ -911,11 +1139,17 @@ discard block |
||
911 | 1139 | //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"; |
912 | 1140 | if ($globalDebug) { |
913 | 1141 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
914 | - 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"; |
|
915 | - 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"; |
|
1142 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1143 | + 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"; |
|
1144 | + } else { |
|
1145 | + 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"; |
|
1146 | + } |
|
916 | 1147 | } else { |
917 | - 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"; |
|
918 | - 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"; |
|
1148 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1149 | + 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"; |
|
1150 | + } else { |
|
1151 | + 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"; |
|
1152 | + } |
|
919 | 1153 | } |
920 | 1154 | } |
921 | 1155 | $ignoreImport = false; |
@@ -961,22 +1195,30 @@ discard block |
||
961 | 1195 | |
962 | 1196 | if (!$ignoreImport) { |
963 | 1197 | 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'])) { |
964 | - 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'))); |
|
1198 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1199 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1200 | + } |
|
965 | 1201 | $timeelapsed = microtime(true); |
966 | 1202 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
967 | 1203 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
968 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1204 | + if ($globalDebug) { |
|
1205 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1206 | + } |
|
969 | 1207 | $SpotterLive = new SpotterLive($this->db); |
970 | 1208 | $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]['altitude_real'], $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']); |
971 | 1209 | $SpotterLive->db = null; |
972 | - if ($globalDebug) echo $result."\n"; |
|
1210 | + if ($globalDebug) { |
|
1211 | + echo $result."\n"; |
|
1212 | + } |
|
973 | 1213 | } |
974 | 1214 | } |
975 | 1215 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
976 | 1216 | $APRSSpotter->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]['altitude_real'], $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']); |
977 | 1217 | } |
978 | 1218 | $this->all_flights[$id]['putinarchive'] = false; |
979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1219 | + if ($globalDebugTimeElapsed) { |
|
1220 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1221 | + } |
|
980 | 1222 | |
981 | 1223 | // Put statistics in $this->stats variable |
982 | 1224 | //if ($line['format_source'] != 'aprs') { |
@@ -984,7 +1226,9 @@ discard block |
||
984 | 1226 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
985 | 1227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
986 | 1228 | $source = $this->all_flights[$id]['source_name']; |
987 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1229 | + if ($source == '') { |
|
1230 | + $source = $this->all_flights[$id]['format_source']; |
|
1231 | + } |
|
988 | 1232 | if (!isset($this->source_location[$source])) { |
989 | 1233 | $Location = new Source($this->db); |
990 | 1234 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1005,7 +1249,9 @@ discard block |
||
1005 | 1249 | $stats_heading = round($stats_heading/22.5); |
1006 | 1250 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1007 | 1251 | $current_date = date('Y-m-d'); |
1008 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1252 | + if ($stats_heading == 16) { |
|
1253 | + $stats_heading = 0; |
|
1254 | + } |
|
1009 | 1255 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1010 | 1256 | for ($i=0;$i<=15;$i++) { |
1011 | 1257 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1023,7 +1269,9 @@ discard block |
||
1023 | 1269 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1024 | 1270 | end($this->stats[$current_date][$source]['hist']); |
1025 | 1271 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1026 | - } else $mini = 0; |
|
1272 | + } else { |
|
1273 | + $mini = 0; |
|
1274 | + } |
|
1027 | 1275 | for ($i=$mini;$i<=$distance;$i+=10) { |
1028 | 1276 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1029 | 1277 | } |
@@ -1035,19 +1283,27 @@ discard block |
||
1035 | 1283 | } |
1036 | 1284 | |
1037 | 1285 | $this->all_flights[$id]['lastupdate'] = time(); |
1038 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1286 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1287 | + $send = true; |
|
1288 | + } |
|
1039 | 1289 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1040 | - } 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"; |
|
1290 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1291 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1292 | + } |
|
1041 | 1293 | //$this->del(); |
1042 | 1294 | |
1043 | 1295 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1044 | 1296 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1045 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1297 | + if ($globalDebug) { |
|
1298 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1299 | + } |
|
1046 | 1300 | $SpotterLive = new SpotterLive($this->db); |
1047 | 1301 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1048 | 1302 | $SpotterLive->db = null; |
1049 | 1303 | //SpotterLive->deleteLiveSpotterData(); |
1050 | - if ($globalDebug) echo " Done\n"; |
|
1304 | + if ($globalDebug) { |
|
1305 | + echo " Done\n"; |
|
1306 | + } |
|
1051 | 1307 | $this->last_delete_hourly = time(); |
1052 | 1308 | } else { |
1053 | 1309 | $this->del(); |
@@ -1059,7 +1315,9 @@ discard block |
||
1059 | 1315 | //$ignoreImport = false; |
1060 | 1316 | } |
1061 | 1317 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1062 | - if ($send) return $this->all_flights[$id]; |
|
1318 | + if ($send) { |
|
1319 | + return $this->all_flights[$id]; |
|
1320 | + } |
|
1063 | 1321 | } |
1064 | 1322 | } |
1065 | 1323 | } |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | public function __construct($dbc = null) { |
8 | 8 | $Connection = new Connection($dbc); |
9 | 9 | $this->db = $Connection->db; |
10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
10 | + if ($this->db === null) { |
|
11 | + die('Error: No DB connection.'); |
|
12 | + } |
|
11 | 13 | } |
12 | 14 | |
13 | 15 | /** |
@@ -20,20 +22,27 @@ discard block |
||
20 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 24 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
25 | + if (isset($source['source'])) { |
|
26 | + $filter['source'][] = $source['source']; |
|
27 | + } |
|
24 | 28 | } |
25 | 29 | } else { |
26 | 30 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 31 | } |
28 | 32 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) { |
|
34 | + $filter = array_merge($filter,$globalFilter); |
|
35 | + } |
|
30 | 36 | $filter_query_join = ''; |
31 | 37 | $filter_query_where = ''; |
32 | 38 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | 39 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
34 | 40 | } |
35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
41 | + if ($filter_query_where == '' && $where) { |
|
42 | + $filter_query_where = ' WHERE'; |
|
43 | + } elseif ($filter_query_where != '' && $and) { |
|
44 | + $filter_query_where .= ' AND'; |
|
45 | + } |
|
37 | 46 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 47 | return $filter_query; |
39 | 48 | } |
@@ -90,7 +99,9 @@ discard block |
||
90 | 99 | $info = str_replace('^','<br />',$info); |
91 | 100 | $info = str_replace('&sect;','',$info); |
92 | 101 | $info = str_replace('"','',$info); |
93 | - if ($type == '') $type = NULL; |
|
102 | + if ($type == '') { |
|
103 | + $type = NULL; |
|
104 | + } |
|
94 | 105 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
95 | 106 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
96 | 107 | try { |
@@ -106,7 +117,9 @@ discard block |
||
106 | 117 | $info = str_replace('^','<br />',$info); |
107 | 118 | $info = str_replace('&sect;','',$info); |
108 | 119 | $info = str_replace('"','',$info); |
109 | - if ($type == '') $type = NULL; |
|
120 | + if ($type == '') { |
|
121 | + $type = NULL; |
|
122 | + } |
|
110 | 123 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
111 | 124 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
112 | 125 | try { |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection.'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Marine = new Marine($this->db); |
90 | 97 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | |
95 | 107 | //$country = $over_country; |
96 | 108 | // Route is not added in marine_archive |
@@ -593,7 +605,9 @@ discard block |
||
593 | 605 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
594 | 606 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
595 | 607 | $translate = $Translation->ident2icao($q_item); |
596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
608 | + if ($translate != $q_item) { |
|
609 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
610 | + } |
|
597 | 611 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
598 | 612 | $additional_query .= ")"; |
599 | 613 | } |
@@ -811,7 +825,9 @@ discard block |
||
811 | 825 | date_default_timezone_set($globalTimezone); |
812 | 826 | $datetime = new DateTime(); |
813 | 827 | $offset = $datetime->format('P'); |
814 | - } else $offset = '+00:00'; |
|
828 | + } else { |
|
829 | + $offset = '+00:00'; |
|
830 | + } |
|
815 | 831 | |
816 | 832 | |
817 | 833 | if ($date_array[1] != "") |
@@ -1087,9 +1103,13 @@ discard block |
||
1087 | 1103 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1088 | 1104 | } |
1089 | 1105 | } |
1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1106 | + if ($sincedate != '') { |
|
1107 | + $query .= "AND date > '".$sincedate."' "; |
|
1108 | + } |
|
1091 | 1109 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1092 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1110 | + if ($limit) { |
|
1111 | + $query .= " LIMIT 0,10"; |
|
1112 | + } |
|
1093 | 1113 | |
1094 | 1114 | |
1095 | 1115 | $sth = $this->db->prepare($query); |
@@ -1133,9 +1153,13 @@ discard block |
||
1133 | 1153 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1134 | 1154 | } |
1135 | 1155 | } |
1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1156 | + if ($sincedate != '') { |
|
1157 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1158 | + } |
|
1137 | 1159 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1138 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1160 | + if ($limit) { |
|
1161 | + $query .= " LIMIT 0,10"; |
|
1162 | + } |
|
1139 | 1163 | |
1140 | 1164 | |
1141 | 1165 | $sth = $this->db->prepare($query); |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection.'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Tracker = new Tracker($this->db); |
90 | 97 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | // Route is not added in tracker_archive |
95 | 107 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
96 | 108 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -589,7 +601,9 @@ discard block |
||
589 | 601 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
590 | 602 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
591 | 603 | $translate = $Translation->ident2icao($q_item); |
592 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
604 | + if ($translate != $q_item) { |
|
605 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
606 | + } |
|
593 | 607 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
594 | 608 | $additional_query .= ")"; |
595 | 609 | } |
@@ -807,7 +821,9 @@ discard block |
||
807 | 821 | date_default_timezone_set($globalTimezone); |
808 | 822 | $datetime = new DateTime(); |
809 | 823 | $offset = $datetime->format('P'); |
810 | - } else $offset = '+00:00'; |
|
824 | + } else { |
|
825 | + $offset = '+00:00'; |
|
826 | + } |
|
811 | 827 | |
812 | 828 | |
813 | 829 | if ($date_array[1] != "") |
@@ -1083,9 +1099,13 @@ discard block |
||
1083 | 1099 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1084 | 1100 | } |
1085 | 1101 | } |
1086 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1102 | + if ($sincedate != '') { |
|
1103 | + $query .= "AND date > '".$sincedate."' "; |
|
1104 | + } |
|
1087 | 1105 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1088 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1106 | + if ($limit) { |
|
1107 | + $query .= " LIMIT 0,10"; |
|
1108 | + } |
|
1089 | 1109 | |
1090 | 1110 | |
1091 | 1111 | $sth = $this->db->prepare($query); |
@@ -1129,9 +1149,13 @@ discard block |
||
1129 | 1149 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1130 | 1150 | } |
1131 | 1151 | } |
1132 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1152 | + if ($sincedate != '') { |
|
1153 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1154 | + } |
|
1133 | 1155 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1134 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1156 | + if ($limit) { |
|
1157 | + $query .= " LIMIT 0,10"; |
|
1158 | + } |
|
1135 | 1159 | |
1136 | 1160 | |
1137 | 1161 | $sth = $this->db->prepare($query); |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | public function __construct($dbc = null) { |
8 | 8 | $Connection = new Connection($dbc); |
9 | 9 | $this->db = $Connection->db; |
10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
10 | + if ($this->db === null) { |
|
11 | + die('Error: No DB connection.'); |
|
12 | + } |
|
11 | 13 | } |
12 | 14 | |
13 | 15 | public function getAllLocationInfo() { |
@@ -102,7 +104,9 @@ discard block |
||
102 | 104 | } |
103 | 105 | |
104 | 106 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
105 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
107 | + if ($last_seen == '') { |
|
108 | + $last_seen = date('Y-m-d H:i:s'); |
|
109 | + } |
|
106 | 110 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
107 | 111 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
108 | 112 | try { |
@@ -114,7 +118,9 @@ discard block |
||
114 | 118 | } |
115 | 119 | |
116 | 120 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
117 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
121 | + if ($last_seen == '') { |
|
122 | + $last_seen = date('Y-m-d H:i:s'); |
|
123 | + } |
|
118 | 124 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
119 | 125 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
120 | 126 | try { |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | } |
138 | 144 | |
139 | 145 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
140 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
146 | + if ($last_seen == '') { |
|
147 | + $last_seen = date('Y-m-d H:i:s'); |
|
148 | + } |
|
141 | 149 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
142 | 150 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
143 | 151 | try { |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | public function __construct($dbc = null,$fromACARSscript = false) { |
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | - if ($this->db === null) die('Error: No DB connection.'); |
|
16 | + if ($this->db === null) { |
|
17 | + die('Error: No DB connection.'); |
|
18 | + } |
|
17 | 19 | if ($fromACARSscript) { |
18 | 20 | $this->fromACARSscript = true; |
19 | 21 | $this->SI = new SpotterImport($this->db); |
@@ -27,14 +29,19 @@ discard block |
||
27 | 29 | */ |
28 | 30 | public function ident2icao($ident) { |
29 | 31 | if (substr($ident,0,2) == 'AF') { |
30 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
32 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
33 | + $icao = $ident; |
|
34 | + } else { |
|
35 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
36 | + } |
|
32 | 37 | } else { |
33 | 38 | $Spotter = new Spotter($this->db); |
34 | 39 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
35 | 40 | if (isset($identicao[0])) { |
36 | 41 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
37 | - } else $icao = $ident; |
|
42 | + } else { |
|
43 | + $icao = $ident; |
|
44 | + } |
|
38 | 45 | } |
39 | 46 | return $icao; |
40 | 47 | } |
@@ -107,14 +114,24 @@ discard block |
||
107 | 114 | $message = ''; |
108 | 115 | $result = array(); |
109 | 116 | $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
110 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
112 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
117 | + if ($n == 0) { |
|
118 | + $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
119 | + } |
|
120 | + if ($n == 0) { |
|
121 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
122 | + } |
|
123 | + if ($n == 0) { |
|
124 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
125 | + } |
|
113 | 126 | if ($n != 0) { |
114 | 127 | $registration = str_replace('.','',$registration); |
115 | 128 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
116 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
117 | - } else $message = $data; |
|
129 | + if ($globalDebug) { |
|
130 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
131 | + } |
|
132 | + } else { |
|
133 | + $message = $data; |
|
134 | + } |
|
118 | 135 | $decode = array(); |
119 | 136 | $found = false; |
120 | 137 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -134,12 +151,21 @@ discard block |
||
134 | 151 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
135 | 152 | $latitude = $la / 10000.0; |
136 | 153 | $longitude = $ln / 10000.0; |
137 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
138 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
154 | + if ($lac == 'S') { |
|
155 | + $latitude = '-'.$latitude; |
|
156 | + } |
|
157 | + if ($lnc == 'W') { |
|
158 | + $longitude = '-'.$longitude; |
|
159 | + } |
|
139 | 160 | // Temp not always available |
140 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
141 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
161 | + if ($globalDebug) { |
|
162 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
163 | + } |
|
164 | + if ($temp == '') { |
|
165 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
166 | + } else { |
|
167 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
168 | + } |
|
143 | 169 | |
144 | 170 | //$icao = $Translation->checkTranslation($ident); |
145 | 171 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -153,25 +179,35 @@ discard block |
||
153 | 179 | $ahour = ''; |
154 | 180 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
155 | 181 | if ($n == 4 && strlen($darr) == 4) { |
156 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
157 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
158 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
182 | + if ($dhour != '') { |
|
183 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
184 | + } |
|
185 | + if ($ahour != '') { |
|
186 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
187 | + } |
|
188 | + if ($globalDebug) { |
|
189 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
190 | + } |
|
159 | 191 | //$icao = ACARS->ident2icao($ident); |
160 | 192 | //$icao = $Translation->checkTranslation($ident); |
161 | 193 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
162 | 194 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
163 | 195 | $found = true; |
164 | - } |
|
165 | - elseif ($n == 2 || $n == 4) { |
|
166 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
167 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
196 | + } elseif ($n == 2 || $n == 4) { |
|
197 | + if ($dhour != '') { |
|
198 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
199 | + } |
|
200 | + if ($globalDebug) { |
|
201 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
202 | + } |
|
168 | 203 | //$icao = ACARS->ident2icao($ident); |
169 | 204 | //$icao = $Translation->checkTranslation($ident); |
170 | 205 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
171 | 206 | $found = true; |
172 | - } |
|
173 | - elseif ($n == 1) { |
|
174 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
207 | + } elseif ($n == 1) { |
|
208 | + if ($globalDebug) { |
|
209 | + echo 'airport arrival : '.$darr."\n"; |
|
210 | + } |
|
175 | 211 | //$icao = ACARS->ident2icao($ident); |
176 | 212 | //$icao = $Translation->checkTranslation($ident); |
177 | 213 | $decode = array('Arrival airport' => $darr); |
@@ -189,7 +225,9 @@ discard block |
||
189 | 225 | $darr = ''; |
190 | 226 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
191 | 227 | if ($n == 4) { |
192 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
230 | + } |
|
193 | 231 | //$icao = ACARS->ident2icao($ident); |
194 | 232 | //$icao = $Translation->checkTranslation($ident); |
195 | 233 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -223,14 +261,23 @@ discard block |
||
223 | 261 | $apiste = ''; |
224 | 262 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
225 | 263 | if ($n > 8) { |
226 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
228 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
264 | + if ($globalDebug) { |
|
265 | + echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
266 | + } |
|
267 | + if ($dhour != '') { |
|
268 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
269 | + } |
|
270 | + if ($ahour != '') { |
|
271 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
272 | + } |
|
229 | 273 | $icao = trim($aident); |
230 | 274 | |
231 | 275 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
232 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
233 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
276 | + if ($ahour == '') { |
|
277 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
278 | + } else { |
|
279 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
280 | + } |
|
234 | 281 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
235 | 282 | $decode['icao'] = $icao; |
236 | 283 | $found = true; |
@@ -252,9 +299,15 @@ discard block |
||
252 | 299 | $lns = $lns.'.'.$lns; |
253 | 300 | $latitude = $las / 1000.0; |
254 | 301 | $longitude = $lns / 1000.0; |
255 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
256 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
257 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
302 | + if ($lac == 'S') { |
|
303 | + $latitude = '-'.$latitude; |
|
304 | + } |
|
305 | + if ($lnc == 'W') { |
|
306 | + $longitude = '-'.$longitude; |
|
307 | + } |
|
308 | + if ($globalDebug) { |
|
309 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
310 | + } |
|
258 | 311 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
259 | 312 | $found = true; |
260 | 313 | } |
@@ -272,7 +325,9 @@ discard block |
||
272 | 325 | $darr = ''; |
273 | 326 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
274 | 327 | if ($n == 4) { |
275 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
328 | + if ($globalDebug) { |
|
329 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
330 | + } |
|
276 | 331 | //$icao = $Translation->checkTranslation($ident); |
277 | 332 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
278 | 333 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -285,7 +340,9 @@ discard block |
||
285 | 340 | $darr = ''; |
286 | 341 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
287 | 342 | if ($n == 4) { |
288 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
343 | + if ($globalDebug) { |
|
344 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
345 | + } |
|
289 | 346 | //$icao = $Translation->checkTranslation($ident); |
290 | 347 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
291 | 348 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,7 +355,9 @@ discard block |
||
298 | 355 | $darr = ''; |
299 | 356 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
300 | 357 | if ($n == 2) { |
301 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
358 | + if ($globalDebug) { |
|
359 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
360 | + } |
|
302 | 361 | //$icao = $Translation->checkTranslation($ident); |
303 | 362 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
304 | 363 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -312,7 +371,9 @@ discard block |
||
312 | 371 | $darr = ''; |
313 | 372 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
314 | 373 | if ($n == 6) { |
315 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
374 | + if ($globalDebug) { |
|
375 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
376 | + } |
|
316 | 377 | //$icao = $Translation->checkTranslation($ident); |
317 | 378 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
318 | 379 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -325,7 +386,9 @@ discard block |
||
325 | 386 | $darr = ''; |
326 | 387 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
327 | 388 | if ($n == 7) { |
328 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
389 | + if ($globalDebug) { |
|
390 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
391 | + } |
|
329 | 392 | //$icao = $Translation->checkTranslation($ident); |
330 | 393 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
331 | 394 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -353,8 +416,12 @@ discard block |
||
353 | 416 | $decode['icao'] = $icao; |
354 | 417 | $latitude = $las / 100.0; |
355 | 418 | $longitude = $lns / 100.0; |
356 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
357 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
419 | + if ($lac == 'S') { |
|
420 | + $latitude = '-'.$latitude; |
|
421 | + } |
|
422 | + if ($lnc == 'W') { |
|
423 | + $longitude = '-'.$longitude; |
|
424 | + } |
|
358 | 425 | |
359 | 426 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
360 | 427 | $found = true; |
@@ -372,8 +439,12 @@ discard block |
||
372 | 439 | if ($n == 4) { |
373 | 440 | $latitude = $las; |
374 | 441 | $longitude = $lns; |
375 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
376 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
442 | + if ($lac == 'S') { |
|
443 | + $latitude = '-'.$latitude; |
|
444 | + } |
|
445 | + if ($lnc == 'W') { |
|
446 | + $longitude = '-'.$longitude; |
|
447 | + } |
|
377 | 448 | |
378 | 449 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
379 | 450 | $found = true; |
@@ -389,7 +460,9 @@ discard block |
||
389 | 460 | $darr = ''; |
390 | 461 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
391 | 462 | if ($n == 5) { |
392 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
463 | + if ($globalDebug) { |
|
464 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
465 | + } |
|
393 | 466 | //$icao = $Translation->checkTranslation($ident); |
394 | 467 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
395 | 468 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -410,7 +483,9 @@ discard block |
||
410 | 483 | $aident = ''; |
411 | 484 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
412 | 485 | if ($n == 8) { |
413 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
486 | + if ($globalDebug) { |
|
487 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
488 | + } |
|
414 | 489 | $icao = trim($aident); |
415 | 490 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
416 | 491 | $decode['icao'] = $icao; |
@@ -427,7 +502,9 @@ discard block |
||
427 | 502 | $darr = ''; |
428 | 503 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
429 | 504 | if ($n == 5) { |
430 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
505 | + if ($globalDebug) { |
|
506 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
507 | + } |
|
431 | 508 | //$icao = $Translation->checkTranslation($ident); |
432 | 509 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
433 | 510 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -442,7 +519,9 @@ discard block |
||
442 | 519 | $darr = ''; |
443 | 520 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
444 | 521 | if ($n == 3) { |
445 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
522 | + if ($globalDebug) { |
|
523 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
524 | + } |
|
446 | 525 | //$icao = $Translation->checkTranslation($ident); |
447 | 526 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
448 | 527 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -457,7 +536,9 @@ discard block |
||
457 | 536 | $darr = ''; |
458 | 537 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
459 | 538 | if ($n == 3) { |
460 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
539 | + if ($globalDebug) { |
|
540 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
541 | + } |
|
461 | 542 | //$icao = $Translation->checkTranslation($ident); |
462 | 543 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
463 | 544 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -467,7 +548,9 @@ discard block |
||
467 | 548 | if (!$found) { |
468 | 549 | $n = sscanf($message,'MET01%4c',$airport); |
469 | 550 | if ($n == 1) { |
470 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
551 | + if ($globalDebug) { |
|
552 | + echo 'airport name : '.$airport; |
|
553 | + } |
|
471 | 554 | $decode = array('Airport/Waypoint name' => $airport); |
472 | 555 | $found = true; |
473 | 556 | } |
@@ -475,184 +558,126 @@ discard block |
||
475 | 558 | if ($label == 'H1') { |
476 | 559 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
477 | 560 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
478 | - } |
|
479 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
561 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
480 | 562 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
481 | - } |
|
482 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
563 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
483 | 564 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
484 | - } |
|
485 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
565 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
486 | 566 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
487 | - } |
|
488 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
567 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
489 | 568 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
490 | - } |
|
491 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
569 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
492 | 570 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
493 | - } |
|
494 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
571 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
495 | 572 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
496 | - } |
|
497 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
573 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
498 | 574 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
499 | - } |
|
500 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
575 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
501 | 576 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
502 | - } |
|
503 | - elseif (preg_match(':^#CF:',$message)) { |
|
577 | + } elseif (preg_match(':^#CF:',$message)) { |
|
504 | 578 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
505 | - } |
|
506 | - elseif (preg_match(':^#DF:',$message)) { |
|
579 | + } elseif (preg_match(':^#DF:',$message)) { |
|
507 | 580 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
508 | - } |
|
509 | - elseif (preg_match(':^#EC:',$message)) { |
|
581 | + } elseif (preg_match(':^#EC:',$message)) { |
|
510 | 582 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
511 | - } |
|
512 | - elseif (preg_match(':^#EI:',$message)) { |
|
583 | + } elseif (preg_match(':^#EI:',$message)) { |
|
513 | 584 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
514 | - } |
|
515 | - elseif (preg_match(':^#H1:',$message)) { |
|
585 | + } elseif (preg_match(':^#H1:',$message)) { |
|
516 | 586 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
517 | - } |
|
518 | - elseif (preg_match(':^#H2:',$message)) { |
|
587 | + } elseif (preg_match(':^#H2:',$message)) { |
|
519 | 588 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
520 | - } |
|
521 | - elseif (preg_match(':^#HD:',$message)) { |
|
589 | + } elseif (preg_match(':^#HD:',$message)) { |
|
522 | 590 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
523 | - } |
|
524 | - elseif (preg_match(':^#M1:',$message)) { |
|
591 | + } elseif (preg_match(':^#M1:',$message)) { |
|
525 | 592 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
526 | - } |
|
527 | - elseif (preg_match(':^#M2:',$message)) { |
|
593 | + } elseif (preg_match(':^#M2:',$message)) { |
|
528 | 594 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
529 | - } |
|
530 | - elseif (preg_match(':^#M3:',$message)) { |
|
595 | + } elseif (preg_match(':^#M3:',$message)) { |
|
531 | 596 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
532 | - } |
|
533 | - elseif (preg_match(':^#MD:',$message)) { |
|
597 | + } elseif (preg_match(':^#MD:',$message)) { |
|
534 | 598 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
535 | - } |
|
536 | - elseif (preg_match(':^#PS:',$message)) { |
|
599 | + } elseif (preg_match(':^#PS:',$message)) { |
|
537 | 600 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
538 | - } |
|
539 | - elseif (preg_match(':^#S1:',$message)) { |
|
601 | + } elseif (preg_match(':^#S1:',$message)) { |
|
540 | 602 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
541 | - } |
|
542 | - elseif (preg_match(':^#S2:',$message)) { |
|
603 | + } elseif (preg_match(':^#S2:',$message)) { |
|
543 | 604 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
544 | - } |
|
545 | - elseif (preg_match(':^#SD:',$message)) { |
|
605 | + } elseif (preg_match(':^#SD:',$message)) { |
|
546 | 606 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
547 | - } |
|
548 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
607 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
549 | 608 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
550 | - } |
|
551 | - elseif (preg_match(':^#WO:',$message)) { |
|
609 | + } elseif (preg_match(':^#WO:',$message)) { |
|
552 | 610 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
553 | - } |
|
554 | - elseif (preg_match(':^#A1:',$message)) { |
|
611 | + } elseif (preg_match(':^#A1:',$message)) { |
|
555 | 612 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
556 | - } |
|
557 | - elseif (preg_match(':^#A3:',$message)) { |
|
613 | + } elseif (preg_match(':^#A3:',$message)) { |
|
558 | 614 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
559 | - } |
|
560 | - elseif (preg_match(':^#A4:',$message)) { |
|
615 | + } elseif (preg_match(':^#A4:',$message)) { |
|
561 | 616 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
562 | - } |
|
563 | - elseif (preg_match(':^#A6:',$message)) { |
|
617 | + } elseif (preg_match(':^#A6:',$message)) { |
|
564 | 618 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
565 | - } |
|
566 | - elseif (preg_match(':^#A8:',$message)) { |
|
619 | + } elseif (preg_match(':^#A8:',$message)) { |
|
567 | 620 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
568 | - } |
|
569 | - elseif (preg_match(':^#A9:',$message)) { |
|
621 | + } elseif (preg_match(':^#A9:',$message)) { |
|
570 | 622 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
571 | - } |
|
572 | - elseif (preg_match(':^#A0:',$message)) { |
|
623 | + } elseif (preg_match(':^#A0:',$message)) { |
|
573 | 624 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
574 | - } |
|
575 | - elseif (preg_match(':^#AA:',$message)) { |
|
625 | + } elseif (preg_match(':^#AA:',$message)) { |
|
576 | 626 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
577 | - } |
|
578 | - elseif (preg_match(':^#AB:',$message)) { |
|
627 | + } elseif (preg_match(':^#AB:',$message)) { |
|
579 | 628 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
580 | - } |
|
581 | - elseif (preg_match(':^#AC:',$message)) { |
|
629 | + } elseif (preg_match(':^#AC:',$message)) { |
|
582 | 630 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
583 | - } |
|
584 | - elseif (preg_match(':^#AD:',$message)) { |
|
631 | + } elseif (preg_match(':^#AD:',$message)) { |
|
585 | 632 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
586 | - } |
|
587 | - elseif (preg_match(':^#AF:',$message)) { |
|
633 | + } elseif (preg_match(':^#AF:',$message)) { |
|
588 | 634 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
589 | - } |
|
590 | - elseif (preg_match(':^#B1:',$message)) { |
|
635 | + } elseif (preg_match(':^#B1:',$message)) { |
|
591 | 636 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
592 | - } |
|
593 | - elseif (preg_match(':^#B2:',$message)) { |
|
637 | + } elseif (preg_match(':^#B2:',$message)) { |
|
594 | 638 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
595 | - } |
|
596 | - elseif (preg_match(':^#B3:',$message)) { |
|
639 | + } elseif (preg_match(':^#B3:',$message)) { |
|
597 | 640 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
598 | - } |
|
599 | - elseif (preg_match(':^#B4:',$message)) { |
|
641 | + } elseif (preg_match(':^#B4:',$message)) { |
|
600 | 642 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
601 | - } |
|
602 | - elseif (preg_match(':^#B6:',$message)) { |
|
643 | + } elseif (preg_match(':^#B6:',$message)) { |
|
603 | 644 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
604 | - } |
|
605 | - elseif (preg_match(':^#B8:',$message)) { |
|
645 | + } elseif (preg_match(':^#B8:',$message)) { |
|
606 | 646 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
607 | - } |
|
608 | - elseif (preg_match(':^#B9:',$message)) { |
|
647 | + } elseif (preg_match(':^#B9:',$message)) { |
|
609 | 648 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
610 | - } |
|
611 | - elseif (preg_match(':^#B0:',$message)) { |
|
649 | + } elseif (preg_match(':^#B0:',$message)) { |
|
612 | 650 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
613 | - } |
|
614 | - elseif (preg_match(':^#BA:',$message)) { |
|
651 | + } elseif (preg_match(':^#BA:',$message)) { |
|
615 | 652 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
616 | - } |
|
617 | - elseif (preg_match(':^#BB:',$message)) { |
|
653 | + } elseif (preg_match(':^#BB:',$message)) { |
|
618 | 654 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
619 | - } |
|
620 | - elseif (preg_match(':^#BC:',$message)) { |
|
655 | + } elseif (preg_match(':^#BC:',$message)) { |
|
621 | 656 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
622 | - } |
|
623 | - elseif (preg_match(':^#BD:',$message)) { |
|
657 | + } elseif (preg_match(':^#BD:',$message)) { |
|
624 | 658 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
625 | - } |
|
626 | - elseif (preg_match(':^#BE:',$message)) { |
|
659 | + } elseif (preg_match(':^#BE:',$message)) { |
|
627 | 660 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
628 | - } |
|
629 | - elseif (preg_match(':^#BF:',$message)) { |
|
661 | + } elseif (preg_match(':^#BF:',$message)) { |
|
630 | 662 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
631 | - } |
|
632 | - elseif (preg_match(':^#H3:',$message)) { |
|
663 | + } elseif (preg_match(':^#H3:',$message)) { |
|
633 | 664 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
634 | 665 | } |
635 | 666 | } |
636 | 667 | if ($label == '10') { |
637 | 668 | if (preg_match(':^DTO01:',$message)) { |
638 | 669 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
639 | - } |
|
640 | - elseif (preg_match(':^AIS01:',$message)) { |
|
670 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
641 | 671 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
642 | - } |
|
643 | - elseif (preg_match(':^FTX01:',$message)) { |
|
672 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
644 | 673 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
645 | - } |
|
646 | - elseif (preg_match(':^FPL01:',$message)) { |
|
674 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
647 | 675 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
648 | - } |
|
649 | - elseif (preg_match(':^WAB01:',$message)) { |
|
676 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
650 | 677 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
651 | - } |
|
652 | - elseif (preg_match(':^MET01:',$message)) { |
|
678 | + } elseif (preg_match(':^MET01:',$message)) { |
|
653 | 679 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
654 | - } |
|
655 | - elseif (preg_match(':^WAB02:',$message)) { |
|
680 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
656 | 681 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
657 | 682 | } |
658 | 683 | } |
@@ -667,38 +692,28 @@ discard block |
||
667 | 692 | $vsta = array('Version' => $version); |
668 | 693 | if ($state == 'E') { |
669 | 694 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
670 | - } |
|
671 | - elseif ($state == 'L') { |
|
695 | + } elseif ($state == 'L') { |
|
672 | 696 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
673 | - } |
|
674 | - else { |
|
697 | + } else { |
|
675 | 698 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
676 | 699 | } |
677 | 700 | if ($type == 'V') { |
678 | 701 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
679 | - } |
|
680 | - elseif ($type == 'S') { |
|
702 | + } elseif ($type == 'S') { |
|
681 | 703 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
682 | - } |
|
683 | - elseif ($type == 'H') { |
|
704 | + } elseif ($type == 'H') { |
|
684 | 705 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
685 | - } |
|
686 | - elseif ($type == 'G') { |
|
706 | + } elseif ($type == 'G') { |
|
687 | 707 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
688 | - } |
|
689 | - elseif ($type == 'C') { |
|
708 | + } elseif ($type == 'C') { |
|
690 | 709 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
691 | - } |
|
692 | - elseif ($type == '2') { |
|
710 | + } elseif ($type == '2') { |
|
693 | 711 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
694 | - } |
|
695 | - elseif ($type == 'X') { |
|
712 | + } elseif ($type == 'X') { |
|
696 | 713 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
697 | - } |
|
698 | - elseif ($type == 'I') { |
|
714 | + } elseif ($type == 'I') { |
|
699 | 715 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
700 | - } |
|
701 | - else { |
|
716 | + } else { |
|
702 | 717 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
703 | 718 | } |
704 | 719 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -707,7 +722,9 @@ discard block |
||
707 | 722 | } |
708 | 723 | |
709 | 724 | $title = $this->getTitlefromLabel($label); |
710 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
725 | + if ($title != '') { |
|
726 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
727 | + } |
|
711 | 728 | /* |
712 | 729 | // Business jets always use GS0001 |
713 | 730 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -742,31 +759,54 @@ discard block |
||
742 | 759 | $msg = $message['message']; |
743 | 760 | $decode = $message['decode']; |
744 | 761 | $registration = (string)$message['registration']; |
745 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
746 | - else $latitude = ''; |
|
747 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
748 | - else $longitude = ''; |
|
749 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
750 | - else $airicao = ''; |
|
751 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
752 | - else $icao = $Translation->checkTranslation($ident); |
|
762 | + if (isset($decode['latitude'])) { |
|
763 | + $latitude = $decode['latitude']; |
|
764 | + } else { |
|
765 | + $latitude = ''; |
|
766 | + } |
|
767 | + if (isset($decode['longitude'])) { |
|
768 | + $longitude = $decode['longitude']; |
|
769 | + } else { |
|
770 | + $longitude = ''; |
|
771 | + } |
|
772 | + if (isset($decode['airicao'])) { |
|
773 | + $airicao = $decode['airicao']; |
|
774 | + } else { |
|
775 | + $airicao = ''; |
|
776 | + } |
|
777 | + if (isset($decode['icao'])) { |
|
778 | + $icao = $decode['icao']; |
|
779 | + } else { |
|
780 | + $icao = $Translation->checkTranslation($ident); |
|
781 | + } |
|
753 | 782 | $image_array = $Image->getSpotterImage($registration); |
754 | 783 | if (!isset($image_array[0]['registration'])) { |
755 | 784 | $Image->addSpotterImage($registration); |
756 | 785 | } |
757 | 786 | // Business jets always use GS0001 |
758 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
759 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
760 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
761 | - else $decode_json = ''; |
|
787 | + if ($ident != 'GS0001') { |
|
788 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
789 | + } |
|
790 | + if ($globalDebug && isset($info) && $info != '') { |
|
791 | + echo $info; |
|
792 | + } |
|
793 | + if (count($decode) > 0) { |
|
794 | + $decode_json = json_encode($decode); |
|
795 | + } else { |
|
796 | + $decode_json = ''; |
|
797 | + } |
|
762 | 798 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
763 | 799 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
764 | 800 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
765 | 801 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
766 | 802 | } |
767 | 803 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
768 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
769 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
804 | + if (!isset($globalACARSArchive)) { |
|
805 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
806 | + } |
|
807 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
808 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
809 | + } |
|
770 | 810 | if ($globalDebug && count($decode) > 0) { |
771 | 811 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
772 | 812 | } |
@@ -789,7 +829,9 @@ discard block |
||
789 | 829 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
790 | 830 | $Connection = new Connection($this->db); |
791 | 831 | $this->db = $Connection->db; |
792 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
832 | + if ($globalDebug) { |
|
833 | + echo "Test if not already in Live ACARS table..."; |
|
834 | + } |
|
793 | 835 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
794 | 836 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
795 | 837 | try { |
@@ -799,7 +841,9 @@ discard block |
||
799 | 841 | return "error : ".$e->getMessage(); |
800 | 842 | } |
801 | 843 | if ($stht->fetchColumn() == 0) { |
802 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
844 | + if ($globalDebug) { |
|
845 | + echo "Add Live ACARS data..."; |
|
846 | + } |
|
803 | 847 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
804 | 848 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
805 | 849 | try { |
@@ -809,10 +853,14 @@ discard block |
||
809 | 853 | return "error : ".$e->getMessage(); |
810 | 854 | } |
811 | 855 | } else { |
812 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
856 | + if ($globalDebug) { |
|
857 | + echo "Data already in DB...\n"; |
|
858 | + } |
|
813 | 859 | return false; |
814 | 860 | } |
815 | - if ($globalDebug) echo "Done\n"; |
|
861 | + if ($globalDebug) { |
|
862 | + echo "Done\n"; |
|
863 | + } |
|
816 | 864 | return true; |
817 | 865 | } |
818 | 866 | } |
@@ -843,7 +891,9 @@ discard block |
||
843 | 891 | } |
844 | 892 | if ($stht->fetchColumn() == 0) { |
845 | 893 | */ |
846 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
894 | + if ($globalDebug) { |
|
895 | + echo "Add Live ACARS data..."; |
|
896 | + } |
|
847 | 897 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
848 | 898 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
849 | 899 | try { |
@@ -852,7 +902,9 @@ discard block |
||
852 | 902 | } catch(PDOException $e) { |
853 | 903 | return "error : ".$e->getMessage(); |
854 | 904 | } |
855 | - if ($globalDebug) echo "Done\n"; |
|
905 | + if ($globalDebug) { |
|
906 | + echo "Done\n"; |
|
907 | + } |
|
856 | 908 | } |
857 | 909 | } |
858 | 910 | |
@@ -875,8 +927,11 @@ discard block |
||
875 | 927 | return ''; |
876 | 928 | } |
877 | 929 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
878 | - if (count($row) > 0) return $row[0]['title']; |
|
879 | - else return ''; |
|
930 | + if (count($row) > 0) { |
|
931 | + return $row[0]['title']; |
|
932 | + } else { |
|
933 | + return ''; |
|
934 | + } |
|
880 | 935 | } |
881 | 936 | |
882 | 937 | /** |
@@ -895,8 +950,11 @@ discard block |
||
895 | 950 | return array(); |
896 | 951 | } |
897 | 952 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
898 | - if (count($row) > 0) return $row; |
|
899 | - else return array(); |
|
953 | + if (count($row) > 0) { |
|
954 | + return $row; |
|
955 | + } else { |
|
956 | + return array(); |
|
957 | + } |
|
900 | 958 | } |
901 | 959 | |
902 | 960 | /** |
@@ -916,8 +974,11 @@ discard block |
||
916 | 974 | return array(); |
917 | 975 | } |
918 | 976 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
919 | - if (count($row) > 0) return $row[0]; |
|
920 | - else return array(); |
|
977 | + if (count($row) > 0) { |
|
978 | + return $row[0]; |
|
979 | + } else { |
|
980 | + return array(); |
|
981 | + } |
|
921 | 982 | } |
922 | 983 | |
923 | 984 | /** |
@@ -962,19 +1023,35 @@ discard block |
||
962 | 1023 | if ($row['registration'] != '') { |
963 | 1024 | $row['registration'] = str_replace('.','',$row['registration']); |
964 | 1025 | $image_array = $Image->getSpotterImage($row['registration']); |
965 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
966 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
968 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
969 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1026 | + if (count($image_array) > 0) { |
|
1027 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1028 | + } else { |
|
1029 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1030 | + } |
|
1031 | + } else { |
|
1032 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1033 | + } |
|
1034 | + if ($row['registration'] == '') { |
|
1035 | + $row['registration'] = 'NA'; |
|
1036 | + } |
|
1037 | + if ($row['ident'] == '') { |
|
1038 | + $row['ident'] = 'NA'; |
|
1039 | + } |
|
970 | 1040 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
971 | 1041 | if (isset($identicao[0])) { |
972 | 1042 | if (substr($row['ident'],0,2) == 'AF') { |
973 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
975 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1043 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1044 | + $icao = $row['ident']; |
|
1045 | + } else { |
|
1046 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1047 | + } |
|
1048 | + } else { |
|
1049 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1050 | + } |
|
976 | 1051 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
977 | - } else $icao = $row['ident']; |
|
1052 | + } else { |
|
1053 | + $icao = $row['ident']; |
|
1054 | + } |
|
978 | 1055 | $icao = $Translation->checkTranslation($icao,false); |
979 | 1056 | $decode = json_decode($row['decode'],true); |
980 | 1057 | $found = false; |
@@ -999,7 +1076,9 @@ discard block |
||
999 | 1076 | $found = true; |
1000 | 1077 | } |
1001 | 1078 | } |
1002 | - if ($found) $row['decode'] = json_encode($decode); |
|
1079 | + if ($found) { |
|
1080 | + $row['decode'] = json_encode($decode); |
|
1081 | + } |
|
1003 | 1082 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1004 | 1083 | $result[] = $data; |
1005 | 1084 | $i++; |
@@ -1007,8 +1086,9 @@ discard block |
||
1007 | 1086 | if (isset($result)) { |
1008 | 1087 | $result[0]['query_number_rows'] = $i; |
1009 | 1088 | return $result; |
1089 | + } else { |
|
1090 | + return array(); |
|
1010 | 1091 | } |
1011 | - else return array(); |
|
1012 | 1092 | } |
1013 | 1093 | |
1014 | 1094 | /** |
@@ -1057,31 +1137,51 @@ discard block |
||
1057 | 1137 | if ($row['registration'] != '') { |
1058 | 1138 | $row['registration'] = str_replace('.','',$row['registration']); |
1059 | 1139 | $image_array = $Image->getSpotterImage($row['registration']); |
1060 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1061 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1140 | + if (count($image_array) > 0) { |
|
1141 | + $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1142 | + } else { |
|
1143 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1144 | + } |
|
1145 | + } else { |
|
1146 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1147 | + } |
|
1063 | 1148 | $icao = ''; |
1064 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1065 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1149 | + if ($row['registration'] == '') { |
|
1150 | + $row['registration'] = 'NA'; |
|
1151 | + } |
|
1152 | + if ($row['ident'] == '') { |
|
1153 | + $row['ident'] = 'NA'; |
|
1154 | + } |
|
1066 | 1155 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1067 | 1156 | if (isset($identicao[0])) { |
1068 | 1157 | if (substr($row['ident'],0,2) == 'AF') { |
1069 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1071 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1158 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1159 | + $icao = $row['ident']; |
|
1160 | + } else { |
|
1161 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1162 | + } |
|
1163 | + } else { |
|
1164 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1165 | + } |
|
1072 | 1166 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1073 | - } else $icao = $row['ident']; |
|
1167 | + } else { |
|
1168 | + $icao = $row['ident']; |
|
1169 | + } |
|
1074 | 1170 | $icao = $Translation->checkTranslation($icao); |
1075 | 1171 | $decode = json_decode($row['decode'],true); |
1076 | 1172 | $found = false; |
1077 | 1173 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1078 | 1174 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1079 | - if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1175 | + if (isset($airport_info[0]['icao'])) { |
|
1176 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1177 | + } |
|
1080 | 1178 | $found = true; |
1081 | 1179 | } |
1082 | 1180 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1083 | 1181 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1084 | - if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1182 | + if (isset($airport_info[0]['icao'])) { |
|
1183 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1184 | + } |
|
1085 | 1185 | $found = true; |
1086 | 1186 | } |
1087 | 1187 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1091,7 +1191,9 @@ discard block |
||
1091 | 1191 | $found = true; |
1092 | 1192 | } |
1093 | 1193 | } |
1094 | - if ($found) $row['decode'] = json_encode($decode); |
|
1194 | + if ($found) { |
|
1195 | + $row['decode'] = json_encode($decode); |
|
1196 | + } |
|
1095 | 1197 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1096 | 1198 | $result[] = $data; |
1097 | 1199 | $i++; |
@@ -1099,7 +1201,9 @@ discard block |
||
1099 | 1201 | if (isset($result)) { |
1100 | 1202 | $result[0]['query_number_rows'] = $i; |
1101 | 1203 | return $result; |
1102 | - } else return array(); |
|
1204 | + } else { |
|
1205 | + return array(); |
|
1206 | + } |
|
1103 | 1207 | } |
1104 | 1208 | |
1105 | 1209 | /** |
@@ -1115,25 +1219,37 @@ discard block |
||
1115 | 1219 | $ident = trim($ident); |
1116 | 1220 | $Translation = new Translation($this->db); |
1117 | 1221 | $Spotter = new Spotter($this->db); |
1118 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1222 | + if ($globalDebug) { |
|
1223 | + echo "Test if we add ModeS data..."; |
|
1224 | + } |
|
1119 | 1225 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1120 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1121 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1226 | + if ($icao == '') { |
|
1227 | + $icao = $Translation->checkTranslation($ident); |
|
1228 | + } |
|
1229 | + if ($globalDebug) { |
|
1230 | + echo '- Ident : '.$icao.' - '; |
|
1231 | + } |
|
1122 | 1232 | if ($ident == '' || $registration == '') { |
1123 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1233 | + if ($globalDebug) { |
|
1234 | + echo "Ident or registration null, exit\n"; |
|
1235 | + } |
|
1124 | 1236 | return ''; |
1125 | 1237 | } |
1126 | 1238 | $registration = str_replace('.','',$registration); |
1127 | 1239 | $ident = $Translation->ident2icao($ident); |
1128 | 1240 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1129 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1241 | + if ($globalDebug) { |
|
1242 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1243 | + } |
|
1130 | 1244 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
1131 | 1245 | $querysi_values = array(':registration' => $registration); |
1132 | 1246 | try { |
1133 | 1247 | $sthsi = $this->db->prepare($querysi); |
1134 | 1248 | $sthsi->execute($querysi_values); |
1135 | 1249 | } catch(PDOException $e) { |
1136 | - if ($globalDebug) echo $e->getMessage(); |
|
1250 | + if ($globalDebug) { |
|
1251 | + echo $e->getMessage(); |
|
1252 | + } |
|
1137 | 1253 | return "error : ".$e->getMessage(); |
1138 | 1254 | } |
1139 | 1255 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1141,9 +1257,14 @@ discard block |
||
1141 | 1257 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1142 | 1258 | $Translation = new Translation($this->db); |
1143 | 1259 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1144 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1145 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1146 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1260 | + if ($globalDebug) { |
|
1261 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1262 | + } |
|
1263 | + if ($ident != $trans_ident) { |
|
1264 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1265 | + } elseif ($trans_ident == $ident) { |
|
1266 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1267 | + } |
|
1147 | 1268 | } else { |
1148 | 1269 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1149 | 1270 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1152,32 +1273,46 @@ discard block |
||
1152 | 1273 | $sth = $this->db->prepare($query); |
1153 | 1274 | $sth->execute($query_values); |
1154 | 1275 | } catch(PDOException $e) { |
1155 | - if ($globalDebug) echo $e->getMessage(); |
|
1276 | + if ($globalDebug) { |
|
1277 | + echo $e->getMessage(); |
|
1278 | + } |
|
1156 | 1279 | return "error : ".$e->getMessage(); |
1157 | 1280 | } |
1158 | 1281 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1159 | 1282 | $sth->closeCursor(); |
1160 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1161 | - else $hex = ''; |
|
1283 | + if (isset($result['modes'])) { |
|
1284 | + $hex = $result['modes']; |
|
1285 | + } else { |
|
1286 | + $hex = ''; |
|
1287 | + } |
|
1162 | 1288 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1163 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
1289 | + if ($this->fromACARSscript) { |
|
1290 | + $this->SI->add($SI_data); |
|
1291 | + } |
|
1164 | 1292 | } |
1165 | 1293 | } |
1166 | - if ($globalDebug) echo 'Done'."\n"; |
|
1294 | + if ($globalDebug) { |
|
1295 | + echo 'Done'."\n"; |
|
1296 | + } |
|
1167 | 1297 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1168 | 1298 | $query_values = array(':ident' => $icao); |
1169 | 1299 | try { |
1170 | 1300 | $sth = $this->db->prepare($query); |
1171 | 1301 | $sth->execute($query_values); |
1172 | 1302 | } catch(PDOException $e) { |
1173 | - if ($globalDebug) echo $e->getMessage(); |
|
1303 | + if ($globalDebug) { |
|
1304 | + echo $e->getMessage(); |
|
1305 | + } |
|
1174 | 1306 | return "error : ".$e->getMessage(); |
1175 | 1307 | } |
1176 | 1308 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1177 | 1309 | $sth->closeCursor(); |
1178 | 1310 | if (isset($result['flightaware_id'])) { |
1179 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1180 | - else $ModeS = ''; |
|
1311 | + if (isset($result['ModeS'])) { |
|
1312 | + $ModeS = $result['ModeS']; |
|
1313 | + } else { |
|
1314 | + $ModeS = ''; |
|
1315 | + } |
|
1181 | 1316 | if ($ModeS == '') { |
1182 | 1317 | $id = explode('-',$result['flightaware_id']); |
1183 | 1318 | $ModeS = $id[0]; |
@@ -1190,24 +1325,32 @@ discard block |
||
1190 | 1325 | $sthc = $this->db->prepare($queryc); |
1191 | 1326 | $sthc->execute($queryc_values); |
1192 | 1327 | } catch(PDOException $e) { |
1193 | - if ($globalDebug) echo $e->getMessage(); |
|
1328 | + if ($globalDebug) { |
|
1329 | + echo $e->getMessage(); |
|
1330 | + } |
|
1194 | 1331 | return "error : ".$e->getMessage(); |
1195 | 1332 | } |
1196 | 1333 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1197 | 1334 | $sthc->closeCursor(); |
1198 | 1335 | if (count($row) == 0) { |
1199 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1336 | + if ($globalDebug) { |
|
1337 | + echo " Add to ModeS table - "; |
|
1338 | + } |
|
1200 | 1339 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1201 | 1340 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1202 | 1341 | try { |
1203 | 1342 | $sthi = $this->db->prepare($queryi); |
1204 | 1343 | $sthi->execute($queryi_values); |
1205 | 1344 | } catch(PDOException $e) { |
1206 | - if ($globalDebug) echo $e->getMessage(); |
|
1345 | + if ($globalDebug) { |
|
1346 | + echo $e->getMessage(); |
|
1347 | + } |
|
1207 | 1348 | return "error : ".$e->getMessage(); |
1208 | 1349 | } |
1209 | 1350 | } else { |
1210 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1351 | + if ($globalDebug) { |
|
1352 | + echo " Update ModeS table - "; |
|
1353 | + } |
|
1211 | 1354 | if ($ICAOTypeCode != '') { |
1212 | 1355 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1213 | 1356 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1219,7 +1362,9 @@ discard block |
||
1219 | 1362 | $sthi = $this->db->prepare($queryi); |
1220 | 1363 | $sthi->execute($queryi_values); |
1221 | 1364 | } catch(PDOException $e) { |
1222 | - if ($globalDebug) echo $e->getMessage(); |
|
1365 | + if ($globalDebug) { |
|
1366 | + echo $e->getMessage(); |
|
1367 | + } |
|
1223 | 1368 | return "error : ".$e->getMessage(); |
1224 | 1369 | } |
1225 | 1370 | } |
@@ -1240,7 +1385,9 @@ discard block |
||
1240 | 1385 | return "error : ".$e->getMessage(); |
1241 | 1386 | } |
1242 | 1387 | */ |
1243 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1388 | + if ($globalDebug) { |
|
1389 | + echo " Update Spotter_output table - "; |
|
1390 | + } |
|
1244 | 1391 | if ($ICAOTypeCode != '') { |
1245 | 1392 | if ($globalDBdriver == 'mysql') { |
1246 | 1393 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1251,8 +1398,7 @@ discard block |
||
1251 | 1398 | } else { |
1252 | 1399 | if ($globalDBdriver == 'mysql') { |
1253 | 1400 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1254 | - } |
|
1255 | - elseif ($globalDBdriver == 'pgsql') { |
|
1401 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1256 | 1402 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1257 | 1403 | } |
1258 | 1404 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1261,14 +1407,20 @@ discard block |
||
1261 | 1407 | $sthi = $this->db->prepare($queryi); |
1262 | 1408 | $sthi->execute($queryi_values); |
1263 | 1409 | } catch(PDOException $e) { |
1264 | - if ($globalDebug) echo $e->getMessage(); |
|
1410 | + if ($globalDebug) { |
|
1411 | + echo $e->getMessage(); |
|
1412 | + } |
|
1265 | 1413 | return "error : ".$e->getMessage(); |
1266 | 1414 | } |
1267 | 1415 | } |
1268 | 1416 | } else { |
1269 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1417 | + if ($globalDebug) { |
|
1418 | + echo " Can't find ModeS in spotter_output - "; |
|
1419 | + } |
|
1420 | + } |
|
1421 | + if ($globalDebug) { |
|
1422 | + echo "Done\n"; |
|
1270 | 1423 | } |
1271 | - if ($globalDebug) echo "Done\n"; |
|
1272 | 1424 | } |
1273 | 1425 | } |
1274 | 1426 | ?> |
@@ -73,8 +73,11 @@ discard block |
||
73 | 73 | $globalDBSname = $globalDBname; |
74 | 74 | $globalDBSuser = $globalDBuser; |
75 | 75 | $globalDBSpass = $globalDBpass; |
76 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
77 | - else $globalDBSport = $globalDBport; |
|
76 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
77 | + $globalDBSport = 3306; |
|
78 | + } else { |
|
79 | + $globalDBSport = $globalDBport; |
|
80 | + } |
|
78 | 81 | } else { |
79 | 82 | $DBname = 'default'; |
80 | 83 | $globalDBSdriver = $globalDBdriver; |
@@ -82,8 +85,11 @@ discard block |
||
82 | 85 | $globalDBSname = $globalDBname; |
83 | 86 | $globalDBSuser = $user; |
84 | 87 | $globalDBSpass = $pass; |
85 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
86 | - else $globalDBSport = $globalDBport; |
|
88 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
89 | + $globalDBSport = 3306; |
|
90 | + } else { |
|
91 | + $globalDBSport = $globalDBport; |
|
92 | + } |
|
87 | 93 | } |
88 | 94 | } else { |
89 | 95 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -91,12 +97,19 @@ discard block |
||
91 | 97 | $globalDBSname = $globalDB[$DBname]['name']; |
92 | 98 | $globalDBSuser = $globalDB[$DBname]['user']; |
93 | 99 | $globalDBSpass = $globalDB[$DBname]['pass']; |
94 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
95 | - else $globalDBSport = 3306; |
|
100 | + if (isset($globalDB[$DBname]['port'])) { |
|
101 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
102 | + } else { |
|
103 | + $globalDBSport = 3306; |
|
104 | + } |
|
105 | + } |
|
106 | + if ($globalDBSname == '' || $globalDBSuser == '') { |
|
107 | + return false; |
|
96 | 108 | } |
97 | - if ($globalDBSname == '' || $globalDBSuser == '') return false; |
|
98 | 109 | // Set number of try to connect to DB |
99 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
110 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
111 | + $globalDBretry = 5; |
|
112 | + } |
|
100 | 113 | $i = 0; |
101 | 114 | while (true) { |
102 | 115 | try { |
@@ -105,10 +118,16 @@ discard block |
||
105 | 118 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
106 | 119 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
107 | 120 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
108 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
110 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
111 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
121 | + if (!isset($globalDBTimeOut)) { |
|
122 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
123 | + } else { |
|
124 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | + } |
|
126 | + if (!isset($globalDBPersistent)) { |
|
127 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
128 | + } else { |
|
129 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
130 | + } |
|
112 | 131 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
113 | 132 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
114 | 133 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -122,24 +141,36 @@ discard block |
||
122 | 141 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
123 | 142 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
124 | 143 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
125 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
127 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
128 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
144 | + if (!isset($globalDBTimeOut)) { |
|
145 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
146 | + } else { |
|
147 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
148 | + } |
|
149 | + if (!isset($globalDBPersistent)) { |
|
150 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
151 | + } else { |
|
152 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
153 | + } |
|
129 | 154 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
130 | 155 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
131 | 156 | } |
132 | 157 | break; |
133 | 158 | } catch(PDOException $e) { |
134 | 159 | $i++; |
135 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
160 | + if (isset($globalDebug) && $globalDebug) { |
|
161 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
162 | + } |
|
136 | 163 | //exit; |
137 | - if ($i > $globalDBretry) return false; |
|
164 | + if ($i > $globalDBretry) { |
|
165 | + return false; |
|
166 | + } |
|
138 | 167 | //return false; |
139 | 168 | } |
140 | 169 | sleep(2); |
141 | 170 | } |
142 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
171 | + if ($DBname === 'default') { |
|
172 | + $this->db = $this->dbs['default']; |
|
173 | + } |
|
143 | 174 | return true; |
144 | 175 | } |
145 | 176 | |
@@ -151,7 +182,9 @@ discard block |
||
151 | 182 | } else { |
152 | 183 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
153 | 184 | } |
154 | - if ($this->db == NULL) return false; |
|
185 | + if ($this->db == NULL) { |
|
186 | + return false; |
|
187 | + } |
|
155 | 188 | try { |
156 | 189 | //$Connection = new Connection(); |
157 | 190 | $results = $this->db->query($query); |
@@ -160,22 +193,31 @@ discard block |
||
160 | 193 | } |
161 | 194 | if($results->rowCount()>0) { |
162 | 195 | return true; |
196 | + } else { |
|
197 | + return false; |
|
163 | 198 | } |
164 | - else return false; |
|
165 | 199 | } |
166 | 200 | |
167 | 201 | public function connectionExists() |
168 | 202 | { |
169 | 203 | global $globalDBdriver, $globalDBCheckConnection, $globalNoDB; |
170 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
171 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
204 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
205 | + return true; |
|
206 | + } |
|
207 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
208 | + return true; |
|
209 | + } |
|
172 | 210 | $query = "SELECT 1 + 1"; |
173 | - if ($this->db === null) return false; |
|
211 | + if ($this->db === null) { |
|
212 | + return false; |
|
213 | + } |
|
174 | 214 | try { |
175 | 215 | $sum = @$this->db->query($query); |
176 | 216 | if ($sum instanceof \PDOStatement) { |
177 | 217 | $sum = $sum->fetchColumn(0); |
178 | - } else $sum = 0; |
|
218 | + } else { |
|
219 | + $sum = 0; |
|
220 | + } |
|
179 | 221 | if (intval($sum) !== 2) { |
180 | 222 | return false; |
181 | 223 | } |
@@ -210,8 +252,9 @@ discard block |
||
210 | 252 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
211 | 253 | if($nb[0]['nb'] > 0) { |
212 | 254 | return true; |
255 | + } else { |
|
256 | + return false; |
|
213 | 257 | } |
214 | - else return false; |
|
215 | 258 | } |
216 | 259 | |
217 | 260 | /* |
@@ -261,9 +304,12 @@ discard block |
||
261 | 304 | } |
262 | 305 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
263 | 306 | $sth->closeCursor(); |
264 | - if ($result['nb'] > 0) return true; |
|
265 | - else return false; |
|
266 | -/* } else { |
|
307 | + if ($result['nb'] > 0) { |
|
308 | + return true; |
|
309 | + } else { |
|
310 | + return false; |
|
311 | + } |
|
312 | + /* } else { |
|
267 | 313 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
268 | 314 | try { |
269 | 315 | $results = $this->db->query($query); |
@@ -302,7 +348,9 @@ discard block |
||
302 | 348 | $sth->closeCursor(); |
303 | 349 | return $result['value']; |
304 | 350 | } |
305 | - } else return $version; |
|
351 | + } else { |
|
352 | + return $version; |
|
353 | + } |
|
306 | 354 | } |
307 | 355 | |
308 | 356 | /* |
@@ -311,9 +359,14 @@ discard block |
||
311 | 359 | */ |
312 | 360 | public function latest() { |
313 | 361 | global $globalNoDB; |
314 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
315 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
316 | - else return false; |
|
362 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
363 | + return true; |
|
364 | + } |
|
365 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
366 | + return true; |
|
367 | + } else { |
|
368 | + return false; |
|
369 | + } |
|
317 | 370 | } |
318 | 371 | |
319 | 372 | } |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2159,8 +2287,11 @@ discard block |
||
2159 | 2287 | if ($Connection->tableExists('aircraft')) { |
2160 | 2288 | if (!$Connection->tableExists('config')) { |
2161 | 2289 | $version = '1'; |
2162 | - if ($update) return self::update_from_1(); |
|
2163 | - else return $version; |
|
2290 | + if ($update) { |
|
2291 | + return self::update_from_1(); |
|
2292 | + } else { |
|
2293 | + return $version; |
|
2294 | + } |
|
2164 | 2295 | } else { |
2165 | 2296 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2166 | 2297 | try { |
@@ -2173,187 +2304,326 @@ discard block |
||
2173 | 2304 | if ($update) { |
2174 | 2305 | if ($result['value'] == '2') { |
2175 | 2306 | $error = self::update_from_2(); |
2176 | - if ($error != '') return $error; |
|
2177 | - else return self::check_version(true); |
|
2307 | + if ($error != '') { |
|
2308 | + return $error; |
|
2309 | + } else { |
|
2310 | + return self::check_version(true); |
|
2311 | + } |
|
2178 | 2312 | } elseif ($result['value'] == '3') { |
2179 | 2313 | $error = self::update_from_3(); |
2180 | - if ($error != '') return $error; |
|
2181 | - else return self::check_version(true); |
|
2314 | + if ($error != '') { |
|
2315 | + return $error; |
|
2316 | + } else { |
|
2317 | + return self::check_version(true); |
|
2318 | + } |
|
2182 | 2319 | } elseif ($result['value'] == '4') { |
2183 | 2320 | $error = self::update_from_4(); |
2184 | - if ($error != '') return $error; |
|
2185 | - else return self::check_version(true); |
|
2321 | + if ($error != '') { |
|
2322 | + return $error; |
|
2323 | + } else { |
|
2324 | + return self::check_version(true); |
|
2325 | + } |
|
2186 | 2326 | } elseif ($result['value'] == '5') { |
2187 | 2327 | $error = self::update_from_5(); |
2188 | - if ($error != '') return $error; |
|
2189 | - else return self::check_version(true); |
|
2328 | + if ($error != '') { |
|
2329 | + return $error; |
|
2330 | + } else { |
|
2331 | + return self::check_version(true); |
|
2332 | + } |
|
2190 | 2333 | } elseif ($result['value'] == '6') { |
2191 | 2334 | $error = self::update_from_6(); |
2192 | - if ($error != '') return $error; |
|
2193 | - else return self::check_version(true); |
|
2335 | + if ($error != '') { |
|
2336 | + return $error; |
|
2337 | + } else { |
|
2338 | + return self::check_version(true); |
|
2339 | + } |
|
2194 | 2340 | } elseif ($result['value'] == '7') { |
2195 | 2341 | $error = self::update_from_7(); |
2196 | - if ($error != '') return $error; |
|
2197 | - else return self::check_version(true); |
|
2342 | + if ($error != '') { |
|
2343 | + return $error; |
|
2344 | + } else { |
|
2345 | + return self::check_version(true); |
|
2346 | + } |
|
2198 | 2347 | } elseif ($result['value'] == '8') { |
2199 | 2348 | $error = self::update_from_8(); |
2200 | - if ($error != '') return $error; |
|
2201 | - else return self::check_version(true); |
|
2349 | + if ($error != '') { |
|
2350 | + return $error; |
|
2351 | + } else { |
|
2352 | + return self::check_version(true); |
|
2353 | + } |
|
2202 | 2354 | } elseif ($result['value'] == '9') { |
2203 | 2355 | $error = self::update_from_9(); |
2204 | - if ($error != '') return $error; |
|
2205 | - else return self::check_version(true); |
|
2356 | + if ($error != '') { |
|
2357 | + return $error; |
|
2358 | + } else { |
|
2359 | + return self::check_version(true); |
|
2360 | + } |
|
2206 | 2361 | } elseif ($result['value'] == '10') { |
2207 | 2362 | $error = self::update_from_10(); |
2208 | - if ($error != '') return $error; |
|
2209 | - else return self::check_version(true); |
|
2363 | + if ($error != '') { |
|
2364 | + return $error; |
|
2365 | + } else { |
|
2366 | + return self::check_version(true); |
|
2367 | + } |
|
2210 | 2368 | } elseif ($result['value'] == '11') { |
2211 | 2369 | $error = self::update_from_11(); |
2212 | - if ($error != '') return $error; |
|
2213 | - else return self::check_version(true); |
|
2370 | + if ($error != '') { |
|
2371 | + return $error; |
|
2372 | + } else { |
|
2373 | + return self::check_version(true); |
|
2374 | + } |
|
2214 | 2375 | } elseif ($result['value'] == '12') { |
2215 | 2376 | $error = self::update_from_12(); |
2216 | - if ($error != '') return $error; |
|
2217 | - else return self::check_version(true); |
|
2377 | + if ($error != '') { |
|
2378 | + return $error; |
|
2379 | + } else { |
|
2380 | + return self::check_version(true); |
|
2381 | + } |
|
2218 | 2382 | } elseif ($result['value'] == '13') { |
2219 | 2383 | $error = self::update_from_13(); |
2220 | - if ($error != '') return $error; |
|
2221 | - else return self::check_version(true); |
|
2384 | + if ($error != '') { |
|
2385 | + return $error; |
|
2386 | + } else { |
|
2387 | + return self::check_version(true); |
|
2388 | + } |
|
2222 | 2389 | } elseif ($result['value'] == '14') { |
2223 | 2390 | $error = self::update_from_14(); |
2224 | - if ($error != '') return $error; |
|
2225 | - else return self::check_version(true); |
|
2391 | + if ($error != '') { |
|
2392 | + return $error; |
|
2393 | + } else { |
|
2394 | + return self::check_version(true); |
|
2395 | + } |
|
2226 | 2396 | } elseif ($result['value'] == '15') { |
2227 | 2397 | $error = self::update_from_15(); |
2228 | - if ($error != '') return $error; |
|
2229 | - else return self::check_version(true); |
|
2398 | + if ($error != '') { |
|
2399 | + return $error; |
|
2400 | + } else { |
|
2401 | + return self::check_version(true); |
|
2402 | + } |
|
2230 | 2403 | } elseif ($result['value'] == '16') { |
2231 | 2404 | $error = self::update_from_16(); |
2232 | - if ($error != '') return $error; |
|
2233 | - else return self::check_version(true); |
|
2405 | + if ($error != '') { |
|
2406 | + return $error; |
|
2407 | + } else { |
|
2408 | + return self::check_version(true); |
|
2409 | + } |
|
2234 | 2410 | } elseif ($result['value'] == '17') { |
2235 | 2411 | $error = self::update_from_17(); |
2236 | - if ($error != '') return $error; |
|
2237 | - else return self::check_version(true); |
|
2412 | + if ($error != '') { |
|
2413 | + return $error; |
|
2414 | + } else { |
|
2415 | + return self::check_version(true); |
|
2416 | + } |
|
2238 | 2417 | } elseif ($result['value'] == '18') { |
2239 | 2418 | $error = self::update_from_18(); |
2240 | - if ($error != '') return $error; |
|
2241 | - else return self::check_version(true); |
|
2419 | + if ($error != '') { |
|
2420 | + return $error; |
|
2421 | + } else { |
|
2422 | + return self::check_version(true); |
|
2423 | + } |
|
2242 | 2424 | } elseif ($result['value'] == '19') { |
2243 | 2425 | $error = self::update_from_19(); |
2244 | - if ($error != '') return $error; |
|
2245 | - else return self::check_version(true); |
|
2426 | + if ($error != '') { |
|
2427 | + return $error; |
|
2428 | + } else { |
|
2429 | + return self::check_version(true); |
|
2430 | + } |
|
2246 | 2431 | } elseif ($result['value'] == '20') { |
2247 | 2432 | $error = self::update_from_20(); |
2248 | - if ($error != '') return $error; |
|
2249 | - else return self::check_version(true); |
|
2433 | + if ($error != '') { |
|
2434 | + return $error; |
|
2435 | + } else { |
|
2436 | + return self::check_version(true); |
|
2437 | + } |
|
2250 | 2438 | } elseif ($result['value'] == '21') { |
2251 | 2439 | $error = self::update_from_21(); |
2252 | - if ($error != '') return $error; |
|
2253 | - else return self::check_version(true); |
|
2440 | + if ($error != '') { |
|
2441 | + return $error; |
|
2442 | + } else { |
|
2443 | + return self::check_version(true); |
|
2444 | + } |
|
2254 | 2445 | } elseif ($result['value'] == '22') { |
2255 | 2446 | $error = self::update_from_22(); |
2256 | - if ($error != '') return $error; |
|
2257 | - else return self::check_version(true); |
|
2447 | + if ($error != '') { |
|
2448 | + return $error; |
|
2449 | + } else { |
|
2450 | + return self::check_version(true); |
|
2451 | + } |
|
2258 | 2452 | } elseif ($result['value'] == '23') { |
2259 | 2453 | $error = self::update_from_23(); |
2260 | - if ($error != '') return $error; |
|
2261 | - else return self::check_version(true); |
|
2454 | + if ($error != '') { |
|
2455 | + return $error; |
|
2456 | + } else { |
|
2457 | + return self::check_version(true); |
|
2458 | + } |
|
2262 | 2459 | } elseif ($result['value'] == '24') { |
2263 | 2460 | $error = self::update_from_24(); |
2264 | - if ($error != '') return $error; |
|
2265 | - else return self::check_version(true); |
|
2461 | + if ($error != '') { |
|
2462 | + return $error; |
|
2463 | + } else { |
|
2464 | + return self::check_version(true); |
|
2465 | + } |
|
2266 | 2466 | } elseif ($result['value'] == '25') { |
2267 | 2467 | $error = self::update_from_25(); |
2268 | - if ($error != '') return $error; |
|
2269 | - else return self::check_version(true); |
|
2468 | + if ($error != '') { |
|
2469 | + return $error; |
|
2470 | + } else { |
|
2471 | + return self::check_version(true); |
|
2472 | + } |
|
2270 | 2473 | } elseif ($result['value'] == '26') { |
2271 | 2474 | $error = self::update_from_26(); |
2272 | - if ($error != '') return $error; |
|
2273 | - else return self::check_version(true); |
|
2475 | + if ($error != '') { |
|
2476 | + return $error; |
|
2477 | + } else { |
|
2478 | + return self::check_version(true); |
|
2479 | + } |
|
2274 | 2480 | } elseif ($result['value'] == '27') { |
2275 | 2481 | $error = self::update_from_27(); |
2276 | - if ($error != '') return $error; |
|
2277 | - else return self::check_version(true); |
|
2482 | + if ($error != '') { |
|
2483 | + return $error; |
|
2484 | + } else { |
|
2485 | + return self::check_version(true); |
|
2486 | + } |
|
2278 | 2487 | } elseif ($result['value'] == '28') { |
2279 | 2488 | $error = self::update_from_28(); |
2280 | - if ($error != '') return $error; |
|
2281 | - else return self::check_version(true); |
|
2489 | + if ($error != '') { |
|
2490 | + return $error; |
|
2491 | + } else { |
|
2492 | + return self::check_version(true); |
|
2493 | + } |
|
2282 | 2494 | } elseif ($result['value'] == '29') { |
2283 | 2495 | $error = self::update_from_29(); |
2284 | - if ($error != '') return $error; |
|
2285 | - else return self::check_version(true); |
|
2496 | + if ($error != '') { |
|
2497 | + return $error; |
|
2498 | + } else { |
|
2499 | + return self::check_version(true); |
|
2500 | + } |
|
2286 | 2501 | } elseif ($result['value'] == '30') { |
2287 | 2502 | $error = self::update_from_30(); |
2288 | - if ($error != '') return $error; |
|
2289 | - else return self::check_version(true); |
|
2503 | + if ($error != '') { |
|
2504 | + return $error; |
|
2505 | + } else { |
|
2506 | + return self::check_version(true); |
|
2507 | + } |
|
2290 | 2508 | } elseif ($result['value'] == '31') { |
2291 | 2509 | $error = self::update_from_31(); |
2292 | - if ($error != '') return $error; |
|
2293 | - else return self::check_version(true); |
|
2510 | + if ($error != '') { |
|
2511 | + return $error; |
|
2512 | + } else { |
|
2513 | + return self::check_version(true); |
|
2514 | + } |
|
2294 | 2515 | } elseif ($result['value'] == '32') { |
2295 | 2516 | $error = self::update_from_32(); |
2296 | - if ($error != '') return $error; |
|
2297 | - else return self::check_version(true); |
|
2517 | + if ($error != '') { |
|
2518 | + return $error; |
|
2519 | + } else { |
|
2520 | + return self::check_version(true); |
|
2521 | + } |
|
2298 | 2522 | } elseif ($result['value'] == '33') { |
2299 | 2523 | $error = self::update_from_33(); |
2300 | - if ($error != '') return $error; |
|
2301 | - else return self::check_version(true); |
|
2524 | + if ($error != '') { |
|
2525 | + return $error; |
|
2526 | + } else { |
|
2527 | + return self::check_version(true); |
|
2528 | + } |
|
2302 | 2529 | } elseif ($result['value'] == '34') { |
2303 | 2530 | $error = self::update_from_34(); |
2304 | - if ($error != '') return $error; |
|
2305 | - else return self::check_version(true); |
|
2531 | + if ($error != '') { |
|
2532 | + return $error; |
|
2533 | + } else { |
|
2534 | + return self::check_version(true); |
|
2535 | + } |
|
2306 | 2536 | } elseif ($result['value'] == '35') { |
2307 | 2537 | $error = self::update_from_35(); |
2308 | - if ($error != '') return $error; |
|
2309 | - else return self::check_version(true); |
|
2538 | + if ($error != '') { |
|
2539 | + return $error; |
|
2540 | + } else { |
|
2541 | + return self::check_version(true); |
|
2542 | + } |
|
2310 | 2543 | } elseif ($result['value'] == '36') { |
2311 | 2544 | $error = self::update_from_36(); |
2312 | - if ($error != '') return $error; |
|
2313 | - else return self::check_version(true); |
|
2545 | + if ($error != '') { |
|
2546 | + return $error; |
|
2547 | + } else { |
|
2548 | + return self::check_version(true); |
|
2549 | + } |
|
2314 | 2550 | } elseif ($result['value'] == '37') { |
2315 | 2551 | $error = self::update_from_37(); |
2316 | - if ($error != '') return $error; |
|
2317 | - else return self::check_version(true); |
|
2552 | + if ($error != '') { |
|
2553 | + return $error; |
|
2554 | + } else { |
|
2555 | + return self::check_version(true); |
|
2556 | + } |
|
2318 | 2557 | } elseif ($result['value'] == '38') { |
2319 | 2558 | $error = self::update_from_38(); |
2320 | - if ($error != '') return $error; |
|
2321 | - else return self::check_version(true); |
|
2559 | + if ($error != '') { |
|
2560 | + return $error; |
|
2561 | + } else { |
|
2562 | + return self::check_version(true); |
|
2563 | + } |
|
2322 | 2564 | } elseif ($result['value'] == '39') { |
2323 | 2565 | $error = self::update_from_39(); |
2324 | - if ($error != '') return $error; |
|
2325 | - else return self::check_version(true); |
|
2566 | + if ($error != '') { |
|
2567 | + return $error; |
|
2568 | + } else { |
|
2569 | + return self::check_version(true); |
|
2570 | + } |
|
2326 | 2571 | } elseif ($result['value'] == '40') { |
2327 | 2572 | $error = self::update_from_40(); |
2328 | - if ($error != '') return $error; |
|
2329 | - else return self::check_version(true); |
|
2573 | + if ($error != '') { |
|
2574 | + return $error; |
|
2575 | + } else { |
|
2576 | + return self::check_version(true); |
|
2577 | + } |
|
2330 | 2578 | } elseif ($result['value'] == '41') { |
2331 | 2579 | $error = self::update_from_41(); |
2332 | - if ($error != '') return $error; |
|
2333 | - else return self::check_version(true); |
|
2580 | + if ($error != '') { |
|
2581 | + return $error; |
|
2582 | + } else { |
|
2583 | + return self::check_version(true); |
|
2584 | + } |
|
2334 | 2585 | } elseif ($result['value'] == '42') { |
2335 | 2586 | $error = self::update_from_42(); |
2336 | - if ($error != '') return $error; |
|
2337 | - else return self::check_version(true); |
|
2587 | + if ($error != '') { |
|
2588 | + return $error; |
|
2589 | + } else { |
|
2590 | + return self::check_version(true); |
|
2591 | + } |
|
2338 | 2592 | } elseif ($result['value'] == '43') { |
2339 | 2593 | $error = self::update_from_43(); |
2340 | - if ($error != '') return $error; |
|
2341 | - else return self::check_version(true); |
|
2594 | + if ($error != '') { |
|
2595 | + return $error; |
|
2596 | + } else { |
|
2597 | + return self::check_version(true); |
|
2598 | + } |
|
2342 | 2599 | } elseif ($result['value'] == '44') { |
2343 | 2600 | $error = self::update_from_44(); |
2344 | - if ($error != '') return $error; |
|
2345 | - else return self::check_version(true); |
|
2601 | + if ($error != '') { |
|
2602 | + return $error; |
|
2603 | + } else { |
|
2604 | + return self::check_version(true); |
|
2605 | + } |
|
2346 | 2606 | } elseif ($result['value'] == '45') { |
2347 | 2607 | $error = self::update_from_45(); |
2348 | - if ($error != '') return $error; |
|
2349 | - else return self::check_version(true); |
|
2350 | - } else return ''; |
|
2608 | + if ($error != '') { |
|
2609 | + return $error; |
|
2610 | + } else { |
|
2611 | + return self::check_version(true); |
|
2612 | + } |
|
2613 | + } else { |
|
2614 | + return ''; |
|
2615 | + } |
|
2351 | 2616 | } else { |
2352 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2353 | - else return 0; |
|
2617 | + if (isset($result['value']) && $result['value'] != '') { |
|
2618 | + return $result['value']; |
|
2619 | + } else { |
|
2620 | + return 0; |
|
2621 | + } |
|
2354 | 2622 | } |
2355 | 2623 | } |
2356 | - } else return $version; |
|
2624 | + } else { |
|
2625 | + return $version; |
|
2626 | + } |
|
2357 | 2627 | } |
2358 | 2628 | } |
2359 | 2629 | } |