@@ -5,7 +5,9 @@ |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Route by Airport"); |
7 | 7 | require_once('header.php'); |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | include('statistics-sub-menu.php'); |
10 | 12 | |
11 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -6,11 +6,15 @@ discard block |
||
6 | 6 | $beginpage = microtime(true); |
7 | 7 | $Stats = new Stats(); |
8 | 8 | |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 13 | if ($airline_icao == '' && isset($globalFilter)) { |
12 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
13 | -} |
|
14 | + if (isset($globalFilter['airline'])) { |
|
15 | + $airline_icao = $globalFilter['airline'][0]; |
|
16 | + } |
|
17 | + } |
|
14 | 18 | if ($airline_icao != '' && $airline_icao != 'all') { |
15 | 19 | $Spotter = new Spotter(); |
16 | 20 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -41,14 +45,21 @@ discard block |
||
41 | 45 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
42 | 46 | <div class="column"> |
43 | 47 | <div class="info"> |
44 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
48 | + <h1><?php if (isset($airline_name)) { |
|
49 | + echo _("Statistics for ").$airline_name; |
|
50 | +} else { |
|
51 | + echo _("Statistics"); |
|
52 | +} |
|
53 | +?></h1> |
|
45 | 54 | <?php |
46 | 55 | $last_update = $Stats->getLastStatsUpdate(); |
47 | 56 | //if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->'; |
48 | 57 | if (isset($last_update[0]['value'])) { |
49 | 58 | date_default_timezone_set('UTC'); |
50 | 59 | $lastupdate = strtotime($last_update[0]['value']); |
51 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
60 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
61 | + date_default_timezone_set($globalTimezone); |
|
62 | + } |
|
52 | 63 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
53 | 64 | } |
54 | 65 | ?> |
@@ -100,8 +111,9 @@ discard block |
||
100 | 111 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
101 | 112 | <?php |
102 | 113 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
103 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
104 | - else { |
|
114 | + if (count($aircraft_array) == 0) { |
|
115 | + print _("No data available"); |
|
116 | + } else { |
|
105 | 117 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
106 | 118 | $aircraft_data = ''; |
107 | 119 | foreach($aircraft_array as $aircraft_item) |
@@ -123,11 +135,17 @@ discard block |
||
123 | 135 | <?php |
124 | 136 | if ($year != '' && $month != '') { |
125 | 137 | ?> |
126 | - <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> |
|
138 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
139 | + echo '/'.$airline_icao; |
|
140 | +} |
|
141 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
127 | 142 | <?php |
128 | 143 | } else { |
129 | 144 | ?> |
130 | - <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> |
|
145 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
146 | + echo '/'.$airline_icao; |
|
147 | +} |
|
148 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
131 | 149 | <?php |
132 | 150 | } |
133 | 151 | ?> |
@@ -158,11 +176,15 @@ discard block |
||
158 | 176 | print '</script>'; |
159 | 177 | if ($year != '' && $month != '') { |
160 | 178 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
161 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
179 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
180 | + echo '/'.$airline_icao; |
|
181 | + } |
|
162 | 182 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
163 | 183 | } else { |
164 | 184 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
165 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
185 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
186 | + echo '/'.$airline_icao; |
|
187 | + } |
|
166 | 188 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
167 | 189 | } |
168 | 190 | print '</div>'; |
@@ -186,8 +208,9 @@ discard block |
||
186 | 208 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
187 | 209 | <?php |
188 | 210 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
189 | - if (count($pilot_array) == 0) print _("No data available"); |
|
190 | - else { |
|
211 | + if (count($pilot_array) == 0) { |
|
212 | + print _("No data available"); |
|
213 | + } else { |
|
191 | 214 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
192 | 215 | $pilot_data = ''; |
193 | 216 | foreach($pilot_array as $pilot_item) |
@@ -206,7 +229,9 @@ discard block |
||
206 | 229 | } |
207 | 230 | print '<div class="more">'; |
208 | 231 | print '<a href="'.$globalURL.'/statistics/pilot'; |
209 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
232 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
233 | + echo '/'.$airline_icao; |
|
234 | + } |
|
210 | 235 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
211 | 236 | print '</div>'; |
212 | 237 | ?> |
@@ -220,8 +245,9 @@ discard block |
||
220 | 245 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
221 | 246 | <?php |
222 | 247 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
223 | - if (count($owner_array) == 0) print _("No data available"); |
|
224 | - else { |
|
248 | + if (count($owner_array) == 0) { |
|
249 | + print _("No data available"); |
|
250 | + } else { |
|
225 | 251 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
226 | 252 | $owner_data = ''; |
227 | 253 | foreach($owner_array as $owner_item) |
@@ -240,7 +266,10 @@ discard block |
||
240 | 266 | } |
241 | 267 | ?> |
242 | 268 | <div class="more"> |
243 | - <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> |
|
269 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
270 | + echo '/'.$airline_icao; |
|
271 | +} |
|
272 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
244 | 273 | </div> |
245 | 274 | </div> |
246 | 275 | |
@@ -253,8 +282,9 @@ discard block |
||
253 | 282 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
254 | 283 | <?php |
255 | 284 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
256 | - if (count($flightover_array) == 0) print _("No data available"); |
|
257 | - else { |
|
285 | + if (count($flightover_array) == 0) { |
|
286 | + print _("No data available"); |
|
287 | + } else { |
|
258 | 288 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
259 | 289 | print 'var series = ['; |
260 | 290 | $flightover_data = ''; |
@@ -297,7 +327,10 @@ discard block |
||
297 | 327 | } |
298 | 328 | ?> |
299 | 329 | <div class="more"> |
300 | - <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> |
|
330 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
331 | + echo '/'.$airline_icao; |
|
332 | +} |
|
333 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
301 | 334 | </div> |
302 | 335 | </div> |
303 | 336 | <?php |
@@ -364,7 +397,9 @@ discard block |
||
364 | 397 | print '</script>'; |
365 | 398 | |
366 | 399 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
367 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
400 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
401 | + echo '/'.$airline_icao; |
|
402 | + } |
|
368 | 403 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
369 | 404 | } |
370 | 405 | ?> |
@@ -427,7 +462,9 @@ discard block |
||
427 | 462 | |
428 | 463 | |
429 | 464 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
430 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
465 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
466 | + echo '/'.$airline_icao; |
|
467 | + } |
|
431 | 468 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
432 | 469 | } |
433 | 470 | ?> |
@@ -442,8 +479,9 @@ discard block |
||
442 | 479 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
443 | 480 | <?php |
444 | 481 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
445 | - if (count($year_array) == 0) print _("No data available"); |
|
446 | - else { |
|
482 | + if (count($year_array) == 0) { |
|
483 | + print _("No data available"); |
|
484 | + } else { |
|
447 | 485 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
448 | 486 | $year_data = ''; |
449 | 487 | $year_cnt = ''; |
@@ -463,7 +501,10 @@ discard block |
||
463 | 501 | } |
464 | 502 | ?> |
465 | 503 | <div class="more"> |
466 | - <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> |
|
504 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
505 | + echo '/'.$airline_icao; |
|
506 | +} |
|
507 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
467 | 508 | </div> |
468 | 509 | </div> |
469 | 510 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -471,8 +512,9 @@ discard block |
||
471 | 512 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
472 | 513 | <?php |
473 | 514 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
474 | - if (count($month_array) == 0) print _("No data available"); |
|
475 | - else { |
|
515 | + if (count($month_array) == 0) { |
|
516 | + print _("No data available"); |
|
517 | + } else { |
|
476 | 518 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
477 | 519 | $month_data = ''; |
478 | 520 | $month_cnt = ''; |
@@ -493,7 +535,10 @@ discard block |
||
493 | 535 | } |
494 | 536 | ?> |
495 | 537 | <div class="more"> |
496 | - <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> |
|
538 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
539 | + echo '/'.$airline_icao; |
|
540 | +} |
|
541 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
497 | 542 | </div> |
498 | 543 | </div> |
499 | 544 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -502,8 +547,9 @@ discard block |
||
502 | 547 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
503 | 548 | <?php |
504 | 549 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
505 | - if (empty($date_array)) print _("No data available"); |
|
506 | - else { |
|
550 | + if (empty($date_array)) { |
|
551 | + print _("No data available"); |
|
552 | + } else { |
|
507 | 553 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
508 | 554 | $date_data = ''; |
509 | 555 | $date_cnt = ''; |
@@ -524,7 +570,10 @@ discard block |
||
524 | 570 | } |
525 | 571 | ?> |
526 | 572 | <div class="more"> |
527 | - <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> |
|
573 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
574 | + echo '/'.$airline_icao; |
|
575 | +} |
|
576 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
528 | 577 | </div> |
529 | 578 | </div> |
530 | 579 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -532,8 +581,9 @@ discard block |
||
532 | 581 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
533 | 582 | <?php |
534 | 583 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
535 | - if (empty($hour_array)) print _("No data available"); |
|
536 | - else { |
|
584 | + if (empty($hour_array)) { |
|
585 | + print _("No data available"); |
|
586 | + } else { |
|
537 | 587 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
538 | 588 | $hour_data = ''; |
539 | 589 | $hour_cnt = ''; |
@@ -554,7 +604,10 @@ discard block |
||
554 | 604 | } |
555 | 605 | ?> |
556 | 606 | <div class="more"> |
557 | - <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> |
|
607 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
608 | + echo '/'.$airline_icao; |
|
609 | +} |
|
610 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
558 | 611 | </div> |
559 | 612 | </div> |
560 | 613 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -571,8 +624,9 @@ discard block |
||
571 | 624 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
572 | 625 | <?php |
573 | 626 | $year_array = $Stats->countFatalitiesByYear(); |
574 | - if (count($year_array) == 0) print _("No data available"); |
|
575 | - else { |
|
627 | + if (count($year_array) == 0) { |
|
628 | + print _("No data available"); |
|
629 | + } else { |
|
576 | 630 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
577 | 631 | $year_data = ''; |
578 | 632 | $year_cnt = ''; |
@@ -603,8 +657,9 @@ discard block |
||
603 | 657 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
604 | 658 | <?php |
605 | 659 | $year_array = $Stats->countFatalitiesLast12Months(); |
606 | - if (count($year_array) == 0) print _("No data available"); |
|
607 | - else { |
|
660 | + if (count($year_array) == 0) { |
|
661 | + print _("No data available"); |
|
662 | + } else { |
|
608 | 663 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
609 | 664 | $year_data = ''; |
610 | 665 | $year_cnt = ''; |
@@ -664,8 +719,11 @@ discard block |
||
664 | 719 | $distance = $distance; |
665 | 720 | $unit = 'km'; |
666 | 721 | } |
667 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
668 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
722 | + if (!isset($polar_data)) { |
|
723 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
724 | + } else { |
|
725 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
726 | + } |
|
669 | 727 | } |
670 | 728 | ?> |
671 | 729 | <div class="col-md-6"> |
@@ -717,8 +775,11 @@ discard block |
||
717 | 775 | foreach ($msg as $eachmsg) { |
718 | 776 | //$eachmsg = $msg[0]; |
719 | 777 | $data = $eachmsg['source_data']; |
720 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
721 | - else $max = 500; |
|
778 | + if ($data > 500) { |
|
779 | + $max = (round(($data+100)/100))*100; |
|
780 | + } else { |
|
781 | + $max = 500; |
|
782 | + } |
|
722 | 783 | ?> |
723 | 784 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
724 | 785 | <script> |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($dbc = null) { |
15 | 15 | global $globalFilterName; |
16 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
16 | + if (isset($globalFilterName)) { |
|
17 | + $this->filter_name = $globalFilterName; |
|
18 | + } |
|
17 | 19 | $Connection = new Connection($dbc); |
18 | 20 | $this->db = $Connection->db(); |
19 | 21 | } |
@@ -81,7 +83,9 @@ discard block |
||
81 | 83 | } |
82 | 84 | } |
83 | 85 | public function getAllAirlineNames($filter_name = '') { |
84 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
86 | + if ($filter_name == '') { |
|
87 | + $filter_name = $this->filter_name; |
|
88 | + } |
|
85 | 89 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
86 | 90 | try { |
87 | 91 | $sth = $this->db->prepare($query); |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | return $all; |
94 | 98 | } |
95 | 99 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
96 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
100 | + if ($filter_name == '') { |
|
101 | + $filter_name = $this->filter_name; |
|
102 | + } |
|
97 | 103 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
98 | 104 | try { |
99 | 105 | $sth = $this->db->prepare($query); |
@@ -105,7 +111,9 @@ discard block |
||
105 | 111 | return $all; |
106 | 112 | } |
107 | 113 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
108 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
114 | + if ($filter_name == '') { |
|
115 | + $filter_name = $this->filter_name; |
|
116 | + } |
|
109 | 117 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
110 | 118 | try { |
111 | 119 | $sth = $this->db->prepare($query); |
@@ -117,7 +125,9 @@ discard block |
||
117 | 125 | return $all; |
118 | 126 | } |
119 | 127 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
120 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
128 | + if ($filter_name == '') { |
|
129 | + $filter_name = $this->filter_name; |
|
130 | + } |
|
121 | 131 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
122 | 132 | try { |
123 | 133 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
130 | 140 | } |
131 | 141 | |
132 | 142 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
133 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
143 | + if ($filter_name == '') { |
|
144 | + $filter_name = $this->filter_name; |
|
145 | + } |
|
134 | 146 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
135 | 147 | try { |
136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
143 | 155 | } |
144 | 156 | |
145 | 157 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
146 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | + if ($filter_name == '') { |
|
159 | + $filter_name = $this->filter_name; |
|
160 | + } |
|
147 | 161 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
148 | 162 | try { |
149 | 163 | $sth = $this->db->prepare($query); |
@@ -158,10 +172,15 @@ discard block |
||
158 | 172 | |
159 | 173 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
160 | 174 | global $globalStatsFilters; |
161 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
175 | + if ($filter_name == '') { |
|
176 | + $filter_name = $this->filter_name; |
|
177 | + } |
|
162 | 178 | if ($year == '' && $month == '') { |
163 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
164 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
179 | + if ($limit) { |
|
180 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
181 | + } else { |
|
182 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
183 | + } |
|
165 | 184 | try { |
166 | 185 | $sth = $this->db->prepare($query); |
167 | 186 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -169,7 +188,9 @@ discard block |
||
169 | 188 | echo "error : ".$e->getMessage(); |
170 | 189 | } |
171 | 190 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | - } else $all = array(); |
|
191 | + } else { |
|
192 | + $all = array(); |
|
193 | + } |
|
173 | 194 | if (empty($all)) { |
174 | 195 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
175 | 196 | if ($filter_name != '') { |
@@ -183,10 +204,15 @@ discard block |
||
183 | 204 | } |
184 | 205 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
185 | 206 | global $globalStatsFilters; |
186 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
207 | + if ($filter_name == '') { |
|
208 | + $filter_name = $this->filter_name; |
|
209 | + } |
|
187 | 210 | if ($year == '' && $month == '') { |
188 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
189 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
211 | + if ($limit) { |
|
212 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
213 | + } else { |
|
214 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC"; |
|
215 | + } |
|
190 | 216 | try { |
191 | 217 | $sth = $this->db->prepare($query); |
192 | 218 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -194,7 +220,9 @@ discard block |
||
194 | 220 | echo "error : ".$e->getMessage(); |
195 | 221 | } |
196 | 222 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
197 | - } else $all = array(); |
|
223 | + } else { |
|
224 | + $all = array(); |
|
225 | + } |
|
198 | 226 | if (empty($all)) { |
199 | 227 | $Spotter = new Spotter($this->db); |
200 | 228 | $filters = array(); |
@@ -209,10 +237,15 @@ discard block |
||
209 | 237 | } |
210 | 238 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
211 | 239 | global $globalStatsFilters; |
212 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
240 | + if ($filter_name == '') { |
|
241 | + $filter_name = $this->filter_name; |
|
242 | + } |
|
213 | 243 | if ($year == '' && $month == '') { |
214 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
215 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
244 | + if ($limit) { |
|
245 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
246 | + } else { |
|
247 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
248 | + } |
|
216 | 249 | try { |
217 | 250 | $sth = $this->db->prepare($query); |
218 | 251 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -220,7 +253,9 @@ discard block |
||
220 | 253 | echo "error : ".$e->getMessage(); |
221 | 254 | } |
222 | 255 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
223 | - } else $all = array(); |
|
256 | + } else { |
|
257 | + $all = array(); |
|
258 | + } |
|
224 | 259 | if (empty($all)) { |
225 | 260 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
226 | 261 | if ($filter_name != '') { |
@@ -235,10 +270,15 @@ discard block |
||
235 | 270 | |
236 | 271 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
237 | 272 | global $globalStatsFilters; |
238 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
273 | + if ($filter_name == '') { |
|
274 | + $filter_name = $this->filter_name; |
|
275 | + } |
|
239 | 276 | if ($year == '' && $month == '') { |
240 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
241 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
277 | + if ($limit) { |
|
278 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
279 | + } else { |
|
280 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
281 | + } |
|
242 | 282 | try { |
243 | 283 | $sth = $this->db->prepare($query); |
244 | 284 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -246,7 +286,9 @@ discard block |
||
246 | 286 | echo "error : ".$e->getMessage(); |
247 | 287 | } |
248 | 288 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | - } else $all = array(); |
|
289 | + } else { |
|
290 | + $all = array(); |
|
291 | + } |
|
250 | 292 | if (empty($all)) { |
251 | 293 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
252 | 294 | if ($filter_name != '') { |
@@ -260,9 +302,14 @@ discard block |
||
260 | 302 | } |
261 | 303 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
262 | 304 | global $globalStatsFilters; |
263 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
264 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
265 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
305 | + if ($filter_name == '') { |
|
306 | + $filter_name = $this->filter_name; |
|
307 | + } |
|
308 | + if ($limit) { |
|
309 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
310 | + } else { |
|
311 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
312 | + } |
|
266 | 313 | try { |
267 | 314 | $sth = $this->db->prepare($query); |
268 | 315 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -284,17 +331,29 @@ discard block |
||
284 | 331 | |
285 | 332 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
286 | 333 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
287 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
334 | + if ($filter_name == '') { |
|
335 | + $filter_name = $this->filter_name; |
|
336 | + } |
|
288 | 337 | if ($year == '' && $month == '') { |
289 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
290 | - if ($globalIVAO) $forsource = 'ivao'; |
|
338 | + if ($globalVATSIM) { |
|
339 | + $forsource = 'vatsim'; |
|
340 | + } |
|
341 | + if ($globalIVAO) { |
|
342 | + $forsource = 'ivao'; |
|
343 | + } |
|
291 | 344 | if (isset($forsource)) { |
292 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
293 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
345 | + if ($limit) { |
|
346 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
347 | + } else { |
|
348 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
349 | + } |
|
294 | 350 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
295 | 351 | } else { |
296 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
297 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
352 | + if ($limit) { |
|
353 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
354 | + } else { |
|
355 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
356 | + } |
|
298 | 357 | $query_values = array(':filter_name' => $filter_name); |
299 | 358 | } |
300 | 359 | try { |
@@ -304,7 +363,9 @@ discard block |
||
304 | 363 | echo "error : ".$e->getMessage(); |
305 | 364 | } |
306 | 365 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
307 | - } else $all = array(); |
|
366 | + } else { |
|
367 | + $all = array(); |
|
368 | + } |
|
308 | 369 | if (empty($all)) { |
309 | 370 | $Spotter = new Spotter($this->db); |
310 | 371 | $filters = array(); |
@@ -319,10 +380,15 @@ discard block |
||
319 | 380 | } |
320 | 381 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
321 | 382 | global $globalStatsFilters; |
322 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
383 | + if ($filter_name == '') { |
|
384 | + $filter_name = $this->filter_name; |
|
385 | + } |
|
323 | 386 | if ($year == '' && $month == '') { |
324 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
325 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
387 | + if ($limit) { |
|
388 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
389 | + } else { |
|
390 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
391 | + } |
|
326 | 392 | try { |
327 | 393 | $sth = $this->db->prepare($query); |
328 | 394 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -330,7 +396,9 @@ discard block |
||
330 | 396 | echo "error : ".$e->getMessage(); |
331 | 397 | } |
332 | 398 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | - } else $all = array(); |
|
399 | + } else { |
|
400 | + $all = array(); |
|
401 | + } |
|
334 | 402 | if (empty($all)) { |
335 | 403 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
336 | 404 | if ($filter_name != '') { |
@@ -344,10 +412,15 @@ discard block |
||
344 | 412 | } |
345 | 413 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
346 | 414 | global $globalStatsFilters; |
347 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
415 | + if ($filter_name == '') { |
|
416 | + $filter_name = $this->filter_name; |
|
417 | + } |
|
348 | 418 | if ($year == '' && $month == '') { |
349 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
350 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
419 | + if ($limit) { |
|
420 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
421 | + } else { |
|
422 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
423 | + } |
|
351 | 424 | try { |
352 | 425 | $sth = $this->db->prepare($query); |
353 | 426 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -355,7 +428,9 @@ discard block |
||
355 | 428 | echo "error : ".$e->getMessage(); |
356 | 429 | } |
357 | 430 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
358 | - } else $all = array(); |
|
431 | + } else { |
|
432 | + $all = array(); |
|
433 | + } |
|
359 | 434 | if (empty($all)) { |
360 | 435 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
361 | 436 | if ($filter_name != '') { |
@@ -369,11 +444,16 @@ discard block |
||
369 | 444 | } |
370 | 445 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
371 | 446 | $Connection = new Connection(); |
372 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
447 | + if ($filter_name == '') { |
|
448 | + $filter_name = $this->filter_name; |
|
449 | + } |
|
373 | 450 | if ($Connection->tableExists('countries')) { |
374 | 451 | if ($year == '' && $month == '') { |
375 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
376 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
452 | + if ($limit) { |
|
453 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
454 | + } else { |
|
455 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
456 | + } |
|
377 | 457 | try { |
378 | 458 | $sth = $this->db->prepare($query); |
379 | 459 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -388,17 +468,24 @@ discard block |
||
388 | 468 | } |
389 | 469 | */ |
390 | 470 | return $all; |
391 | - } else return array(); |
|
471 | + } else { |
|
472 | + return array(); |
|
473 | + } |
|
392 | 474 | } else { |
393 | 475 | return array(); |
394 | 476 | } |
395 | 477 | } |
396 | 478 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
397 | 479 | global $globalStatsFilters; |
398 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
480 | + if ($filter_name == '') { |
|
481 | + $filter_name = $this->filter_name; |
|
482 | + } |
|
399 | 483 | if ($year == '' && $month == '') { |
400 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
401 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
484 | + if ($limit) { |
|
485 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
486 | + } else { |
|
487 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
488 | + } |
|
402 | 489 | try { |
403 | 490 | $sth = $this->db->prepare($query); |
404 | 491 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -406,7 +493,9 @@ discard block |
||
406 | 493 | echo "error : ".$e->getMessage(); |
407 | 494 | } |
408 | 495 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
409 | - } else $all = array(); |
|
496 | + } else { |
|
497 | + $all = array(); |
|
498 | + } |
|
410 | 499 | if (empty($all)) { |
411 | 500 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
412 | 501 | if ($filter_name != '') { |
@@ -421,10 +510,15 @@ discard block |
||
421 | 510 | |
422 | 511 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
423 | 512 | global $globalStatsFilters; |
424 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
513 | + if ($filter_name == '') { |
|
514 | + $filter_name = $this->filter_name; |
|
515 | + } |
|
425 | 516 | if ($year == '' && $month == '') { |
426 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
427 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
517 | + if ($limit) { |
|
518 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
519 | + } else { |
|
520 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
521 | + } |
|
428 | 522 | try { |
429 | 523 | $sth = $this->db->prepare($query); |
430 | 524 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -432,7 +526,9 @@ discard block |
||
432 | 526 | echo "error : ".$e->getMessage(); |
433 | 527 | } |
434 | 528 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | - } else $all = array(); |
|
529 | + } else { |
|
530 | + $all = array(); |
|
531 | + } |
|
436 | 532 | if (empty($all)) { |
437 | 533 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
438 | 534 | if ($filter_name != '') { |
@@ -446,10 +542,15 @@ discard block |
||
446 | 542 | } |
447 | 543 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
448 | 544 | global $globalStatsFilters; |
449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
545 | + if ($filter_name == '') { |
|
546 | + $filter_name = $this->filter_name; |
|
547 | + } |
|
450 | 548 | if ($year == '' && $month == '') { |
451 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
452 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
549 | + if ($limit) { |
|
550 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
551 | + } else { |
|
552 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
553 | + } |
|
453 | 554 | try { |
454 | 555 | $sth = $this->db->prepare($query); |
455 | 556 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -457,7 +558,9 @@ discard block |
||
457 | 558 | echo "error : ".$e->getMessage(); |
458 | 559 | } |
459 | 560 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - } else $all = array(); |
|
561 | + } else { |
|
562 | + $all = array(); |
|
563 | + } |
|
461 | 564 | if (empty($all)) { |
462 | 565 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
463 | 566 | if ($filter_name != '') { |
@@ -478,7 +581,9 @@ discard block |
||
478 | 581 | $icao = $value['airport_departure_icao']; |
479 | 582 | if (isset($all[$icao])) { |
480 | 583 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
481 | - } else $all[$icao] = $value; |
|
584 | + } else { |
|
585 | + $all[$icao] = $value; |
|
586 | + } |
|
482 | 587 | } |
483 | 588 | $count = array(); |
484 | 589 | foreach ($all as $key => $row) { |
@@ -490,10 +595,15 @@ discard block |
||
490 | 595 | } |
491 | 596 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
492 | 597 | global $globalStatsFilters; |
493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
598 | + if ($filter_name == '') { |
|
599 | + $filter_name = $this->filter_name; |
|
600 | + } |
|
494 | 601 | if ($year == '' && $month == '') { |
495 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
496 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
602 | + if ($limit) { |
|
603 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
604 | + } else { |
|
605 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
606 | + } |
|
497 | 607 | try { |
498 | 608 | $sth = $this->db->prepare($query); |
499 | 609 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -501,7 +611,9 @@ discard block |
||
501 | 611 | echo "error : ".$e->getMessage(); |
502 | 612 | } |
503 | 613 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
504 | - } else $all = array(); |
|
614 | + } else { |
|
615 | + $all = array(); |
|
616 | + } |
|
505 | 617 | if (empty($all)) { |
506 | 618 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
507 | 619 | if ($filter_name != '') { |
@@ -522,7 +634,9 @@ discard block |
||
522 | 634 | $icao = $value['airport_arrival_icao']; |
523 | 635 | if (isset($all[$icao])) { |
524 | 636 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
525 | - } else $all[$icao] = $value; |
|
637 | + } else { |
|
638 | + $all[$icao] = $value; |
|
639 | + } |
|
526 | 640 | } |
527 | 641 | $count = array(); |
528 | 642 | foreach ($all as $key => $row) { |
@@ -535,13 +649,21 @@ discard block |
||
535 | 649 | } |
536 | 650 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
537 | 651 | global $globalDBdriver, $globalStatsFilters; |
538 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
652 | + if ($filter_name == '') { |
|
653 | + $filter_name = $this->filter_name; |
|
654 | + } |
|
539 | 655 | if ($globalDBdriver == 'mysql') { |
540 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
541 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
656 | + if ($limit) { |
|
657 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
658 | + } else { |
|
659 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
660 | + } |
|
542 | 661 | } else { |
543 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
544 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
662 | + if ($limit) { |
|
663 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
664 | + } else { |
|
665 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
666 | + } |
|
545 | 667 | } |
546 | 668 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
547 | 669 | try { |
@@ -565,7 +687,9 @@ discard block |
||
565 | 687 | |
566 | 688 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
567 | 689 | global $globalStatsFilters; |
568 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
690 | + if ($filter_name == '') { |
|
691 | + $filter_name = $this->filter_name; |
|
692 | + } |
|
569 | 693 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
570 | 694 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
571 | 695 | try { |
@@ -587,7 +711,9 @@ discard block |
||
587 | 711 | } |
588 | 712 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
589 | 713 | global $globalDBdriver, $globalStatsFilters; |
590 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
714 | + if ($filter_name == '') { |
|
715 | + $filter_name = $this->filter_name; |
|
716 | + } |
|
591 | 717 | if ($globalDBdriver == 'mysql') { |
592 | 718 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
593 | 719 | } else { |
@@ -613,7 +739,9 @@ discard block |
||
613 | 739 | } |
614 | 740 | public function countAllDates($stats_airline = '',$filter_name = '') { |
615 | 741 | global $globalStatsFilters; |
616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
742 | + if ($filter_name == '') { |
|
743 | + $filter_name = $this->filter_name; |
|
744 | + } |
|
617 | 745 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
618 | 746 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
619 | 747 | try { |
@@ -635,7 +763,9 @@ discard block |
||
635 | 763 | } |
636 | 764 | public function countAllDatesByAirlines($filter_name = '') { |
637 | 765 | global $globalStatsFilters; |
638 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
766 | + if ($filter_name == '') { |
|
767 | + $filter_name = $this->filter_name; |
|
768 | + } |
|
639 | 769 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
640 | 770 | $query_data = array('filter_name' => $filter_name); |
641 | 771 | try { |
@@ -657,7 +787,9 @@ discard block |
||
657 | 787 | } |
658 | 788 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
659 | 789 | global $globalStatsFilters, $globalDBdriver; |
660 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
790 | + if ($filter_name == '') { |
|
791 | + $filter_name = $this->filter_name; |
|
792 | + } |
|
661 | 793 | if ($globalDBdriver == 'mysql') { |
662 | 794 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
663 | 795 | } else { |
@@ -726,7 +858,9 @@ discard block |
||
726 | 858 | } |
727 | 859 | public function countAllMilitaryMonths($filter_name = '') { |
728 | 860 | global $globalStatsFilters; |
729 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
861 | + if ($filter_name == '') { |
|
862 | + $filter_name = $this->filter_name; |
|
863 | + } |
|
730 | 864 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
731 | 865 | try { |
732 | 866 | $sth = $this->db->prepare($query); |
@@ -747,9 +881,14 @@ discard block |
||
747 | 881 | } |
748 | 882 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
749 | 883 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
750 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
751 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
752 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
884 | + if ($filter_name == '') { |
|
885 | + $filter_name = $this->filter_name; |
|
886 | + } |
|
887 | + if ($limit) { |
|
888 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
889 | + } else { |
|
890 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
891 | + } |
|
753 | 892 | if ($orderby == 'hour') { |
754 | 893 | if ($globalDBdriver == 'mysql') { |
755 | 894 | //$query .= " ORDER BY flight_date ASC"; |
@@ -758,7 +897,9 @@ discard block |
||
758 | 897 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
759 | 898 | } |
760 | 899 | } |
761 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
900 | + if ($orderby == 'count') { |
|
901 | + $query .= " ORDER BY hour_count DESC"; |
|
902 | + } |
|
762 | 903 | try { |
763 | 904 | $sth = $this->db->prepare($query); |
764 | 905 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -779,8 +920,12 @@ discard block |
||
779 | 920 | |
780 | 921 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
781 | 922 | global $globalStatsFilters; |
782 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
783 | - if ($year == '') $year = date('Y'); |
|
923 | + if ($filter_name == '') { |
|
924 | + $filter_name = $this->filter_name; |
|
925 | + } |
|
926 | + if ($year == '') { |
|
927 | + $year = date('Y'); |
|
928 | + } |
|
784 | 929 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
785 | 930 | if (empty($all)) { |
786 | 931 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -795,8 +940,12 @@ discard block |
||
795 | 940 | } |
796 | 941 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
797 | 942 | global $globalStatsFilters; |
798 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
799 | - if ($year == '') $year = date('Y'); |
|
943 | + if ($filter_name == '') { |
|
944 | + $filter_name = $this->filter_name; |
|
945 | + } |
|
946 | + if ($year == '') { |
|
947 | + $year = date('Y'); |
|
948 | + } |
|
800 | 949 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
801 | 950 | if (empty($all)) { |
802 | 951 | $filters = array(); |
@@ -812,8 +961,12 @@ discard block |
||
812 | 961 | } |
813 | 962 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
814 | 963 | global $globalStatsFilters; |
815 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
816 | - if ($year == '') $year = date('Y'); |
|
964 | + if ($filter_name == '') { |
|
965 | + $filter_name = $this->filter_name; |
|
966 | + } |
|
967 | + if ($year == '') { |
|
968 | + $year = date('Y'); |
|
969 | + } |
|
817 | 970 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
818 | 971 | if (empty($all)) { |
819 | 972 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -828,7 +981,9 @@ discard block |
||
828 | 981 | } |
829 | 982 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
830 | 983 | global $globalStatsFilters; |
831 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
984 | + if ($filter_name == '') { |
|
985 | + $filter_name = $this->filter_name; |
|
986 | + } |
|
832 | 987 | if ($year == '' && $month == '') { |
833 | 988 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
834 | 989 | try { |
@@ -839,7 +994,9 @@ discard block |
||
839 | 994 | } |
840 | 995 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
841 | 996 | $all = $result[0]['nb']; |
842 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
997 | + } else { |
|
998 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
999 | + } |
|
843 | 1000 | if (empty($all)) { |
844 | 1001 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
845 | 1002 | if ($filter_name != '') { |
@@ -853,7 +1010,9 @@ discard block |
||
853 | 1010 | } |
854 | 1011 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
855 | 1012 | global $globalStatsFilters; |
856 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1013 | + if ($filter_name == '') { |
|
1014 | + $filter_name = $this->filter_name; |
|
1015 | + } |
|
857 | 1016 | if ($year == '' && $month == '') { |
858 | 1017 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
859 | 1018 | try { |
@@ -864,7 +1023,9 @@ discard block |
||
864 | 1023 | } |
865 | 1024 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
866 | 1025 | $all = $result[0]['nb_airline']; |
867 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1026 | + } else { |
|
1027 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
1028 | + } |
|
868 | 1029 | if (empty($all)) { |
869 | 1030 | $filters = array(); |
870 | 1031 | $filters = array('year' => $year,'month' => $month); |
@@ -879,7 +1040,9 @@ discard block |
||
879 | 1040 | } |
880 | 1041 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
881 | 1042 | global $globalStatsFilters; |
882 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1043 | + if ($filter_name == '') { |
|
1044 | + $filter_name = $this->filter_name; |
|
1045 | + } |
|
883 | 1046 | if ($year == '' && $month == '') { |
884 | 1047 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
885 | 1048 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -907,7 +1070,9 @@ discard block |
||
907 | 1070 | } |
908 | 1071 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
909 | 1072 | global $globalStatsFilters; |
910 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1073 | + if ($filter_name == '') { |
|
1074 | + $filter_name = $this->filter_name; |
|
1075 | + } |
|
911 | 1076 | //if ($year == '') $year = date('Y'); |
912 | 1077 | if ($year == '' && $month == '') { |
913 | 1078 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -936,7 +1101,9 @@ discard block |
||
936 | 1101 | } |
937 | 1102 | |
938 | 1103 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
939 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1104 | + if ($filter_name == '') { |
|
1105 | + $filter_name = $this->filter_name; |
|
1106 | + } |
|
940 | 1107 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
941 | 1108 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
942 | 1109 | try { |
@@ -949,7 +1116,9 @@ discard block |
||
949 | 1116 | return $all; |
950 | 1117 | } |
951 | 1118 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
952 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1119 | + if ($filter_name == '') { |
|
1120 | + $filter_name = $this->filter_name; |
|
1121 | + } |
|
953 | 1122 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
954 | 1123 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
955 | 1124 | try { |
@@ -962,7 +1131,9 @@ discard block |
||
962 | 1131 | return $all; |
963 | 1132 | } |
964 | 1133 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
965 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1134 | + if ($filter_name == '') { |
|
1135 | + $filter_name = $this->filter_name; |
|
1136 | + } |
|
966 | 1137 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
967 | 1138 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
968 | 1139 | try { |
@@ -973,7 +1144,9 @@ discard block |
||
973 | 1144 | } |
974 | 1145 | } |
975 | 1146 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
976 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1147 | + if ($filter_name == '') { |
|
1148 | + $filter_name = $this->filter_name; |
|
1149 | + } |
|
977 | 1150 | global $globalArchiveMonths, $globalDBdriver; |
978 | 1151 | if ($globalDBdriver == 'mysql') { |
979 | 1152 | if ($month == '') { |
@@ -1003,7 +1176,9 @@ discard block |
||
1003 | 1176 | } |
1004 | 1177 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
1005 | 1178 | global $globalArchiveMonths, $globalDBdriver; |
1006 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1179 | + if ($filter_name == '') { |
|
1180 | + $filter_name = $this->filter_name; |
|
1181 | + } |
|
1007 | 1182 | if ($globalDBdriver == 'mysql') { |
1008 | 1183 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
1009 | 1184 | } else { |
@@ -1021,7 +1196,9 @@ discard block |
||
1021 | 1196 | } |
1022 | 1197 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
1023 | 1198 | global $globalArchiveMonths, $globalDBdriver; |
1024 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1199 | + if ($filter_name == '') { |
|
1200 | + $filter_name = $this->filter_name; |
|
1201 | + } |
|
1025 | 1202 | if ($globalDBdriver == 'mysql') { |
1026 | 1203 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
1027 | 1204 | } else { |
@@ -1038,7 +1215,9 @@ discard block |
||
1038 | 1215 | } |
1039 | 1216 | public function getStatsAirlineTotal($filter_name = '') { |
1040 | 1217 | global $globalArchiveMonths, $globalDBdriver; |
1041 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1218 | + if ($filter_name == '') { |
|
1219 | + $filter_name = $this->filter_name; |
|
1220 | + } |
|
1042 | 1221 | if ($globalDBdriver == 'mysql') { |
1043 | 1222 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
1044 | 1223 | } else { |
@@ -1055,7 +1234,9 @@ discard block |
||
1055 | 1234 | } |
1056 | 1235 | public function getStatsOwnerTotal($filter_name = '') { |
1057 | 1236 | global $globalArchiveMonths, $globalDBdriver; |
1058 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1237 | + if ($filter_name == '') { |
|
1238 | + $filter_name = $this->filter_name; |
|
1239 | + } |
|
1059 | 1240 | if ($globalDBdriver == 'mysql') { |
1060 | 1241 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
1061 | 1242 | } else { |
@@ -1072,7 +1253,9 @@ discard block |
||
1072 | 1253 | } |
1073 | 1254 | public function getStatsOwner($owner_name,$filter_name = '') { |
1074 | 1255 | global $globalArchiveMonths, $globalDBdriver; |
1075 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1256 | + if ($filter_name == '') { |
|
1257 | + $filter_name = $this->filter_name; |
|
1258 | + } |
|
1076 | 1259 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | 1260 | try { |
1078 | 1261 | $sth = $this->db->prepare($query); |
@@ -1081,12 +1264,17 @@ discard block |
||
1081 | 1264 | echo "error : ".$e->getMessage(); |
1082 | 1265 | } |
1083 | 1266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1084 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1085 | - else return 0; |
|
1267 | + if (isset($all[0]['cnt'])) { |
|
1268 | + return $all[0]['cnt']; |
|
1269 | + } else { |
|
1270 | + return 0; |
|
1271 | + } |
|
1086 | 1272 | } |
1087 | 1273 | public function getStatsPilotTotal($filter_name = '') { |
1088 | 1274 | global $globalArchiveMonths, $globalDBdriver; |
1089 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1275 | + if ($filter_name == '') { |
|
1276 | + $filter_name = $this->filter_name; |
|
1277 | + } |
|
1090 | 1278 | if ($globalDBdriver == 'mysql') { |
1091 | 1279 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
1092 | 1280 | } else { |
@@ -1103,7 +1291,9 @@ discard block |
||
1103 | 1291 | } |
1104 | 1292 | public function getStatsPilot($pilot,$filter_name = '') { |
1105 | 1293 | global $globalArchiveMonths, $globalDBdriver; |
1106 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1294 | + if ($filter_name == '') { |
|
1295 | + $filter_name = $this->filter_name; |
|
1296 | + } |
|
1107 | 1297 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | 1298 | try { |
1109 | 1299 | $sth = $this->db->prepare($query); |
@@ -1112,13 +1302,18 @@ discard block |
||
1112 | 1302 | echo "error : ".$e->getMessage(); |
1113 | 1303 | } |
1114 | 1304 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1115 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
1116 | - else return 0; |
|
1305 | + if (isset($all[0]['cnt'])) { |
|
1306 | + return $all[0]['cnt']; |
|
1307 | + } else { |
|
1308 | + return 0; |
|
1309 | + } |
|
1117 | 1310 | } |
1118 | 1311 | |
1119 | 1312 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1120 | 1313 | global $globalDBdriver; |
1121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1314 | + if ($filter_name == '') { |
|
1315 | + $filter_name = $this->filter_name; |
|
1316 | + } |
|
1122 | 1317 | if ($globalDBdriver == 'mysql') { |
1123 | 1318 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
1124 | 1319 | } else { |
@@ -1134,7 +1329,9 @@ discard block |
||
1134 | 1329 | } |
1135 | 1330 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
1136 | 1331 | global $globalDBdriver; |
1137 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1332 | + if ($filter_name == '') { |
|
1333 | + $filter_name = $this->filter_name; |
|
1334 | + } |
|
1138 | 1335 | if ($globalDBdriver == 'mysql') { |
1139 | 1336 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1140 | 1337 | } else { |
@@ -1520,10 +1717,14 @@ discard block |
||
1520 | 1717 | $Connection = new Connection(); |
1521 | 1718 | date_default_timezone_set('UTC'); |
1522 | 1719 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
1523 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo 'Update stats !'."\n"; |
|
1722 | + } |
|
1524 | 1723 | if (isset($last_update[0]['value'])) { |
1525 | 1724 | $last_update_day = $last_update[0]['value']; |
1526 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1725 | + } else { |
|
1726 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1727 | + } |
|
1527 | 1728 | $reset = false; |
1528 | 1729 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
1529 | 1730 | if ($globalStatsResetYear) { |
@@ -1532,42 +1733,60 @@ discard block |
||
1532 | 1733 | } |
1533 | 1734 | $Spotter = new Spotter($this->db); |
1534 | 1735 | |
1535 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1736 | + if ($globalDebug) { |
|
1737 | + echo 'Count all aircraft types...'."\n"; |
|
1738 | + } |
|
1536 | 1739 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1537 | 1740 | foreach ($alldata as $number) { |
1538 | 1741 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
1539 | 1742 | } |
1540 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1743 | + if ($globalDebug) { |
|
1744 | + echo 'Count all airlines...'."\n"; |
|
1745 | + } |
|
1541 | 1746 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1542 | 1747 | foreach ($alldata as $number) { |
1543 | 1748 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
1544 | 1749 | } |
1545 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1750 | + if ($globalDebug) { |
|
1751 | + echo 'Count all registrations...'."\n"; |
|
1752 | + } |
|
1546 | 1753 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1547 | 1754 | foreach ($alldata as $number) { |
1548 | 1755 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
1549 | 1756 | } |
1550 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1757 | + if ($globalDebug) { |
|
1758 | + echo 'Count all callsigns...'."\n"; |
|
1759 | + } |
|
1551 | 1760 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1552 | 1761 | foreach ($alldata as $number) { |
1553 | 1762 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1554 | 1763 | } |
1555 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1764 | + if ($globalDebug) { |
|
1765 | + echo 'Count all owners...'."\n"; |
|
1766 | + } |
|
1556 | 1767 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1557 | 1768 | foreach ($alldata as $number) { |
1558 | 1769 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
1559 | 1770 | } |
1560 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo 'Count all pilots...'."\n"; |
|
1773 | + } |
|
1561 | 1774 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1562 | 1775 | foreach ($alldata as $number) { |
1563 | 1776 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
1564 | 1777 | } |
1565 | 1778 | |
1566 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1779 | + if ($globalDebug) { |
|
1780 | + echo 'Count all departure airports...'."\n"; |
|
1781 | + } |
|
1567 | 1782 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1568 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1783 | + if ($globalDebug) { |
|
1784 | + echo 'Count all detected departure airports...'."\n"; |
|
1785 | + } |
|
1569 | 1786 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1570 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1787 | + if ($globalDebug) { |
|
1788 | + echo 'Order departure airports...'."\n"; |
|
1789 | + } |
|
1571 | 1790 | $alldata = array(); |
1572 | 1791 | |
1573 | 1792 | foreach ($pall as $value) { |
@@ -1578,7 +1797,9 @@ discard block |
||
1578 | 1797 | $icao = $value['airport_departure_icao']; |
1579 | 1798 | if (isset($alldata[$icao])) { |
1580 | 1799 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1581 | - } else $alldata[$icao] = $value; |
|
1800 | + } else { |
|
1801 | + $alldata[$icao] = $value; |
|
1802 | + } |
|
1582 | 1803 | } |
1583 | 1804 | $count = array(); |
1584 | 1805 | foreach ($alldata as $key => $row) { |
@@ -1588,11 +1809,17 @@ discard block |
||
1588 | 1809 | foreach ($alldata as $number) { |
1589 | 1810 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
1590 | 1811 | } |
1591 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1812 | + if ($globalDebug) { |
|
1813 | + echo 'Count all arrival airports...'."\n"; |
|
1814 | + } |
|
1592 | 1815 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1593 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1816 | + if ($globalDebug) { |
|
1817 | + echo 'Count all detected arrival airports...'."\n"; |
|
1818 | + } |
|
1594 | 1819 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1595 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1820 | + if ($globalDebug) { |
|
1821 | + echo 'Order arrival airports...'."\n"; |
|
1822 | + } |
|
1596 | 1823 | $alldata = array(); |
1597 | 1824 | foreach ($pall as $value) { |
1598 | 1825 | $icao = $value['airport_arrival_icao']; |
@@ -1602,7 +1829,9 @@ discard block |
||
1602 | 1829 | $icao = $value['airport_arrival_icao']; |
1603 | 1830 | if (isset($alldata[$icao])) { |
1604 | 1831 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1605 | - } else $alldata[$icao] = $value; |
|
1832 | + } else { |
|
1833 | + $alldata[$icao] = $value; |
|
1834 | + } |
|
1606 | 1835 | } |
1607 | 1836 | $count = array(); |
1608 | 1837 | foreach ($alldata as $key => $row) { |
@@ -1613,7 +1842,9 @@ discard block |
||
1613 | 1842 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
1614 | 1843 | } |
1615 | 1844 | if ($Connection->tableExists('countries')) { |
1616 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all flights by countries...'."\n"; |
|
1847 | + } |
|
1617 | 1848 | $SpotterArchive = new SpotterArchive(); |
1618 | 1849 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1619 | 1850 | foreach ($alldata as $number) { |
@@ -1621,7 +1852,9 @@ discard block |
||
1621 | 1852 | } |
1622 | 1853 | } |
1623 | 1854 | |
1624 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
1855 | + if ($globalDebug) { |
|
1856 | + echo 'Count fatalities stats...'."\n"; |
|
1857 | + } |
|
1625 | 1858 | $Accident = new Accident(); |
1626 | 1859 | $this->deleteStatsByType('fatalities_byyear'); |
1627 | 1860 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -1638,46 +1871,66 @@ discard block |
||
1638 | 1871 | // Add by month using getstat if month finish... |
1639 | 1872 | |
1640 | 1873 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1641 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1874 | + if ($globalDebug) { |
|
1875 | + echo 'Count all flights by months...'."\n"; |
|
1876 | + } |
|
1642 | 1877 | $Spotter = new Spotter($this->db); |
1643 | 1878 | $alldata = $Spotter->countAllMonths(); |
1644 | 1879 | $lastyear = false; |
1645 | 1880 | foreach ($alldata as $number) { |
1646 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1881 | + if ($number['year_name'] != date('Y')) { |
|
1882 | + $lastyear = true; |
|
1883 | + } |
|
1647 | 1884 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1648 | 1885 | } |
1649 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1886 | + if ($globalDebug) { |
|
1887 | + echo 'Count all military flights by months...'."\n"; |
|
1888 | + } |
|
1650 | 1889 | $alldata = $Spotter->countAllMilitaryMonths(); |
1651 | 1890 | foreach ($alldata as $number) { |
1652 | 1891 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1653 | 1892 | } |
1654 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1893 | + if ($globalDebug) { |
|
1894 | + echo 'Count all owners by months...'."\n"; |
|
1895 | + } |
|
1655 | 1896 | $alldata = $Spotter->countAllMonthsOwners(); |
1656 | 1897 | foreach ($alldata as $number) { |
1657 | 1898 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1658 | 1899 | } |
1659 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1900 | + if ($globalDebug) { |
|
1901 | + echo 'Count all pilots by months...'."\n"; |
|
1902 | + } |
|
1660 | 1903 | $alldata = $Spotter->countAllMonthsPilots(); |
1661 | 1904 | foreach ($alldata as $number) { |
1662 | 1905 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1663 | 1906 | } |
1664 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1907 | + if ($globalDebug) { |
|
1908 | + echo 'Count all airlines by months...'."\n"; |
|
1909 | + } |
|
1665 | 1910 | $alldata = $Spotter->countAllMonthsAirlines(); |
1666 | 1911 | foreach ($alldata as $number) { |
1667 | 1912 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1668 | 1913 | } |
1669 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1914 | + if ($globalDebug) { |
|
1915 | + echo 'Count all aircrafts by months...'."\n"; |
|
1916 | + } |
|
1670 | 1917 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1671 | 1918 | foreach ($alldata as $number) { |
1672 | 1919 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1673 | 1920 | } |
1674 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1921 | + if ($globalDebug) { |
|
1922 | + echo 'Count all real arrivals by months...'."\n"; |
|
1923 | + } |
|
1675 | 1924 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1676 | 1925 | foreach ($alldata as $number) { |
1677 | 1926 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1678 | 1927 | } |
1679 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1680 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1928 | + if ($globalDebug) { |
|
1929 | + echo 'Airports data...'."\n"; |
|
1930 | + } |
|
1931 | + if ($globalDebug) { |
|
1932 | + echo '...Departure'."\n"; |
|
1933 | + } |
|
1681 | 1934 | $this->deleteStatAirport('daily'); |
1682 | 1935 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1683 | 1936 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1798,44 +2051,62 @@ discard block |
||
1798 | 2051 | // Count by airlines |
1799 | 2052 | echo '--- Stats by airlines ---'."\n"; |
1800 | 2053 | if ($Connection->tableExists('countries')) { |
1801 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
2054 | + if ($globalDebug) { |
|
2055 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
2056 | + } |
|
1802 | 2057 | $SpotterArchive = new SpotterArchive(); |
1803 | 2058 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
1804 | 2059 | foreach ($alldata as $number) { |
1805 | 2060 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
1806 | 2061 | } |
1807 | 2062 | } |
1808 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
2063 | + if ($globalDebug) { |
|
2064 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
2065 | + } |
|
1809 | 2066 | $Spotter = new Spotter($this->db); |
1810 | 2067 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1811 | 2068 | foreach ($alldata as $number) { |
1812 | 2069 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
1813 | 2070 | } |
1814 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
2073 | + } |
|
1815 | 2074 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1816 | 2075 | foreach ($alldata as $number) { |
1817 | 2076 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
1818 | 2077 | } |
1819 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo 'Count all callsigns by airlines...'."\n"; |
|
2080 | + } |
|
1820 | 2081 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1821 | 2082 | foreach ($alldata as $number) { |
1822 | 2083 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
1823 | 2084 | } |
1824 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
2085 | + if ($globalDebug) { |
|
2086 | + echo 'Count all owners by airlines...'."\n"; |
|
2087 | + } |
|
1825 | 2088 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1826 | 2089 | foreach ($alldata as $number) { |
1827 | 2090 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
1828 | 2091 | } |
1829 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
2092 | + if ($globalDebug) { |
|
2093 | + echo 'Count all pilots by airlines...'."\n"; |
|
2094 | + } |
|
1830 | 2095 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1831 | 2096 | foreach ($alldata as $number) { |
1832 | 2097 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
1833 | 2098 | } |
1834 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo 'Count all departure airports by airlines...'."\n"; |
|
2101 | + } |
|
1835 | 2102 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1836 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
2103 | + if ($globalDebug) { |
|
2104 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
2105 | + } |
|
1837 | 2106 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1838 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
2109 | + } |
|
1839 | 2110 | //$alldata = array(); |
1840 | 2111 | foreach ($dall as $value) { |
1841 | 2112 | $icao = $value['airport_departure_icao']; |
@@ -1856,11 +2127,17 @@ discard block |
||
1856 | 2127 | foreach ($alldata as $number) { |
1857 | 2128 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
1858 | 2129 | } |
1859 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
2130 | + if ($globalDebug) { |
|
2131 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
2132 | + } |
|
1860 | 2133 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1861 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2134 | + if ($globalDebug) { |
|
2135 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
2136 | + } |
|
1862 | 2137 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1863 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
2138 | + if ($globalDebug) { |
|
2139 | + echo 'Order arrival airports by airlines...'."\n"; |
|
2140 | + } |
|
1864 | 2141 | //$alldata = array(); |
1865 | 2142 | foreach ($dall as $value) { |
1866 | 2143 | $icao = $value['airport_arrival_icao']; |
@@ -1879,37 +2156,53 @@ discard block |
||
1879 | 2156 | } |
1880 | 2157 | $alldata = $pall; |
1881 | 2158 | foreach ($alldata as $number) { |
1882 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2159 | + if ($number['airline_icao'] != '') { |
|
2160 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
2161 | + } |
|
2162 | + } |
|
2163 | + if ($globalDebug) { |
|
2164 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1883 | 2165 | } |
1884 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1885 | 2166 | $Spotter = new Spotter($this->db); |
1886 | 2167 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1887 | 2168 | $lastyear = false; |
1888 | 2169 | foreach ($alldata as $number) { |
1889 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2170 | + if ($number['year_name'] != date('Y')) { |
|
2171 | + $lastyear = true; |
|
2172 | + } |
|
1890 | 2173 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1891 | 2174 | } |
1892 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo 'Count all owners by months by airlines...'."\n"; |
|
2177 | + } |
|
1893 | 2178 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1894 | 2179 | foreach ($alldata as $number) { |
1895 | 2180 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1896 | 2181 | } |
1897 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
2182 | + if ($globalDebug) { |
|
2183 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
2184 | + } |
|
1898 | 2185 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1899 | 2186 | foreach ($alldata as $number) { |
1900 | 2187 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1901 | 2188 | } |
1902 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
2191 | + } |
|
1903 | 2192 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1904 | 2193 | foreach ($alldata as $number) { |
1905 | 2194 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1906 | 2195 | } |
1907 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2196 | + if ($globalDebug) { |
|
2197 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
2198 | + } |
|
1908 | 2199 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1909 | 2200 | foreach ($alldata as $number) { |
1910 | 2201 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1911 | 2202 | } |
1912 | - if ($globalDebug) echo '...Departure'."\n"; |
|
2203 | + if ($globalDebug) { |
|
2204 | + echo '...Departure'."\n"; |
|
2205 | + } |
|
1913 | 2206 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1914 | 2207 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1915 | 2208 | foreach ($dall as $value) { |
@@ -1932,7 +2225,9 @@ discard block |
||
1932 | 2225 | foreach ($alldata as $number) { |
1933 | 2226 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1934 | 2227 | } |
1935 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2228 | + if ($globalDebug) { |
|
2229 | + echo '...Arrival'."\n"; |
|
2230 | + } |
|
1936 | 2231 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1937 | 2232 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1938 | 2233 | foreach ($dall as $value) { |
@@ -1956,13 +2251,19 @@ discard block |
||
1956 | 2251 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1957 | 2252 | } |
1958 | 2253 | |
1959 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1960 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2254 | + if ($globalDebug) { |
|
2255 | + echo 'Flights data...'."\n"; |
|
2256 | + } |
|
2257 | + if ($globalDebug) { |
|
2258 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2259 | + } |
|
1961 | 2260 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1962 | 2261 | foreach ($alldata as $number) { |
1963 | 2262 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1964 | 2263 | } |
1965 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2264 | + if ($globalDebug) { |
|
2265 | + echo '-> countAllDates...'."\n"; |
|
2266 | + } |
|
1966 | 2267 | //$previousdata = $this->countAllDatesByAirlines(); |
1967 | 2268 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1968 | 2269 | $values = array(); |
@@ -1975,7 +2276,9 @@ discard block |
||
1975 | 2276 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1976 | 2277 | } |
1977 | 2278 | |
1978 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2279 | + if ($globalDebug) { |
|
2280 | + echo '-> countAllHours...'."\n"; |
|
2281 | + } |
|
1979 | 2282 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1980 | 2283 | foreach ($alldata as $number) { |
1981 | 2284 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1983,14 +2286,18 @@ discard block |
||
1983 | 2286 | |
1984 | 2287 | |
1985 | 2288 | // Stats by filters |
1986 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2289 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2290 | + $globalStatsFilters = array(); |
|
2291 | + } |
|
1987 | 2292 | foreach ($globalStatsFilters as $name => $filter) { |
1988 | 2293 | //$filter_name = $filter['name']; |
1989 | 2294 | $filter_name = $name; |
1990 | 2295 | $reset = false; |
1991 | 2296 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1992 | 2297 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
1993 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2298 | + if ($globalDebug) { |
|
2299 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
2300 | + } |
|
1994 | 2301 | $this->deleteOldStats($filter_name); |
1995 | 2302 | unset($last_update); |
1996 | 2303 | } |
@@ -2009,7 +2316,9 @@ discard block |
||
2009 | 2316 | |
2010 | 2317 | |
2011 | 2318 | // Count by filter |
2012 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2319 | + if ($globalDebug) { |
|
2320 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2321 | + } |
|
2013 | 2322 | $Spotter = new Spotter($this->db); |
2014 | 2323 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
2015 | 2324 | foreach ($alldata as $number) { |
@@ -2046,7 +2355,9 @@ discard block |
||
2046 | 2355 | $icao = $value['airport_departure_icao']; |
2047 | 2356 | if (isset($alldata[$icao])) { |
2048 | 2357 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
2049 | - } else $alldata[$icao] = $value; |
|
2358 | + } else { |
|
2359 | + $alldata[$icao] = $value; |
|
2360 | + } |
|
2050 | 2361 | } |
2051 | 2362 | $count = array(); |
2052 | 2363 | foreach ($alldata as $key => $row) { |
@@ -2067,7 +2378,9 @@ discard block |
||
2067 | 2378 | $icao = $value['airport_arrival_icao']; |
2068 | 2379 | if (isset($alldata[$icao])) { |
2069 | 2380 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
2070 | - } else $alldata[$icao] = $value; |
|
2381 | + } else { |
|
2382 | + $alldata[$icao] = $value; |
|
2383 | + } |
|
2071 | 2384 | } |
2072 | 2385 | $count = array(); |
2073 | 2386 | foreach ($alldata as $key => $row) { |
@@ -2081,7 +2394,9 @@ discard block |
||
2081 | 2394 | $alldata = $Spotter->countAllMonths($filter); |
2082 | 2395 | $lastyear = false; |
2083 | 2396 | foreach ($alldata as $number) { |
2084 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2397 | + if ($number['year_name'] != date('Y')) { |
|
2398 | + $lastyear = true; |
|
2399 | + } |
|
2085 | 2400 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
2086 | 2401 | } |
2087 | 2402 | $alldata = $Spotter->countAllMonthsOwners($filter); |
@@ -72,8 +72,11 @@ discard block |
||
72 | 72 | $globalDBSname = $globalDBname; |
73 | 73 | $globalDBSuser = $globalDBuser; |
74 | 74 | $globalDBSpass = $globalDBpass; |
75 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
76 | - else $globalDBSport = $globalDBport; |
|
75 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
76 | + $globalDBSport = 3306; |
|
77 | + } else { |
|
78 | + $globalDBSport = $globalDBport; |
|
79 | + } |
|
77 | 80 | } else { |
78 | 81 | $DBname = 'default'; |
79 | 82 | $globalDBSdriver = $globalDBdriver; |
@@ -81,8 +84,11 @@ discard block |
||
81 | 84 | $globalDBSname = $globalDBname; |
82 | 85 | $globalDBSuser = $user; |
83 | 86 | $globalDBSpass = $pass; |
84 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
85 | - else $globalDBSport = $globalDBport; |
|
87 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
88 | + $globalDBSport = 3306; |
|
89 | + } else { |
|
90 | + $globalDBSport = $globalDBport; |
|
91 | + } |
|
86 | 92 | } |
87 | 93 | } else { |
88 | 94 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -90,11 +96,16 @@ discard block |
||
90 | 96 | $globalDBSname = $globalDB[$DBname]['name']; |
91 | 97 | $globalDBSuser = $globalDB[$DBname]['user']; |
92 | 98 | $globalDBSpass = $globalDB[$DBname]['pass']; |
93 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
94 | - else $globalDBSport = 3306; |
|
99 | + if (isset($globalDB[$DBname]['port'])) { |
|
100 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
101 | + } else { |
|
102 | + $globalDBSport = 3306; |
|
103 | + } |
|
95 | 104 | } |
96 | 105 | // Set number of try to connect to DB |
97 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
106 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
107 | + $globalDBretry = 5; |
|
108 | + } |
|
98 | 109 | $i = 0; |
99 | 110 | while (true) { |
100 | 111 | try { |
@@ -103,10 +114,16 @@ discard block |
||
103 | 114 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
104 | 115 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
105 | 116 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
106 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
107 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
108 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
109 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
117 | + if (!isset($globalDBTimeOut)) { |
|
118 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
119 | + } else { |
|
120 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
121 | + } |
|
122 | + if (!isset($globalDBPersistent)) { |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
124 | + } else { |
|
125 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
126 | + } |
|
110 | 127 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
111 | 128 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
112 | 129 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -120,23 +137,35 @@ discard block |
||
120 | 137 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
121 | 138 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
122 | 139 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
123 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
124 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
125 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
126 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
140 | + if (!isset($globalDBTimeOut)) { |
|
141 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
142 | + } else { |
|
143 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
144 | + } |
|
145 | + if (!isset($globalDBPersistent)) { |
|
146 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
147 | + } else { |
|
148 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
149 | + } |
|
127 | 150 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
128 | 151 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
129 | 152 | } |
130 | 153 | break; |
131 | 154 | } catch(PDOException $e) { |
132 | 155 | $i++; |
133 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
156 | + if (isset($globalDebug) && $globalDebug) { |
|
157 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
158 | + } |
|
134 | 159 | //exit; |
135 | - if ($i > $globalDBretry) return false; |
|
160 | + if ($i > $globalDBretry) { |
|
161 | + return false; |
|
162 | + } |
|
136 | 163 | //return false; |
137 | 164 | } |
138 | 165 | } |
139 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
166 | + if ($DBname === 'default') { |
|
167 | + $this->db = $this->dbs['default']; |
|
168 | + } |
|
140 | 169 | return true; |
141 | 170 | } |
142 | 171 | |
@@ -148,7 +177,9 @@ discard block |
||
148 | 177 | } else { |
149 | 178 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
150 | 179 | } |
151 | - if ($this->db == NULL) return false; |
|
180 | + if ($this->db == NULL) { |
|
181 | + return false; |
|
182 | + } |
|
152 | 183 | try { |
153 | 184 | //$Connection = new Connection(); |
154 | 185 | $results = $this->db->query($query); |
@@ -157,21 +188,28 @@ discard block |
||
157 | 188 | } |
158 | 189 | if($results->rowCount()>0) { |
159 | 190 | return true; |
191 | + } else { |
|
192 | + return false; |
|
160 | 193 | } |
161 | - else return false; |
|
162 | 194 | } |
163 | 195 | |
164 | 196 | public function connectionExists() |
165 | 197 | { |
166 | 198 | global $globalDBdriver, $globalDBCheckConnection; |
167 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
199 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
200 | + return true; |
|
201 | + } |
|
168 | 202 | $query = "SELECT 1 + 1"; |
169 | - if ($this->db === null) return false; |
|
203 | + if ($this->db === null) { |
|
204 | + return false; |
|
205 | + } |
|
170 | 206 | try { |
171 | 207 | $sum = @$this->db->query($query); |
172 | 208 | if ($sum instanceof \PDOStatement) { |
173 | 209 | $sum = $sum->fetchColumn(0); |
174 | - } else $sum = 0; |
|
210 | + } else { |
|
211 | + $sum = 0; |
|
212 | + } |
|
175 | 213 | if (intval($sum) !== 2) { |
176 | 214 | return false; |
177 | 215 | } |
@@ -206,8 +244,9 @@ discard block |
||
206 | 244 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
207 | 245 | if($nb[0]['nb'] > 0) { |
208 | 246 | return true; |
247 | + } else { |
|
248 | + return false; |
|
209 | 249 | } |
210 | - else return false; |
|
211 | 250 | } |
212 | 251 | |
213 | 252 | /* |
@@ -257,9 +296,12 @@ discard block |
||
257 | 296 | } |
258 | 297 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
259 | 298 | $sth->closeCursor(); |
260 | - if ($result['nb'] > 0) return true; |
|
261 | - else return false; |
|
262 | -/* } else { |
|
299 | + if ($result['nb'] > 0) { |
|
300 | + return true; |
|
301 | + } else { |
|
302 | + return false; |
|
303 | + } |
|
304 | + /* } else { |
|
263 | 305 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
264 | 306 | try { |
265 | 307 | $results = $this->db->query($query); |
@@ -298,7 +340,9 @@ discard block |
||
298 | 340 | $sth->closeCursor(); |
299 | 341 | return $result['value']; |
300 | 342 | } |
301 | - } else return $version; |
|
343 | + } else { |
|
344 | + return $version; |
|
345 | + } |
|
302 | 346 | } |
303 | 347 | |
304 | 348 | /* |
@@ -307,9 +351,14 @@ discard block |
||
307 | 351 | */ |
308 | 352 | public function latest() { |
309 | 353 | global $globalNoDB; |
310 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
311 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
312 | - else return false; |
|
354 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
355 | + return true; |
|
356 | + } |
|
357 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
358 | + return true; |
|
359 | + } else { |
|
360 | + return false; |
|
361 | + } |
|
313 | 362 | } |
314 | 363 | |
315 | 364 | } |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
25 | + if ($registration == '' && $aircraft_icao != '') { |
|
26 | + $registration = $aircraft_icao.$airline_icao; |
|
27 | + } |
|
26 | 28 | $registration = trim($registration); |
27 | 29 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
28 | 30 | FROM spotter_image |
@@ -60,8 +62,11 @@ discard block |
||
60 | 62 | public function getExifCopyright($url) { |
61 | 63 | $exif = exif_read_data($url); |
62 | 64 | $copyright = ''; |
63 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
64 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
65 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
66 | + $copyright = $exif['COMPUTED']['copyright']; |
|
67 | + } elseif (isset($exif['copyright'])) { |
|
68 | + $copyright = $exif['copyright']; |
|
69 | + } |
|
65 | 70 | if ($copyright != '') { |
66 | 71 | $copyright = str_replace('Copyright ','',$copyright); |
67 | 72 | $copyright = str_replace('© ','',$copyright); |
@@ -79,18 +84,29 @@ discard block |
||
79 | 84 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
80 | 85 | { |
81 | 86 | global $globalDebug,$globalAircraftImageFetch; |
82 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
87 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
88 | + return ''; |
|
89 | + } |
|
83 | 90 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
84 | 91 | $registration = trim($registration); |
85 | 92 | //getting the aircraft image |
86 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
87 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
88 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
89 | - else return "success"; |
|
93 | + if ($globalDebug && $registration != '') { |
|
94 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
95 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
96 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
97 | + } elseif ($globalDebug && $airline_icao != '') { |
|
98 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
99 | + } else { |
|
100 | + return "success"; |
|
101 | + } |
|
90 | 102 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
103 | + if ($registration == '' && $aircraft_icao != '') { |
|
104 | + $registration = $aircraft_icao.$airline_icao; |
|
105 | + } |
|
92 | 106 | if ($image_url['original'] != '') { |
93 | - if ($globalDebug) echo 'Found !'."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo 'Found !'."\n"; |
|
109 | + } |
|
94 | 110 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
95 | 111 | try { |
96 | 112 | $sth = $this->db->prepare($query); |
@@ -99,7 +115,9 @@ discard block |
||
99 | 115 | echo $e->getMessage()."\n"; |
100 | 116 | return "error"; |
101 | 117 | } |
102 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
118 | + } elseif ($globalDebug) { |
|
119 | + echo "Not found :'(\n"; |
|
120 | + } |
|
103 | 121 | return "success"; |
104 | 122 | } |
105 | 123 | |
@@ -114,40 +132,84 @@ discard block |
||
114 | 132 | { |
115 | 133 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
116 | 134 | $Spotter = new Spotter($this->db); |
117 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
135 | + if (!isset($globalIVAO)) { |
|
136 | + $globalIVAO = FALSE; |
|
137 | + } |
|
118 | 138 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
119 | 139 | if ($aircraft_registration != '') { |
120 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
140 | + if (strpos($aircraft_registration,'/') !== false) { |
|
141 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
142 | + } |
|
121 | 143 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
122 | 144 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
123 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
124 | - else $aircraft_name = ''; |
|
125 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
126 | - else $aircraft_icao = ''; |
|
127 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
128 | - else $airline_icao = ''; |
|
145 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
146 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
147 | + } else { |
|
148 | + $aircraft_name = ''; |
|
149 | + } |
|
150 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
151 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
152 | + } else { |
|
153 | + $aircraft_icao = ''; |
|
154 | + } |
|
155 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
156 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
157 | + } else { |
|
158 | + $airline_icao = ''; |
|
159 | + } |
|
129 | 160 | } elseif ($aircraft_icao != '') { |
130 | 161 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
131 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
132 | - else $aircraft_name = ''; |
|
162 | + if (isset($aircraft_info[0]['type'])) { |
|
163 | + $aircraft_name = $aircraft_info[0]['type']; |
|
164 | + } else { |
|
165 | + $aircraft_name = ''; |
|
166 | + } |
|
133 | 167 | $aircraft_registration = $aircraft_icao; |
134 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
135 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
168 | + } else { |
|
169 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
170 | + } |
|
171 | + if (!isset($globalAircraftImageSources)) { |
|
172 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
173 | + } |
|
136 | 174 | foreach ($globalAircraftImageSources as $source) { |
137 | 175 | $source = strtolower($source); |
138 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
139 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
140 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
141 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
142 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
143 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
144 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
145 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
146 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
147 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
148 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
176 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
177 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
178 | + } |
|
179 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
180 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
181 | + } |
|
182 | + if ($source == 'flickr') { |
|
183 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
184 | + } |
|
185 | + if ($source == 'bing') { |
|
186 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
187 | + } |
|
188 | + if ($source == 'deviantart') { |
|
189 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
190 | + } |
|
191 | + if ($source == 'wikimedia') { |
|
192 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
193 | + } |
|
194 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
195 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
196 | + } |
|
197 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
198 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
199 | + } |
|
200 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
201 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
202 | + } |
|
203 | + if ($source == 'customsources') { |
|
204 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
205 | + } |
|
206 | + if (isset($images_array) && $images_array['original'] != '') { |
|
207 | + return $images_array; |
|
208 | + } |
|
209 | + } |
|
210 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
211 | + return $this->findAircraftImage($aircraft_icao); |
|
149 | 212 | } |
150 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
151 | 213 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
152 | 214 | } |
153 | 215 | |
@@ -304,8 +366,11 @@ discard block |
||
304 | 366 | */ |
305 | 367 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
306 | 368 | $Common = new Common(); |
307 | - if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
308 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
369 | + if ($aircraft_name != '') { |
|
370 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
371 | + } else { |
|
372 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
373 | + } |
|
309 | 374 | $data = $Common->getData($url); |
310 | 375 | if ($xml = simplexml_load_string($data)) { |
311 | 376 | if (isset($xml->channel->item)) { |
@@ -349,9 +414,14 @@ discard block |
||
349 | 414 | public function fromBing($aircraft_registration,$aircraft_name='') { |
350 | 415 | global $globalImageBingKey; |
351 | 416 | $Common = new Common(); |
352 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
353 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
354 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
417 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
418 | + return false; |
|
419 | + } |
|
420 | + if ($aircraft_name != '') { |
|
421 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
422 | + } else { |
|
423 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
424 | + } |
|
355 | 425 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
356 | 426 | $data = $Common->getData($url,'get','',$headers); |
357 | 427 | $result = json_decode($data); |
@@ -405,13 +475,18 @@ discard block |
||
405 | 475 | */ |
406 | 476 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
407 | 477 | $Common = new Common(); |
408 | - if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
409 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
478 | + if ($aircraft_name != '') { |
|
479 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
480 | + } else { |
|
481 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
482 | + } |
|
410 | 483 | $data = $Common->getData($url); |
411 | 484 | $result = json_decode($data); |
412 | 485 | if (isset($result->query->search[0]->title)) { |
413 | 486 | $fileo = $result->query->search[0]->title; |
414 | - if (substr($fileo,-3) == 'pdf') return false; |
|
487 | + if (substr($fileo,-3) == 'pdf') { |
|
488 | + return false; |
|
489 | + } |
|
415 | 490 | $file = urlencode($fileo); |
416 | 491 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
417 | 492 | $data2 = $Common->getData($url2); |
@@ -482,18 +557,27 @@ discard block |
||
482 | 557 | $image_url = array(); |
483 | 558 | $image_url['thumbnail'] = $url_thumbnail; |
484 | 559 | $image_url['original'] = $url; |
485 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
486 | - else $exifCopyright = ''; |
|
487 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
488 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
489 | - else $image_url['copyright'] = $source['source_website']; |
|
560 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
561 | + $exifCopyright = $this->getExifCopyright($url); |
|
562 | + } else { |
|
563 | + $exifCopyright = ''; |
|
564 | + } |
|
565 | + if ($exifCopyright != '') { |
|
566 | + $image_url['copyright'] = $exifCopyright; |
|
567 | + } elseif (isset($source['copyright'])) { |
|
568 | + $image_url['copyright'] = $source['copyright']; |
|
569 | + } else { |
|
570 | + $image_url['copyright'] = $source['source_website']; |
|
571 | + } |
|
490 | 572 | $image_url['source_website'] = $source['source_website']; |
491 | 573 | $image_url['source'] = $source['source']; |
492 | 574 | return $image_url; |
493 | 575 | } |
494 | 576 | } |
495 | 577 | return false; |
496 | - } else return false; |
|
578 | + } else { |
|
579 | + return false; |
|
580 | + } |
|
497 | 581 | } |
498 | 582 | } |
499 | 583 |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $dbc = $this->db; |
64 | 64 | $this->all_flights[$id]['schedule_check'] = true; |
65 | 65 | if ($globalSchedulesFetch) { |
66 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
66 | + if ($globalDebug) { |
|
67 | + echo 'Getting schedule info...'."\n"; |
|
68 | + } |
|
67 | 69 | $Spotter = new Spotter($dbc); |
68 | 70 | $Schedule = new Schedule($dbc); |
69 | 71 | $Translation = new Translation($dbc); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | if ($Schedule->checkSchedule($operator) == 0) { |
75 | 77 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 78 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
81 | + } |
|
78 | 82 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
79 | 83 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
80 | 84 | // Should also check if route schedule = route from DB |
@@ -83,7 +87,9 @@ discard block |
||
83 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
84 | 88 | if (trim($airport_icao) != '') { |
85 | 89 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
86 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
87 | 93 | } |
88 | 94 | } |
89 | 95 | } |
@@ -92,17 +98,25 @@ discard block |
||
92 | 98 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
93 | 99 | if (trim($airport_icao) != '') { |
94 | 100 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
95 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
101 | + if ($globalDebug) { |
|
102 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
103 | + } |
|
96 | 104 | } |
97 | 105 | } |
98 | 106 | } |
99 | 107 | $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']); |
100 | 108 | } |
101 | - } else $scheduleexist = true; |
|
102 | - } else $scheduleexist = true; |
|
109 | + } else { |
|
110 | + $scheduleexist = true; |
|
111 | + } |
|
112 | + } else { |
|
113 | + $scheduleexist = true; |
|
114 | + } |
|
103 | 115 | // close connection, at least one way will work ? |
104 | 116 | if ($scheduleexist) { |
105 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
117 | + if ($globalDebug) { |
|
118 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
119 | + } |
|
106 | 120 | $sch = $Schedule->getSchedule($operator); |
107 | 121 | $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'])); |
108 | 122 | } |
@@ -124,14 +138,18 @@ discard block |
||
124 | 138 | |
125 | 139 | public function checkAll() { |
126 | 140 | global $globalDebug, $globalNoImport; |
127 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
141 | + if ($globalDebug) { |
|
142 | + echo "Update last seen flights data...\n"; |
|
143 | + } |
|
128 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
129 | 145 | foreach ($this->all_flights as $key => $flight) { |
130 | 146 | if (isset($this->all_flights[$key]['id'])) { |
131 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
132 | 148 | $Spotter = new Spotter($this->db); |
133 | 149 | $real_arrival = $this->arrival($key); |
134 | - if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
150 | + if (isset($this->all_flights[$key]['altitude'])) { |
|
151 | + $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']); |
|
152 | + } |
|
135 | 153 | } |
136 | 154 | } |
137 | 155 | } |
@@ -139,24 +157,32 @@ discard block |
||
139 | 157 | |
140 | 158 | public function arrival($key) { |
141 | 159 | global $globalClosestMinDist, $globalDebug; |
142 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
160 | + if ($globalDebug) { |
|
161 | + echo 'Update arrival...'."\n"; |
|
162 | + } |
|
143 | 163 | $Spotter = new Spotter($this->db); |
144 | 164 | $airport_icao = ''; |
145 | 165 | $airport_time = ''; |
146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
166 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
167 | + $globalClosestMinDist = 50; |
|
168 | + } |
|
147 | 169 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | 170 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
149 | 171 | if (isset($closestAirports[0])) { |
150 | 172 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
151 | 173 | $airport_icao = $closestAirports[0]['icao']; |
152 | 174 | $airport_time = $this->all_flights[$key]['datetime']; |
153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
175 | + if ($globalDebug) { |
|
176 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
177 | + } |
|
154 | 178 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
155 | 179 | foreach ($closestAirports as $airport) { |
156 | 180 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
157 | 181 | $airport_icao = $airport['icao']; |
158 | 182 | $airport_time = $this->all_flights[$key]['datetime']; |
159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
183 | + if ($globalDebug) { |
|
184 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + } |
|
160 | 186 | break; |
161 | 187 | } |
162 | 188 | } |
@@ -164,14 +190,20 @@ discard block |
||
164 | 190 | $airport_icao = $closestAirports[0]['icao']; |
165 | 191 | $airport_time = $this->all_flights[$key]['datetime']; |
166 | 192 | } else { |
167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
195 | + } |
|
168 | 196 | } |
169 | 197 | } else { |
170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
200 | + } |
|
171 | 201 | } |
172 | 202 | |
173 | 203 | } else { |
174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
204 | + if ($globalDebug) { |
|
205 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
206 | + } |
|
175 | 207 | } |
176 | 208 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
177 | 209 | } |
@@ -181,12 +213,16 @@ discard block |
||
181 | 213 | public function del() { |
182 | 214 | global $globalDebug, $globalNoImport, $globalNoDB; |
183 | 215 | // Delete old infos |
184 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
216 | + if ($globalDebug) { |
|
217 | + echo 'Delete old values and update latest data...'."\n"; |
|
218 | + } |
|
185 | 219 | foreach ($this->all_flights as $key => $flight) { |
186 | 220 | if (isset($flight['lastupdate'])) { |
187 | 221 | if ($flight['lastupdate'] < (time()-3000)) { |
188 | 222 | if (isset($this->all_flights[$key]['id'])) { |
189 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
223 | + if ($globalDebug) { |
|
224 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
225 | + } |
|
190 | 226 | /* |
191 | 227 | $SpotterLive = new SpotterLive(); |
192 | 228 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -197,7 +233,9 @@ discard block |
||
197 | 233 | $Spotter = new Spotter($this->db); |
198 | 234 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
199 | 235 | $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']); |
200 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
236 | + if ($globalDebug && $result != 'success') { |
|
237 | + echo '!!! ERROR : '.$result."\n"; |
|
238 | + } |
|
201 | 239 | } |
202 | 240 | // Put in archive |
203 | 241 | // $Spotter->db = null; |
@@ -212,8 +250,10 @@ discard block |
||
212 | 250 | public function add($line) { |
213 | 251 | 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; |
214 | 252 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
215 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
216 | -/* |
|
253 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
254 | + $globalCoordMinChange = '0.02'; |
|
255 | + } |
|
256 | + /* |
|
217 | 257 | $Spotter = new Spotter(); |
218 | 258 | $dbc = $Spotter->db; |
219 | 259 | $SpotterLive = new SpotterLive($dbc); |
@@ -241,11 +281,15 @@ discard block |
||
241 | 281 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
242 | 282 | $current_date = date('Y-m-d'); |
243 | 283 | $source = $line['source_name']; |
244 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
284 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
285 | + $source = $line['format_source']; |
|
286 | + } |
|
245 | 287 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
246 | 288 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
247 | 289 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
248 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
290 | + } else { |
|
291 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
292 | + } |
|
249 | 293 | } |
250 | 294 | |
251 | 295 | /* |
@@ -261,22 +305,35 @@ discard block |
||
261 | 305 | //$this->db = $dbc; |
262 | 306 | |
263 | 307 | //$hex = trim($line['hex']); |
264 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
265 | - else $id = trim($line['id']); |
|
308 | + if (!isset($line['id'])) { |
|
309 | + $id = trim($line['hex']); |
|
310 | + } else { |
|
311 | + $id = trim($line['id']); |
|
312 | + } |
|
266 | 313 | |
267 | 314 | if (!isset($this->all_flights[$id])) { |
268 | 315 | $this->all_flights[$id] = array(); |
269 | 316 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
270 | 317 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
271 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
318 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
320 | + } |
|
272 | 321 | if (!isset($line['id'])) { |
273 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
274 | -// 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'))); |
|
322 | + if (!isset($globalDaemon)) { |
|
323 | + $globalDaemon = TRUE; |
|
324 | + } |
|
325 | + // 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'))); |
|
275 | 326 | // 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'))); |
276 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
327 | + 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')) { |
|
328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
329 | + } |
|
277 | 330 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
278 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
279 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
331 | + } else { |
|
332 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
333 | + } |
|
334 | + if ($globalAllFlights !== FALSE) { |
|
335 | + $dataFound = true; |
|
336 | + } |
|
280 | 337 | } |
281 | 338 | if (isset($line['source_type']) && $line['source_type'] != '') { |
282 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -298,12 +355,20 @@ discard block |
||
298 | 355 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
299 | 356 | } |
300 | 357 | $Spotter->db = null; |
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
358 | + if ($globalDebugTimeElapsed) { |
|
359 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
360 | + } |
|
361 | + if ($aircraft_icao != '') { |
|
362 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
363 | + } |
|
303 | 364 | } |
304 | 365 | } |
305 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
306 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
366 | + if ($globalAllFlights !== FALSE) { |
|
367 | + $dataFound = true; |
|
368 | + } |
|
369 | + if ($globalDebug) { |
|
370 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
371 | + } |
|
307 | 372 | } |
308 | 373 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
309 | 374 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
@@ -314,15 +379,24 @@ discard block |
||
314 | 379 | $Spotter = new Spotter($this->db); |
315 | 380 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
316 | 381 | $Spotter->db = null; |
317 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
382 | + if ($aircraft_icao != '') { |
|
383 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
384 | + } |
|
318 | 385 | } |
319 | 386 | } |
320 | 387 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
321 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
322 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
323 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
324 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
325 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
388 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
389 | + $aircraft_icao = 'GLID'; |
|
390 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
391 | + $aircraft_icao = 'UHEL'; |
|
392 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
393 | + $aircraft_icao = 'TOWPLANE'; |
|
394 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
395 | + $aircraft_icao = 'POWAIRC'; |
|
396 | + } |
|
397 | + if (isset($aircraft_icao)) { |
|
398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
399 | + } |
|
326 | 400 | } |
327 | 401 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
328 | 402 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -332,8 +406,11 @@ discard block |
||
332 | 406 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
333 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
334 | 408 | } else { |
335 | - 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"; |
|
336 | - 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"; |
|
409 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
410 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
411 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
412 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
413 | + } |
|
337 | 414 | /* |
338 | 415 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
339 | 416 | print_r($this->all_flights[$id]); |
@@ -366,15 +443,25 @@ discard block |
||
366 | 443 | $timeelapsed = microtime(true); |
367 | 444 | $Spotter = new Spotter($this->db); |
368 | 445 | $fromsource = NULL; |
369 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
370 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
371 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
372 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
373 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
446 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
447 | + $fromsource = $globalAirlinesSource; |
|
448 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
449 | + $fromsource = 'vatsim'; |
|
450 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
451 | + $fromsource = 'ivao'; |
|
452 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
453 | + $fromsource = 'vatsim'; |
|
454 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
455 | + $fromsource = 'ivao'; |
|
456 | + } |
|
374 | 457 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
375 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
458 | + if ($globalDebug && $result != 'success') { |
|
459 | + echo '!!! ERROR : '.$result."\n"; |
|
460 | + } |
|
376 | 461 | $Spotter->db = null; |
377 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
462 | + if ($globalDebugTimeElapsed) { |
|
463 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
464 | + } |
|
378 | 465 | } |
379 | 466 | } |
380 | 467 | |
@@ -386,7 +473,9 @@ discard block |
||
386 | 473 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
387 | 474 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
388 | 475 | */ |
389 | - 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'])); |
|
476 | + if (!isset($this->all_flights[$id]['id'])) { |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
478 | + } |
|
390 | 479 | |
391 | 480 | //$putinarchive = true; |
392 | 481 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -404,7 +493,9 @@ discard block |
||
404 | 493 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
405 | 494 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
406 | 495 | $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' => '')); |
407 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
496 | + if ($globalDebugTimeElapsed) { |
|
497 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
498 | + } |
|
408 | 499 | } |
409 | 500 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
410 | 501 | $timeelapsed = microtime(true); |
@@ -418,7 +509,9 @@ discard block |
||
418 | 509 | $Translation->db = null; |
419 | 510 | } |
420 | 511 | $Spotter->db = null; |
421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
512 | + if ($globalDebugTimeElapsed) { |
|
513 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
514 | + } |
|
422 | 515 | } |
423 | 516 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
424 | 517 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -427,9 +520,13 @@ discard block |
||
427 | 520 | $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'])); |
428 | 521 | } |
429 | 522 | } |
430 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
523 | + if (!isset($globalFork)) { |
|
524 | + $globalFork = TRUE; |
|
525 | + } |
|
431 | 526 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
432 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
527 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
528 | + $this->get_Schedule($id,trim($line['ident'])); |
|
529 | + } |
|
433 | 530 | } |
434 | 531 | } |
435 | 532 | } |
@@ -445,16 +542,23 @@ discard block |
||
445 | 542 | // use datetime |
446 | 543 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
447 | 544 | $speed = $speed*3.6; |
448 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
449 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
545 | + if ($speed < 1000) { |
|
546 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
547 | + } |
|
548 | + if ($globalDebug) { |
|
549 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
550 | + } |
|
450 | 551 | } |
451 | 552 | } |
452 | 553 | |
453 | 554 | |
454 | 555 | |
455 | 556 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
456 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
457 | - else unset($timediff); |
|
557 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
558 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
559 | + } else { |
|
560 | + unset($timediff); |
|
561 | + } |
|
458 | 562 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
459 | 563 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
460 | 564 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -463,15 +567,23 @@ discard block |
||
463 | 567 | $this->all_flights[$id]['putinarchive'] = true; |
464 | 568 | $this->tmd = 0; |
465 | 569 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
466 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
570 | + if ($globalDebug) { |
|
571 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
572 | + } |
|
467 | 573 | $timeelapsed = microtime(true); |
468 | 574 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
469 | 575 | $Spotter = new Spotter($this->db); |
470 | 576 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
471 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
577 | + if (!empty($all_country)) { |
|
578 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
579 | + } |
|
472 | 580 | $Spotter->db = null; |
473 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
474 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
581 | + if ($globalDebugTimeElapsed) { |
|
582 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
583 | + } |
|
584 | + if ($globalDebug) { |
|
585 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
586 | + } |
|
475 | 587 | } |
476 | 588 | } |
477 | 589 | } |
@@ -479,7 +591,9 @@ discard block |
||
479 | 591 | |
480 | 592 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
481 | 593 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
482 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
594 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
595 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
596 | + } |
|
483 | 597 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
484 | 598 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
485 | 599 | $dataFound = true; |
@@ -501,9 +615,13 @@ discard block |
||
501 | 615 | */ |
502 | 616 | } |
503 | 617 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
504 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
618 | + if ($line['longitude'] > 180) { |
|
619 | + $line['longitude'] = $line['longitude'] - 360; |
|
620 | + } |
|
505 | 621 | //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) { |
506 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
622 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
623 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
624 | + } |
|
507 | 625 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
508 | 626 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
509 | 627 | $dataFound = true; |
@@ -534,7 +652,9 @@ discard block |
||
534 | 652 | } |
535 | 653 | } |
536 | 654 | if (isset($line['last_update']) && $line['last_update'] != '') { |
537 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
655 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
656 | + $dataFound = true; |
|
657 | + } |
|
538 | 658 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
539 | 659 | } |
540 | 660 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -556,41 +676,61 @@ discard block |
||
556 | 676 | // Here we force archive of flight because after ground it's a new one (or should be) |
557 | 677 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
558 | 678 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
559 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
560 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
561 | - 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'])); |
|
679 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
680 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
681 | + } elseif (isset($line['id'])) { |
|
682 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
683 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
684 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
685 | + } |
|
686 | + } |
|
687 | + if ($line['ground'] != 1) { |
|
688 | + $line['ground'] = 0; |
|
562 | 689 | } |
563 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
564 | 690 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
565 | 691 | //$dataFound = true; |
566 | 692 | } |
567 | 693 | if (isset($line['squawk']) && $line['squawk'] != '') { |
568 | 694 | 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'])) { |
569 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
695 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
696 | + $this->all_flights[$id]['putinarchive'] = true; |
|
697 | + } |
|
570 | 698 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
571 | 699 | $highlight = ''; |
572 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
573 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
574 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
700 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
701 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
702 | + } |
|
703 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
704 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
705 | + } |
|
706 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
707 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
708 | + } |
|
575 | 709 | if ($highlight != '') { |
576 | 710 | $timeelapsed = microtime(true); |
577 | 711 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
578 | 712 | $Spotter = new Spotter($this->db); |
579 | 713 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
580 | 714 | $Spotter->db = null; |
581 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
715 | + if ($globalDebugTimeElapsed) { |
|
716 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
717 | + } |
|
582 | 718 | } |
583 | 719 | //$putinarchive = true; |
584 | 720 | //$highlight = ''; |
585 | 721 | } |
586 | 722 | |
587 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
723 | + } else { |
|
724 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
725 | + } |
|
588 | 726 | //$dataFound = true; |
589 | 727 | } |
590 | 728 | |
591 | 729 | if (isset($line['altitude']) && $line['altitude'] != '') { |
592 | 730 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
593 | - 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; |
|
731 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
732 | + $this->all_flights[$id]['putinarchive'] = true; |
|
733 | + } |
|
594 | 734 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
595 | 735 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
596 | 736 | //$dataFound = true; |
@@ -602,21 +742,30 @@ discard block |
||
602 | 742 | } |
603 | 743 | |
604 | 744 | if (isset($line['heading']) && $line['heading'] != '') { |
605 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
745 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
746 | + $this->all_flights[$id]['putinarchive'] = true; |
|
747 | + } |
|
606 | 748 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
607 | 749 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
608 | 750 | //$dataFound = true; |
609 | 751 | } 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']) { |
610 | 752 | $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']); |
611 | 753 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
612 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
613 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
754 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
755 | + $this->all_flights[$id]['putinarchive'] = true; |
|
756 | + } |
|
757 | + if ($globalDebug) { |
|
758 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
759 | + } |
|
614 | 760 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
615 | 761 | // If not enough messages and ACARS set heading to 0 |
616 | 762 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
617 | 763 | } |
618 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
619 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
764 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
765 | + $dataFound = false; |
|
766 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
767 | + $dataFound = false; |
|
768 | + } |
|
620 | 769 | |
621 | 770 | // print_r($this->all_flights[$id]); |
622 | 771 | //gets the callsign from the last hour |
@@ -632,23 +781,38 @@ discard block |
||
632 | 781 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
633 | 782 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
634 | 783 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
635 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
784 | + if ($globalDebug) { |
|
785 | + echo "Check if aircraft is already in DB..."; |
|
786 | + } |
|
636 | 787 | $timeelapsed = microtime(true); |
637 | 788 | $SpotterLive = new SpotterLive($this->db); |
638 | 789 | 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')) { |
639 | 790 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
640 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
791 | + if ($globalDebugTimeElapsed) { |
|
792 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
793 | + } |
|
641 | 794 | } elseif (isset($line['id'])) { |
642 | 795 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
643 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
796 | + if ($globalDebugTimeElapsed) { |
|
797 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
798 | + } |
|
644 | 799 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
645 | 800 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
646 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
647 | - } else $recent_ident = ''; |
|
801 | + if ($globalDebugTimeElapsed) { |
|
802 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
803 | + } |
|
804 | + } else { |
|
805 | + $recent_ident = ''; |
|
806 | + } |
|
648 | 807 | $SpotterLive->db=null; |
649 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
650 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
651 | - } else $recent_ident = ''; |
|
808 | + if ($globalDebug && $recent_ident == '') { |
|
809 | + echo " Not in DB.\n"; |
|
810 | + } elseif ($globalDebug && $recent_ident != '') { |
|
811 | + echo " Already in DB.\n"; |
|
812 | + } |
|
813 | + } else { |
|
814 | + $recent_ident = ''; |
|
815 | + } |
|
652 | 816 | } else { |
653 | 817 | $recent_ident = ''; |
654 | 818 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -656,7 +820,9 @@ discard block |
||
656 | 820 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
657 | 821 | if($recent_ident == "") |
658 | 822 | { |
659 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
823 | + if ($globalDebug) { |
|
824 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
825 | + } |
|
660 | 826 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
661 | 827 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
662 | 828 | //adds the spotter data for the archive |
@@ -700,31 +866,49 @@ discard block |
||
700 | 866 | |
701 | 867 | if (!$ignoreImport) { |
702 | 868 | $highlight = ''; |
703 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
704 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
705 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
706 | - 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'))); |
|
869 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
870 | + $highlight = 'Squawk 7500 : Hijack'; |
|
871 | + } |
|
872 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
873 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
874 | + } |
|
875 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
876 | + $highlight = 'Squawk 7700 : Emergency'; |
|
877 | + } |
|
878 | + if (!isset($this->all_flights[$id]['id'])) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
880 | + } |
|
707 | 881 | $timeelapsed = microtime(true); |
708 | 882 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
709 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
710 | 884 | $Spotter = new Spotter($this->db); |
711 | 885 | $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']); |
712 | 886 | $Spotter->db = null; |
713 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
887 | + if ($globalDebug && isset($result)) { |
|
888 | + echo $result."\n"; |
|
889 | + } |
|
714 | 890 | } |
715 | 891 | } |
716 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
892 | + if ($globalDebugTimeElapsed) { |
|
893 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
894 | + } |
|
717 | 895 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
718 | 896 | |
719 | 897 | // Add source stat in DB |
720 | 898 | $Stats = new Stats($this->db); |
721 | 899 | if (!empty($this->stats)) { |
722 | - if ($globalDebug) echo 'Add source stats : '; |
|
900 | + if ($globalDebug) { |
|
901 | + echo 'Add source stats : '; |
|
902 | + } |
|
723 | 903 | foreach($this->stats as $date => $data) { |
724 | 904 | foreach($data as $source => $sourced) { |
725 | 905 | //print_r($sourced); |
726 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
727 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
906 | + if (isset($sourced['polar'])) { |
|
907 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
908 | + } |
|
909 | + if (isset($sourced['hist'])) { |
|
910 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
911 | + } |
|
728 | 912 | if (isset($sourced['msg'])) { |
729 | 913 | if (time() - $sourced['msg']['date'] > 10) { |
730 | 914 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -737,13 +921,17 @@ discard block |
||
737 | 921 | unset($this->stats[$date]); |
738 | 922 | } |
739 | 923 | } |
740 | - if ($globalDebug) echo 'Done'."\n"; |
|
924 | + if ($globalDebug) { |
|
925 | + echo 'Done'."\n"; |
|
926 | + } |
|
741 | 927 | |
742 | 928 | } |
743 | 929 | $Stats->db = null; |
744 | 930 | } |
745 | 931 | $this->del(); |
746 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
932 | + } elseif ($globalDebug) { |
|
933 | + echo 'Ignore data'."\n"; |
|
934 | + } |
|
747 | 935 | //$ignoreImport = false; |
748 | 936 | $this->all_flights[$id]['addedSpotter'] = 1; |
749 | 937 | //print_r($this->all_flights[$id]); |
@@ -760,7 +948,9 @@ discard block |
||
760 | 948 | */ |
761 | 949 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
762 | 950 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
763 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
951 | + if ($globalDebug) { |
|
952 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
953 | + } |
|
764 | 954 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
765 | 955 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
766 | 956 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -769,7 +959,9 @@ discard block |
||
769 | 959 | $SpotterLive->db=null; |
770 | 960 | } |
771 | 961 | } |
772 | - if ($globalDebug) echo " Done\n"; |
|
962 | + if ($globalDebug) { |
|
963 | + echo " Done\n"; |
|
964 | + } |
|
773 | 965 | $this->last_delete = time(); |
774 | 966 | } |
775 | 967 | } else { |
@@ -796,11 +988,17 @@ discard block |
||
796 | 988 | //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"; |
797 | 989 | if ($globalDebug) { |
798 | 990 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
799 | - 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"; |
|
800 | - 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"; |
|
991 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
992 | + 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"; |
|
993 | + } else { |
|
994 | + 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"; |
|
995 | + } |
|
801 | 996 | } else { |
802 | - 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"; |
|
803 | - 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"; |
|
997 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
998 | + 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"; |
|
999 | + } else { |
|
1000 | + 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"; |
|
1001 | + } |
|
804 | 1002 | } |
805 | 1003 | } |
806 | 1004 | $ignoreImport = false; |
@@ -846,22 +1044,30 @@ discard block |
||
846 | 1044 | |
847 | 1045 | if (!$ignoreImport) { |
848 | 1046 | 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'])) { |
849 | - 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'))); |
|
1047 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1048 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1049 | + } |
|
850 | 1050 | $timeelapsed = microtime(true); |
851 | 1051 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
852 | 1052 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
853 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1055 | + } |
|
854 | 1056 | $SpotterLive = new SpotterLive($this->db); |
855 | 1057 | $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']); |
856 | 1058 | $SpotterLive->db = null; |
857 | - if ($globalDebug) echo $result."\n"; |
|
1059 | + if ($globalDebug) { |
|
1060 | + echo $result."\n"; |
|
1061 | + } |
|
858 | 1062 | } |
859 | 1063 | } |
860 | 1064 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
861 | 1065 | $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']); |
862 | 1066 | } |
863 | 1067 | $this->all_flights[$id]['putinarchive'] = false; |
864 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1068 | + if ($globalDebugTimeElapsed) { |
|
1069 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1070 | + } |
|
865 | 1071 | |
866 | 1072 | // Put statistics in $this->stats variable |
867 | 1073 | //if ($line['format_source'] != 'aprs') { |
@@ -869,7 +1075,9 @@ discard block |
||
869 | 1075 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
870 | 1076 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
871 | 1077 | $source = $this->all_flights[$id]['source_name']; |
872 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1078 | + if ($source == '') { |
|
1079 | + $source = $this->all_flights[$id]['format_source']; |
|
1080 | + } |
|
873 | 1081 | if (!isset($this->source_location[$source])) { |
874 | 1082 | $Location = new Source(); |
875 | 1083 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -890,7 +1098,9 @@ discard block |
||
890 | 1098 | $stats_heading = round($stats_heading/22.5); |
891 | 1099 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
892 | 1100 | $current_date = date('Y-m-d'); |
893 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1101 | + if ($stats_heading == 16) { |
|
1102 | + $stats_heading = 0; |
|
1103 | + } |
|
894 | 1104 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
895 | 1105 | for ($i=0;$i<=15;$i++) { |
896 | 1106 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -908,7 +1118,9 @@ discard block |
||
908 | 1118 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
909 | 1119 | end($this->stats[$current_date][$source]['hist']); |
910 | 1120 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
911 | - } else $mini = 0; |
|
1121 | + } else { |
|
1122 | + $mini = 0; |
|
1123 | + } |
|
912 | 1124 | for ($i=$mini;$i<=$distance;$i+=10) { |
913 | 1125 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
914 | 1126 | } |
@@ -920,19 +1132,27 @@ discard block |
||
920 | 1132 | } |
921 | 1133 | |
922 | 1134 | $this->all_flights[$id]['lastupdate'] = time(); |
923 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1135 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1136 | + $send = true; |
|
1137 | + } |
|
924 | 1138 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
925 | - } 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"; |
|
1139 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1140 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1141 | + } |
|
926 | 1142 | //$this->del(); |
927 | 1143 | |
928 | 1144 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
929 | 1145 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
930 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1146 | + if ($globalDebug) { |
|
1147 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1148 | + } |
|
931 | 1149 | $SpotterLive = new SpotterLive($this->db); |
932 | 1150 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
933 | 1151 | $SpotterLive->db = null; |
934 | 1152 | //SpotterLive->deleteLiveSpotterData(); |
935 | - if ($globalDebug) echo " Done\n"; |
|
1153 | + if ($globalDebug) { |
|
1154 | + echo " Done\n"; |
|
1155 | + } |
|
936 | 1156 | $this->last_delete_hourly = time(); |
937 | 1157 | } else { |
938 | 1158 | $this->del(); |
@@ -944,7 +1164,9 @@ discard block |
||
944 | 1164 | //$ignoreImport = false; |
945 | 1165 | } |
946 | 1166 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
947 | - if ($send) return $this->all_flights[$id]; |
|
1167 | + if ($send) { |
|
1168 | + return $this->all_flights[$id]; |
|
1169 | + } |
|
948 | 1170 | } |
949 | 1171 | } |
950 | 1172 | } |
@@ -72,7 +72,9 @@ discard block |
||
72 | 72 | if (isset($filter[0]['source'])) { |
73 | 73 | $filters = array_merge($filters,$filter); |
74 | 74 | } |
75 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
75 | + if (is_array($globalFilter)) { |
|
76 | + $filter = array_merge($filter,$globalFilter); |
|
77 | + } |
|
76 | 78 | $filter_query_join = ''; |
77 | 79 | $filter_query_where = ''; |
78 | 80 | foreach($filters as $flt) { |
@@ -156,8 +158,11 @@ discard block |
||
156 | 158 | $filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
157 | 159 | } |
158 | 160 | } |
159 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
160 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
161 | + if ($filter_query_where == '' && $where) { |
|
162 | + $filter_query_where = ' WHERE'; |
|
163 | + } elseif ($filter_query_where != '' && $and) { |
|
164 | + $filter_query_where .= ' AND'; |
|
165 | + } |
|
161 | 166 | if ($filter_query_where != '') { |
162 | 167 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
163 | 168 | } |
@@ -180,10 +185,18 @@ discard block |
||
180 | 185 | $Image = new Image($this->db); |
181 | 186 | $Schedule = new Schedule($this->db); |
182 | 187 | $ACARS = new ACARS($this->db); |
183 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
184 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
185 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
186 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
188 | + if (!isset($globalIVAO)) { |
|
189 | + $globalIVAO = FALSE; |
|
190 | + } |
|
191 | + if (!isset($globalVATSIM)) { |
|
192 | + $globalVATSIM = FALSE; |
|
193 | + } |
|
194 | + if (!isset($globalphpVMS)) { |
|
195 | + $globalphpVMS = FALSE; |
|
196 | + } |
|
197 | + if (!isset($globalVAM)) { |
|
198 | + $globalVAM = FALSE; |
|
199 | + } |
|
187 | 200 | date_default_timezone_set('UTC'); |
188 | 201 | |
189 | 202 | if (!is_string($query)) |
@@ -230,21 +243,35 @@ discard block |
||
230 | 243 | } else { |
231 | 244 | $temp_array['spotter_id'] = ''; |
232 | 245 | } |
233 | - if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
234 | - if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
246 | + if (isset($row['flightaware_id'])) { |
|
247 | + $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
248 | + } |
|
249 | + if (isset($row['modes'])) { |
|
250 | + $temp_array['modes'] = $row['modes']; |
|
251 | + } |
|
235 | 252 | $temp_array['ident'] = $row['ident']; |
236 | 253 | if (isset($row['registration']) && $row['registration'] != '') { |
237 | 254 | $temp_array['registration'] = $row['registration']; |
238 | 255 | } elseif (isset($temp_array['modes'])) { |
239 | 256 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
240 | - } else $temp_array['registration'] = ''; |
|
241 | - if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
257 | + } else { |
|
258 | + $temp_array['registration'] = ''; |
|
259 | + } |
|
260 | + if (isset($row['aircraft_icao'])) { |
|
261 | + $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
262 | + } |
|
242 | 263 | |
243 | 264 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
244 | 265 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
245 | - if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
246 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
247 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
266 | + if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) { |
|
267 | + $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
268 | + } |
|
269 | + if (isset($row['latitude'])) { |
|
270 | + $temp_array['latitude'] = $row['latitude']; |
|
271 | + } |
|
272 | + if (isset($row['longitude'])) { |
|
273 | + $temp_array['longitude'] = $row['longitude']; |
|
274 | + } |
|
248 | 275 | /* |
249 | 276 | if (Connection->tableExists('countries')) { |
250 | 277 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
@@ -254,8 +281,12 @@ discard block |
||
254 | 281 | } |
255 | 282 | } |
256 | 283 | */ |
257 | - if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
|
258 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
284 | + if (isset($row['waypoints'])) { |
|
285 | + $temp_array['waypoints'] = $row['waypoints']; |
|
286 | + } |
|
287 | + if (isset($row['format_source'])) { |
|
288 | + $temp_array['format_source'] = $row['format_source']; |
|
289 | + } |
|
259 | 290 | if (isset($row['route_stop']) && $row['route_stop'] != '') { |
260 | 291 | $temp_array['route_stop'] = $row['route_stop']; |
261 | 292 | $allroute = explode(' ',$row['route_stop']); |
@@ -271,13 +302,19 @@ discard block |
||
271 | 302 | } |
272 | 303 | } |
273 | 304 | } |
274 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
305 | + if (isset($row['altitude'])) { |
|
306 | + $temp_array['altitude'] = $row['altitude']; |
|
307 | + } |
|
275 | 308 | if (isset($row['heading'])) { |
276 | 309 | $temp_array['heading'] = $row['heading']; |
277 | 310 | $heading_direction = $this->parseDirection($row['heading']); |
278 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
311 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
312 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
313 | + } |
|
314 | + } |
|
315 | + if (isset($row['ground_speed'])) { |
|
316 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
279 | 317 | } |
280 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
281 | 318 | $temp_array['image'] = ""; |
282 | 319 | $temp_array['image_thumbnail'] = ""; |
283 | 320 | $temp_array['image_source'] = ""; |
@@ -285,7 +322,9 @@ discard block |
||
285 | 322 | |
286 | 323 | if (isset($row['highlight'])) { |
287 | 324 | $temp_array['highlight'] = $row['highlight']; |
288 | - } else $temp_array['highlight'] = ''; |
|
325 | + } else { |
|
326 | + $temp_array['highlight'] = ''; |
|
327 | + } |
|
289 | 328 | |
290 | 329 | if (isset($row['date'])) { |
291 | 330 | $dateArray = $this->parseDateString($row['date']); |
@@ -341,7 +380,9 @@ discard block |
||
341 | 380 | |
342 | 381 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
343 | 382 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
344 | - } else $temp_array['aircraft_shadow'] = 'default.png'; |
|
383 | + } else { |
|
384 | + $temp_array['aircraft_shadow'] = 'default.png'; |
|
385 | + } |
|
345 | 386 | } else { |
346 | 387 | $temp_array['aircraft_shadow'] = 'default.png'; |
347 | 388 | $temp_array['aircraft_name'] = 'N/A'; |
@@ -349,11 +390,17 @@ discard block |
||
349 | 390 | } |
350 | 391 | } |
351 | 392 | $fromsource = NULL; |
352 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
353 | - elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
354 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
355 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
356 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
393 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
394 | + $fromsource = $globalAirlinesSource; |
|
395 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
396 | + $fromsource = 'vatsim'; |
|
397 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
398 | + $fromsource = 'ivao'; |
|
399 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
400 | + $fromsource = 'vatsim'; |
|
401 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
402 | + $fromsource = 'ivao'; |
|
403 | + } |
|
357 | 404 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
358 | 405 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
359 | 406 | if (is_numeric(substr($row['ident'], 2, 1))) { |
@@ -376,12 +423,18 @@ discard block |
||
376 | 423 | } |
377 | 424 | } else { |
378 | 425 | $temp_array['airline_icao'] = $row['airline_icao']; |
379 | - if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
380 | - else $temp_array['airline_iata'] = 'N/A'; |
|
426 | + if (isset($row['airline_iata'])) { |
|
427 | + $temp_array['airline_iata'] = $row['airline_iata']; |
|
428 | + } else { |
|
429 | + $temp_array['airline_iata'] = 'N/A'; |
|
430 | + } |
|
381 | 431 | $temp_array['airline_name'] = $row['airline_name']; |
382 | 432 | $temp_array['airline_country'] = $row['airline_country']; |
383 | - if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
384 | - else $temp_array['airline_callsign'] = 'N/A'; |
|
433 | + if (isset($row['airline_callsign'])) { |
|
434 | + $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
435 | + } else { |
|
436 | + $temp_array['airline_callsign'] = 'N/A'; |
|
437 | + } |
|
385 | 438 | $temp_array['airline_type'] = $row['airline_type']; |
386 | 439 | if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { |
387 | 440 | $airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); |
@@ -408,7 +461,9 @@ discard block |
||
408 | 461 | } |
409 | 462 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
410 | 463 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
411 | - if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
464 | + if ($owner_info['owner'] != '') { |
|
465 | + $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
466 | + } |
|
412 | 467 | $temp_array['aircraft_base'] = $owner_info['base']; |
413 | 468 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
414 | 469 | } |
@@ -416,10 +471,16 @@ discard block |
||
416 | 471 | if($temp_array['registration'] != "" || (($globalIVAO || $globalVATSIM || $globalphpVMS || $globalVAM) && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
417 | 472 | { |
418 | 473 | if ($globalIVAO) { |
419 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
420 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
421 | - } elseif (isset($temp_array['aircraft_type'])) $image_array = $Image->getSpotterImage($temp_array['registration'],$temp_array['aircraft_type']); |
|
422 | - else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
474 | + if (isset($temp_array['airline_icao'])) { |
|
475 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
476 | + } else { |
|
477 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
478 | + } |
|
479 | + } elseif (isset($temp_array['aircraft_type'])) { |
|
480 | + $image_array = $Image->getSpotterImage($temp_array['registration'],$temp_array['aircraft_type']); |
|
481 | + } else { |
|
482 | + $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
483 | + } |
|
423 | 484 | if (count($image_array) > 0) { |
424 | 485 | $temp_array['image'] = $image_array[0]['image']; |
425 | 486 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -471,7 +532,9 @@ discard block |
||
471 | 532 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
472 | 533 | if ($row['departure_airport_icao'] != '') { |
473 | 534 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
474 | - if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
535 | + if (!isset($departure_airport_array[0]['name'])) { |
|
536 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
537 | + } |
|
475 | 538 | /* |
476 | 539 | } elseif ($row['departure_airport_name'] != '') { |
477 | 540 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
@@ -479,7 +542,9 @@ discard block |
||
479 | 542 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
480 | 543 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
481 | 544 | */ |
482 | - } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
545 | + } else { |
|
546 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
547 | + } |
|
483 | 548 | if (isset($departure_airport_array[0]['name'])) { |
484 | 549 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
485 | 550 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
@@ -499,8 +564,12 @@ discard block |
||
499 | 564 | |
500 | 565 | if ($row['arrival_airport_icao'] != '') { |
501 | 566 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
502 | - if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
503 | - } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
567 | + if (count($arrival_airport_array) == 0) { |
|
568 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
569 | + } |
|
570 | + } else { |
|
571 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
572 | + } |
|
504 | 573 | if (isset($arrival_airport_array[0]['name'])) { |
505 | 574 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
506 | 575 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
@@ -516,27 +585,45 @@ discard block |
||
516 | 585 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
517 | 586 | } |
518 | 587 | */ |
519 | - if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
520 | - if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
521 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
522 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
523 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
588 | + if (isset($row['pilot_id']) && $row['pilot_id'] != '') { |
|
589 | + $temp_array['pilot_id'] = $row['pilot_id']; |
|
590 | + } |
|
591 | + if (isset($row['pilot_name']) && $row['pilot_name'] != '') { |
|
592 | + $temp_array['pilot_name'] = $row['pilot_name']; |
|
593 | + } |
|
594 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
595 | + $temp_array['source_name'] = $row['source_name']; |
|
596 | + } |
|
597 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
598 | + $temp_array['over_country'] = $row['over_country']; |
|
599 | + } |
|
600 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
601 | + $temp_array['distance'] = $row['distance']; |
|
602 | + } |
|
524 | 603 | if (isset($row['squawk'])) { |
525 | 604 | $temp_array['squawk'] = $row['squawk']; |
526 | 605 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
527 | 606 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
528 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
607 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
608 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
609 | + } |
|
529 | 610 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
530 | 611 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
531 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
532 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
612 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
613 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
614 | + } |
|
615 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) { |
|
616 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
617 | + } |
|
533 | 618 | } |
534 | 619 | |
535 | 620 | $temp_array['query_number_rows'] = $num_rows; |
536 | 621 | |
537 | 622 | $spotter_array[] = $temp_array; |
538 | 623 | } |
539 | - if ($num_rows == 0) return array(); |
|
624 | + if ($num_rows == 0) { |
|
625 | + return array(); |
|
626 | + } |
|
540 | 627 | $spotter_array[0]['query_number_rows'] = $num_rows; |
541 | 628 | return $spotter_array; |
542 | 629 | } |
@@ -569,7 +656,9 @@ discard block |
||
569 | 656 | foreach ($q_array as $q_item){ |
570 | 657 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
571 | 658 | $additional_query .= " AND ("; |
572 | - if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
659 | + if (is_int($q_item)) { |
|
660 | + $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
661 | + } |
|
573 | 662 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
574 | 663 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
575 | 664 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
@@ -590,7 +679,9 @@ discard block |
||
590 | 679 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
591 | 680 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
592 | 681 | $translate = $Translation->ident2icao($q_item); |
593 | - if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
682 | + if ($translate != $q_item) { |
|
683 | + $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
684 | + } |
|
594 | 685 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
595 | 686 | $additional_query .= ")"; |
596 | 687 | } |
@@ -817,7 +908,9 @@ discard block |
||
817 | 908 | date_default_timezone_set($globalTimezone); |
818 | 909 | $datetime = new DateTime(); |
819 | 910 | $offset = $datetime->format('P'); |
820 | - } else $offset = '+00:00'; |
|
911 | + } else { |
|
912 | + $offset = '+00:00'; |
|
913 | + } |
|
821 | 914 | |
822 | 915 | if ($date_array[1] != "") |
823 | 916 | { |
@@ -849,8 +942,12 @@ discard block |
||
849 | 942 | { |
850 | 943 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
851 | 944 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
852 | - } else $limit_query = ""; |
|
853 | - } else $limit_query = ""; |
|
945 | + } else { |
|
946 | + $limit_query = ""; |
|
947 | + } |
|
948 | + } else { |
|
949 | + $limit_query = ""; |
|
950 | + } |
|
854 | 951 | |
855 | 952 | |
856 | 953 | if ($sort != "") |
@@ -918,8 +1015,12 @@ discard block |
||
918 | 1015 | { |
919 | 1016 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
920 | 1017 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
921 | - } else $limit_query = ""; |
|
922 | - } else $limit_query = ""; |
|
1018 | + } else { |
|
1019 | + $limit_query = ""; |
|
1020 | + } |
|
1021 | + } else { |
|
1022 | + $limit_query = ""; |
|
1023 | + } |
|
923 | 1024 | |
924 | 1025 | if ($sort != "") |
925 | 1026 | { |
@@ -1243,7 +1344,9 @@ discard block |
||
1243 | 1344 | global $global_query; |
1244 | 1345 | |
1245 | 1346 | date_default_timezone_set('UTC'); |
1246 | - if ($id == '') return array(); |
|
1347 | + if ($id == '') { |
|
1348 | + return array(); |
|
1349 | + } |
|
1247 | 1350 | $additional_query = "spotter_output.spotter_id = :id"; |
1248 | 1351 | $query_values = array(':id' => $id); |
1249 | 1352 | |
@@ -1358,8 +1461,11 @@ discard block |
||
1358 | 1461 | if ($sort != "") |
1359 | 1462 | { |
1360 | 1463 | $search_orderby_array = $this->getOrderBy(); |
1361 | - if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1362 | - else $orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1464 | + if (isset($search_orderby_array[$sort]['sql'])) { |
|
1465 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1466 | + } else { |
|
1467 | + $orderby_query = " ORDER BY spotter_output.date DESC"; |
|
1468 | + } |
|
1363 | 1469 | } else { |
1364 | 1470 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
1365 | 1471 | } |
@@ -1984,7 +2090,9 @@ discard block |
||
1984 | 2090 | { |
1985 | 2091 | $highlight = $row['highlight']; |
1986 | 2092 | } |
1987 | - if (isset($highlight)) return $highlight; |
|
2093 | + if (isset($highlight)) { |
|
2094 | + return $highlight; |
|
2095 | + } |
|
1988 | 2096 | } |
1989 | 2097 | |
1990 | 2098 | |
@@ -2012,7 +2120,9 @@ discard block |
||
2012 | 2120 | $sth->closeCursor(); |
2013 | 2121 | if (count($row) > 0) { |
2014 | 2122 | return $row['usage']; |
2015 | - } else return ''; |
|
2123 | + } else { |
|
2124 | + return ''; |
|
2125 | + } |
|
2016 | 2126 | } |
2017 | 2127 | |
2018 | 2128 | /** |
@@ -2037,7 +2147,9 @@ discard block |
||
2037 | 2147 | $sth->closeCursor(); |
2038 | 2148 | if (count($row) > 0) { |
2039 | 2149 | return $row['icao']; |
2040 | - } else return ''; |
|
2150 | + } else { |
|
2151 | + return ''; |
|
2152 | + } |
|
2041 | 2153 | } |
2042 | 2154 | |
2043 | 2155 | /** |
@@ -2065,7 +2177,9 @@ discard block |
||
2065 | 2177 | $airport_longitude = $row['longitude']; |
2066 | 2178 | $Common = new Common(); |
2067 | 2179 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
2068 | - } else return ''; |
|
2180 | + } else { |
|
2181 | + return ''; |
|
2182 | + } |
|
2069 | 2183 | } |
2070 | 2184 | |
2071 | 2185 | /** |
@@ -2177,7 +2291,9 @@ discard block |
||
2177 | 2291 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2178 | 2292 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2179 | 2293 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2180 | - } else return array(); |
|
2294 | + } else { |
|
2295 | + return array(); |
|
2296 | + } |
|
2181 | 2297 | if ($globalDBdriver == 'mysql') { |
2182 | 2298 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
2183 | 2299 | } else { |
@@ -2212,7 +2328,9 @@ discard block |
||
2212 | 2328 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2213 | 2329 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2214 | 2330 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2215 | - } else return array(); |
|
2331 | + } else { |
|
2332 | + return array(); |
|
2333 | + } |
|
2216 | 2334 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
2217 | 2335 | $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
2218 | 2336 | //$query = "SELECT waypoints.* FROM waypoints"; |
@@ -2247,7 +2365,9 @@ discard block |
||
2247 | 2365 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
2248 | 2366 | { |
2249 | 2367 | global $globalUseRealAirlines; |
2250 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2368 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2369 | + $fromsource = NULL; |
|
2370 | + } |
|
2251 | 2371 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
2252 | 2372 | if ($airline_icao == 'NA') { |
2253 | 2373 | $airline_array = array(); |
@@ -2316,7 +2436,9 @@ discard block |
||
2316 | 2436 | public function getAllAirlineInfoByName($airline_name, $fromsource = NULL) |
2317 | 2437 | { |
2318 | 2438 | global $globalUseRealAirlines; |
2319 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2439 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2440 | + $fromsource = NULL; |
|
2441 | + } |
|
2320 | 2442 | $airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING)); |
2321 | 2443 | $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
2322 | 2444 | $sth = $this->db->prepare($query); |
@@ -2332,7 +2454,9 @@ discard block |
||
2332 | 2454 | $sth->execute(array(':fromsource' => $fromsource)); |
2333 | 2455 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2334 | 2456 | $sth->closeCursor(); |
2335 | - if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name); |
|
2457 | + if ($row['nb'] == 0) { |
|
2458 | + $result = $this->getAllAirlineInfoByName($airline_name); |
|
2459 | + } |
|
2336 | 2460 | } |
2337 | 2461 | return $result; |
2338 | 2462 | } |
@@ -2395,15 +2519,20 @@ discard block |
||
2395 | 2519 | 'A320-211' => 'A320', |
2396 | 2520 | '747-8i' => 'B748', |
2397 | 2521 | 'A380' => 'A388'); |
2398 | - if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
|
2522 | + if (isset($all_aircraft[$aircraft_type])) { |
|
2523 | + return $all_aircraft[$aircraft_type]; |
|
2524 | + } |
|
2399 | 2525 | |
2400 | 2526 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
2401 | 2527 | $aircraft_type = strtoupper($aircraft_type); |
2402 | 2528 | $sth = $this->db->prepare($query); |
2403 | 2529 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
2404 | 2530 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2405 | - if (isset($result[0]['icao'])) return $result[0]['icao']; |
|
2406 | - else return ''; |
|
2531 | + if (isset($result[0]['icao'])) { |
|
2532 | + return $result[0]['icao']; |
|
2533 | + } else { |
|
2534 | + return ''; |
|
2535 | + } |
|
2407 | 2536 | } |
2408 | 2537 | |
2409 | 2538 | /** |
@@ -2431,11 +2560,15 @@ discard block |
||
2431 | 2560 | $sth->closeCursor(); |
2432 | 2561 | if (isset($row['icaotypecode'])) { |
2433 | 2562 | $icao = $row['icaotypecode']; |
2434 | - if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao]; |
|
2563 | + if (isset($this->aircraft_correct_icaotype[$icao])) { |
|
2564 | + $icao = $this->aircraft_correct_icaotype[$icao]; |
|
2565 | + } |
|
2435 | 2566 | return $icao; |
2436 | 2567 | } elseif ($source_type == 'flarm') { |
2437 | 2568 | return $this->getAllAircraftType($aircraft_modes); |
2438 | - } else return ''; |
|
2569 | + } else { |
|
2570 | + return ''; |
|
2571 | + } |
|
2439 | 2572 | } |
2440 | 2573 | |
2441 | 2574 | /** |
@@ -2458,7 +2591,9 @@ discard block |
||
2458 | 2591 | $sth->closeCursor(); |
2459 | 2592 | if (isset($row['icaotypecode'])) { |
2460 | 2593 | return $row['icaotypecode']; |
2461 | - } else return ''; |
|
2594 | + } else { |
|
2595 | + return ''; |
|
2596 | + } |
|
2462 | 2597 | } |
2463 | 2598 | |
2464 | 2599 | /** |
@@ -2504,7 +2639,9 @@ discard block |
||
2504 | 2639 | $sth->closeCursor(); |
2505 | 2640 | if (isset($row['operator_correct'])) { |
2506 | 2641 | return $row['operator_correct']; |
2507 | - } else return $operator; |
|
2642 | + } else { |
|
2643 | + return $operator; |
|
2644 | + } |
|
2508 | 2645 | } |
2509 | 2646 | |
2510 | 2647 | /** |
@@ -2517,7 +2654,9 @@ discard block |
||
2517 | 2654 | public function getRouteInfo($callsign) |
2518 | 2655 | { |
2519 | 2656 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
2520 | - if ($callsign == '') return array(); |
|
2657 | + if ($callsign == '') { |
|
2658 | + return array(); |
|
2659 | + } |
|
2521 | 2660 | $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
2522 | 2661 | |
2523 | 2662 | $sth = $this->db->prepare($query); |
@@ -2527,7 +2666,9 @@ discard block |
||
2527 | 2666 | $sth->closeCursor(); |
2528 | 2667 | if (count($row) > 0) { |
2529 | 2668 | return $row; |
2530 | - } else return array(); |
|
2669 | + } else { |
|
2670 | + return array(); |
|
2671 | + } |
|
2531 | 2672 | } |
2532 | 2673 | |
2533 | 2674 | /** |
@@ -2580,7 +2721,9 @@ discard block |
||
2580 | 2721 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
2581 | 2722 | $sth->closeCursor(); |
2582 | 2723 | return $result; |
2583 | - } else return array(); |
|
2724 | + } else { |
|
2725 | + return array(); |
|
2726 | + } |
|
2584 | 2727 | } |
2585 | 2728 | |
2586 | 2729 | |
@@ -2739,8 +2882,11 @@ discard block |
||
2739 | 2882 | $query .= " ORDER BY spotter_output.source_name ASC"; |
2740 | 2883 | |
2741 | 2884 | $sth = $this->db->prepare($query); |
2742 | - if (!empty($query_values)) $sth->execute($query_values); |
|
2743 | - else $sth->execute(); |
|
2885 | + if (!empty($query_values)) { |
|
2886 | + $sth->execute($query_values); |
|
2887 | + } else { |
|
2888 | + $sth->execute(); |
|
2889 | + } |
|
2744 | 2890 | |
2745 | 2891 | $source_array = array(); |
2746 | 2892 | $temp_array = array(); |
@@ -2773,9 +2919,13 @@ discard block |
||
2773 | 2919 | WHERE spotter_output.airline_icao <> '' |
2774 | 2920 | ORDER BY spotter_output.airline_name ASC"; |
2775 | 2921 | */ |
2776 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2777 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2778 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2922 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2923 | + $forsource = $globalAirlinesSource; |
|
2924 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2925 | + $forsource = 'vatsim'; |
|
2926 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2927 | + $forsource = 'ivao'; |
|
2928 | + } |
|
2779 | 2929 | if ($forsource === NULL) { |
2780 | 2930 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; |
2781 | 2931 | $query_data = array(); |
@@ -2818,9 +2968,13 @@ discard block |
||
2818 | 2968 | { |
2819 | 2969 | global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
2820 | 2970 | $filter_query = $this->getFilter($filters,true,true); |
2821 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2822 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2823 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2971 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2972 | + $forsource = $globalAirlinesSource; |
|
2973 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2974 | + $forsource = 'vatsim'; |
|
2975 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2976 | + $forsource = 'ivao'; |
|
2977 | + } |
|
2824 | 2978 | if ($forsource === NULL) { |
2825 | 2979 | $query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC"; |
2826 | 2980 | $query_data = array(); |
@@ -3131,7 +3285,9 @@ discard block |
||
3131 | 3285 | date_default_timezone_set($globalTimezone); |
3132 | 3286 | $datetime = new DateTime(); |
3133 | 3287 | $offset = $datetime->format('P'); |
3134 | - } else $offset = '+00:00'; |
|
3288 | + } else { |
|
3289 | + $offset = '+00:00'; |
|
3290 | + } |
|
3135 | 3291 | if ($airport_icao == '') { |
3136 | 3292 | if ($globalDBdriver == 'mysql') { |
3137 | 3293 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -3163,7 +3319,9 @@ discard block |
||
3163 | 3319 | date_default_timezone_set($globalTimezone); |
3164 | 3320 | $datetime = new DateTime(); |
3165 | 3321 | $offset = $datetime->format('P'); |
3166 | - } else $offset = '+00:00'; |
|
3322 | + } else { |
|
3323 | + $offset = '+00:00'; |
|
3324 | + } |
|
3167 | 3325 | if ($airport_icao == '') { |
3168 | 3326 | if ($globalDBdriver == 'mysql') { |
3169 | 3327 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -3196,7 +3354,9 @@ discard block |
||
3196 | 3354 | date_default_timezone_set($globalTimezone); |
3197 | 3355 | $datetime = new DateTime(); |
3198 | 3356 | $offset = $datetime->format('P'); |
3199 | - } else $offset = '+00:00'; |
|
3357 | + } else { |
|
3358 | + $offset = '+00:00'; |
|
3359 | + } |
|
3200 | 3360 | if ($airport_icao == '') { |
3201 | 3361 | if ($globalDBdriver == 'mysql') { |
3202 | 3362 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3235,7 +3395,9 @@ discard block |
||
3235 | 3395 | date_default_timezone_set($globalTimezone); |
3236 | 3396 | $datetime = new DateTime(); |
3237 | 3397 | $offset = $datetime->format('P'); |
3238 | - } else $offset = '+00:00'; |
|
3398 | + } else { |
|
3399 | + $offset = '+00:00'; |
|
3400 | + } |
|
3239 | 3401 | if ($airport_icao == '') { |
3240 | 3402 | if ($globalDBdriver == 'mysql') { |
3241 | 3403 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3280,7 +3442,9 @@ discard block |
||
3280 | 3442 | date_default_timezone_set($globalTimezone); |
3281 | 3443 | $datetime = new DateTime(); |
3282 | 3444 | $offset = $datetime->format('P'); |
3283 | - } else $offset = '+00:00'; |
|
3445 | + } else { |
|
3446 | + $offset = '+00:00'; |
|
3447 | + } |
|
3284 | 3448 | if ($airport_icao == '') { |
3285 | 3449 | if ($globalDBdriver == 'mysql') { |
3286 | 3450 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -3315,7 +3479,9 @@ discard block |
||
3315 | 3479 | date_default_timezone_set($globalTimezone); |
3316 | 3480 | $datetime = new DateTime(); |
3317 | 3481 | $offset = $datetime->format('P'); |
3318 | - } else $offset = '+00:00'; |
|
3482 | + } else { |
|
3483 | + $offset = '+00:00'; |
|
3484 | + } |
|
3319 | 3485 | if ($airport_icao == '') { |
3320 | 3486 | if ($globalDBdriver == 'mysql') { |
3321 | 3487 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3357,7 +3523,9 @@ discard block |
||
3357 | 3523 | date_default_timezone_set($globalTimezone); |
3358 | 3524 | $datetime = new DateTime(); |
3359 | 3525 | $offset = $datetime->format('P'); |
3360 | - } else $offset = '+00:00'; |
|
3526 | + } else { |
|
3527 | + $offset = '+00:00'; |
|
3528 | + } |
|
3361 | 3529 | if ($airport_icao == '') { |
3362 | 3530 | if ($globalDBdriver == 'mysql') { |
3363 | 3531 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -3391,7 +3559,9 @@ discard block |
||
3391 | 3559 | date_default_timezone_set($globalTimezone); |
3392 | 3560 | $datetime = new DateTime(); |
3393 | 3561 | $offset = $datetime->format('P'); |
3394 | - } else $offset = '+00:00'; |
|
3562 | + } else { |
|
3563 | + $offset = '+00:00'; |
|
3564 | + } |
|
3395 | 3565 | if ($airport_icao == '') { |
3396 | 3566 | if ($globalDBdriver == 'mysql') { |
3397 | 3567 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3439,7 +3609,9 @@ discard block |
||
3439 | 3609 | date_default_timezone_set($globalTimezone); |
3440 | 3610 | $datetime = new DateTime(); |
3441 | 3611 | $offset = $datetime->format('P'); |
3442 | - } else $offset = '+00:00'; |
|
3612 | + } else { |
|
3613 | + $offset = '+00:00'; |
|
3614 | + } |
|
3443 | 3615 | |
3444 | 3616 | if ($globalDBdriver == 'mysql') { |
3445 | 3617 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
@@ -3559,7 +3731,9 @@ discard block |
||
3559 | 3731 | */ |
3560 | 3732 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
3561 | 3733 | { |
3562 | - if ($groundspeed == '') $groundspeed = NULL; |
|
3734 | + if ($groundspeed == '') { |
|
3735 | + $groundspeed = NULL; |
|
3736 | + } |
|
3563 | 3737 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
3564 | 3738 | $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
3565 | 3739 | |
@@ -3609,10 +3783,18 @@ discard block |
||
3609 | 3783 | $Image = new Image($this->db); |
3610 | 3784 | $Common = new Common(); |
3611 | 3785 | |
3612 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
3613 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
3614 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
3615 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
3786 | + if (!isset($globalIVAO)) { |
|
3787 | + $globalIVAO = FALSE; |
|
3788 | + } |
|
3789 | + if (!isset($globalVATSIM)) { |
|
3790 | + $globalVATSIM = FALSE; |
|
3791 | + } |
|
3792 | + if (!isset($globalphpVMS)) { |
|
3793 | + $globalphpVMS = FALSE; |
|
3794 | + } |
|
3795 | + if (!isset($globalVAM)) { |
|
3796 | + $globalVAM = FALSE; |
|
3797 | + } |
|
3616 | 3798 | date_default_timezone_set('UTC'); |
3617 | 3799 | |
3618 | 3800 | //getting the registration |
@@ -3625,23 +3807,33 @@ discard block |
||
3625 | 3807 | if ($ModeS != '') { |
3626 | 3808 | $timeelapsed = microtime(true); |
3627 | 3809 | $registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type); |
3628 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3810 | + if ($globalDebugTimeElapsed) { |
|
3811 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3812 | + } |
|
3629 | 3813 | } else { |
3630 | 3814 | $myhex = explode('-',$flightaware_id); |
3631 | 3815 | if (count($myhex) > 0) { |
3632 | 3816 | $timeelapsed = microtime(true); |
3633 | 3817 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type); |
3634 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3818 | + if ($globalDebugTimeElapsed) { |
|
3819 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3820 | + } |
|
3635 | 3821 | } |
3636 | 3822 | } |
3637 | 3823 | } |
3638 | 3824 | } |
3639 | 3825 | $fromsource = NULL; |
3640 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
3641 | - elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
|
3642 | - elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
|
3643 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
3644 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
3826 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
3827 | + $fromsource = $globalAirlinesSource; |
|
3828 | + } elseif ($format_source == 'vatsimtxt') { |
|
3829 | + $fromsource = 'vatsim'; |
|
3830 | + } elseif ($format_source == 'whazzup') { |
|
3831 | + $fromsource = 'ivao'; |
|
3832 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
3833 | + $fromsource = 'vatsim'; |
|
3834 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
3835 | + $fromsource = 'ivao'; |
|
3836 | + } |
|
3645 | 3837 | //getting the airline information |
3646 | 3838 | if ($ident != "") |
3647 | 3839 | { |
@@ -3665,15 +3857,21 @@ discard block |
||
3665 | 3857 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
3666 | 3858 | $airline_array = $this->getAllAirlineInfo("NA"); |
3667 | 3859 | } |
3668 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3860 | + if ($globalDebugTimeElapsed) { |
|
3861 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3862 | + } |
|
3669 | 3863 | |
3670 | 3864 | } else { |
3671 | 3865 | $timeelapsed = microtime(true); |
3672 | 3866 | $airline_array = $this->getAllAirlineInfo("NA"); |
3673 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3867 | + if ($globalDebugTimeElapsed) { |
|
3868 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3869 | + } |
|
3674 | 3870 | } |
3675 | 3871 | } |
3676 | - } else $airline_array = array(); |
|
3872 | + } else { |
|
3873 | + $airline_array = array(); |
|
3874 | + } |
|
3677 | 3875 | |
3678 | 3876 | //getting the aircraft information |
3679 | 3877 | $aircraft_array = array(); |
@@ -3687,27 +3885,37 @@ discard block |
||
3687 | 3885 | { |
3688 | 3886 | $timeelapsed = microtime(true); |
3689 | 3887 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3690 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3888 | + if ($globalDebugTimeElapsed) { |
|
3889 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3890 | + } |
|
3691 | 3891 | } else { |
3692 | 3892 | $timeelapsed = microtime(true); |
3693 | 3893 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3694 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3894 | + if ($globalDebugTimeElapsed) { |
|
3895 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3896 | + } |
|
3695 | 3897 | } |
3696 | 3898 | } |
3697 | 3899 | } else { |
3698 | 3900 | if ($ModeS != '') { |
3699 | 3901 | $timeelapsed = microtime(true); |
3700 | 3902 | $aircraft_icao = $this->getAllAircraftType($ModeS,$source_type); |
3701 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3903 | + if ($globalDebugTimeElapsed) { |
|
3904 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3905 | + } |
|
3702 | 3906 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
3703 | 3907 | { |
3704 | 3908 | $timeelapsed = microtime(true); |
3705 | 3909 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3706 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3910 | + if ($globalDebugTimeElapsed) { |
|
3911 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3912 | + } |
|
3707 | 3913 | } else { |
3708 | 3914 | $timeelapsed = microtime(true); |
3709 | 3915 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3710 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3916 | + if ($globalDebugTimeElapsed) { |
|
3917 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3918 | + } |
|
3711 | 3919 | } |
3712 | 3920 | } |
3713 | 3921 | } |
@@ -3723,7 +3931,9 @@ discard block |
||
3723 | 3931 | } else { |
3724 | 3932 | $timeelapsed = microtime(true); |
3725 | 3933 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
3726 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3934 | + if ($globalDebugTimeElapsed) { |
|
3935 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3936 | + } |
|
3727 | 3937 | } |
3728 | 3938 | } |
3729 | 3939 | |
@@ -3738,7 +3948,9 @@ discard block |
||
3738 | 3948 | } else { |
3739 | 3949 | $timeelapsed = microtime(true); |
3740 | 3950 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
3741 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3951 | + if ($globalDebugTimeElapsed) { |
|
3952 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3953 | + } |
|
3742 | 3954 | } |
3743 | 3955 | } |
3744 | 3956 | |
@@ -3772,7 +3984,9 @@ discard block |
||
3772 | 3984 | { |
3773 | 3985 | return false; |
3774 | 3986 | } |
3775 | - } else $altitude = 0; |
|
3987 | + } else { |
|
3988 | + $altitude = 0; |
|
3989 | + } |
|
3776 | 3990 | |
3777 | 3991 | if ($heading != "") |
3778 | 3992 | { |
@@ -3801,7 +4015,9 @@ discard block |
||
3801 | 4015 | { |
3802 | 4016 | $timeelapsed = microtime(true); |
3803 | 4017 | $image_array = $Image->getSpotterImage($registration); |
3804 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4018 | + if ($globalDebugTimeElapsed) { |
|
4019 | + echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4020 | + } |
|
3805 | 4021 | if (!isset($image_array[0]['registration'])) |
3806 | 4022 | { |
3807 | 4023 | //echo "Add image !!!! \n"; |
@@ -3809,14 +4025,21 @@ discard block |
||
3809 | 4025 | } |
3810 | 4026 | $timeelapsed = microtime(true); |
3811 | 4027 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
3812 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3813 | - if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
4028 | + if ($globalDebugTimeElapsed) { |
|
4029 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4030 | + } |
|
4031 | + if ($owner_info['owner'] != '') { |
|
4032 | + $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
4033 | + } |
|
3814 | 4034 | } |
3815 | 4035 | |
3816 | 4036 | if (($globalIVAO || $globalVATSIM || $globalphpVMS || $globalVAM) && $aircraft_icao != '') |
3817 | 4037 | { |
3818 | - if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
3819 | - else $airline_icao = ''; |
|
4038 | + if (isset($airline_array[0]['icao'])) { |
|
4039 | + $airline_icao = $airline_array[0]['icao']; |
|
4040 | + } else { |
|
4041 | + $airline_icao = ''; |
|
4042 | + } |
|
3820 | 4043 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
3821 | 4044 | if (!isset($image_array[0]['registration'])) |
3822 | 4045 | { |
@@ -3861,16 +4084,28 @@ discard block |
||
3861 | 4084 | { |
3862 | 4085 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
3863 | 4086 | } |
3864 | - if ($registration == '') $registration = 'NA'; |
|
4087 | + if ($registration == '') { |
|
4088 | + $registration = 'NA'; |
|
4089 | + } |
|
3865 | 4090 | if ($latitude == '' && $longitude == '') { |
3866 | 4091 | $latitude = 0; |
3867 | 4092 | $longitude = 0; |
3868 | 4093 | } |
3869 | - if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
3870 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
3871 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
3872 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
3873 | - if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
4094 | + if ($squawk == '' || $Common->isInteger($squawk) === false) { |
|
4095 | + $squawk = NULL; |
|
4096 | + } |
|
4097 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) { |
|
4098 | + $verticalrate = NULL; |
|
4099 | + } |
|
4100 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
4101 | + $heading = 0; |
|
4102 | + } |
|
4103 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
4104 | + $groundspeed = 0; |
|
4105 | + } |
|
4106 | + if (!isset($aircraft_owner)) { |
|
4107 | + $aircraft_owner = NULL; |
|
4108 | + } |
|
3874 | 4109 | $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
3875 | 4110 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
3876 | 4111 | |
@@ -3881,9 +4116,13 @@ discard block |
||
3881 | 4116 | if ($airline_type == '') { |
3882 | 4117 | $timeelapsed = microtime(true); |
3883 | 4118 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
3884 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4119 | + if ($globalDebugTimeElapsed) { |
|
4120 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
4121 | + } |
|
4122 | + } |
|
4123 | + if ($airline_type == null) { |
|
4124 | + $airline_type = ''; |
|
3885 | 4125 | } |
3886 | - if ($airline_type == null) $airline_type = ''; |
|
3887 | 4126 | $aircraft_type = $aircraft_array[0]['type']; |
3888 | 4127 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
3889 | 4128 | $departure_airport_name = $departure_airport_array[0]['name']; |
@@ -4047,7 +4286,9 @@ discard block |
||
4047 | 4286 | } |
4048 | 4287 | } |
4049 | 4288 | $query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
4050 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4289 | + if ($limit) { |
|
4290 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4291 | + } |
|
4051 | 4292 | |
4052 | 4293 | $sth = $this->db->prepare($query); |
4053 | 4294 | $sth->execute($query_values); |
@@ -4120,7 +4361,9 @@ discard block |
||
4120 | 4361 | } |
4121 | 4362 | |
4122 | 4363 | $query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
4123 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4364 | + if ($limit) { |
|
4365 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4366 | + } |
|
4124 | 4367 | |
4125 | 4368 | |
4126 | 4369 | $sth = $this->db->prepare($query); |
@@ -4164,7 +4407,9 @@ discard block |
||
4164 | 4407 | } |
4165 | 4408 | } |
4166 | 4409 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
4167 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4410 | + if ($limit) { |
|
4411 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4412 | + } |
|
4168 | 4413 | |
4169 | 4414 | |
4170 | 4415 | $sth = $this->db->prepare($query); |
@@ -4240,7 +4485,9 @@ discard block |
||
4240 | 4485 | } |
4241 | 4486 | } |
4242 | 4487 | $query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
4243 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4488 | + if ($limit) { |
|
4489 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4490 | + } |
|
4244 | 4491 | |
4245 | 4492 | $sth = $this->db->prepare($query); |
4246 | 4493 | $sth->execute($query_values); |
@@ -4282,7 +4529,9 @@ discard block |
||
4282 | 4529 | } |
4283 | 4530 | } |
4284 | 4531 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
4285 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4532 | + if ($limit) { |
|
4533 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4534 | + } |
|
4286 | 4535 | |
4287 | 4536 | |
4288 | 4537 | $sth = $this->db->prepare($query); |
@@ -4527,7 +4776,9 @@ discard block |
||
4527 | 4776 | date_default_timezone_set($globalTimezone); |
4528 | 4777 | $datetime = new DateTime($date); |
4529 | 4778 | $offset = $datetime->format('P'); |
4530 | - } else $offset = '+00:00'; |
|
4779 | + } else { |
|
4780 | + $offset = '+00:00'; |
|
4781 | + } |
|
4531 | 4782 | |
4532 | 4783 | if ($globalDBdriver == 'mysql') { |
4533 | 4784 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
@@ -4575,7 +4826,9 @@ discard block |
||
4575 | 4826 | date_default_timezone_set($globalTimezone); |
4576 | 4827 | $datetime = new DateTime($date); |
4577 | 4828 | $offset = $datetime->format('P'); |
4578 | - } else $offset = '+00:00'; |
|
4829 | + } else { |
|
4830 | + $offset = '+00:00'; |
|
4831 | + } |
|
4579 | 4832 | |
4580 | 4833 | if ($globalDBdriver == 'mysql') { |
4581 | 4834 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
@@ -4695,9 +4948,13 @@ discard block |
||
4695 | 4948 | $sth = $this->db->prepare($query); |
4696 | 4949 | $sth->execute($query_values); |
4697 | 4950 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
4698 | - if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
4699 | - elseif ($result[0]['duration'] == '') return 0; |
|
4700 | - else return $result[0]['duration']; |
|
4951 | + if (is_numeric($result[0]['duration'])) { |
|
4952 | + return gmdate('H:i:s',$result[0]['duration']); |
|
4953 | + } elseif ($result[0]['duration'] == '') { |
|
4954 | + return 0; |
|
4955 | + } else { |
|
4956 | + return $result[0]['duration']; |
|
4957 | + } |
|
4701 | 4958 | } |
4702 | 4959 | |
4703 | 4960 | /** |
@@ -4786,8 +5043,11 @@ discard block |
||
4786 | 5043 | $sth = $this->db->prepare($query); |
4787 | 5044 | $sth->execute($query_values); |
4788 | 5045 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
4789 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
4790 | - else return $result[0]['duration']; |
|
5046 | + if (is_int($result[0]['duration'])) { |
|
5047 | + return gmdate('H:i:s',$result[0]['duration']); |
|
5048 | + } else { |
|
5049 | + return $result[0]['duration']; |
|
5050 | + } |
|
4791 | 5051 | } |
4792 | 5052 | |
4793 | 5053 | /** |
@@ -4992,7 +5252,9 @@ discard block |
||
4992 | 5252 | } |
4993 | 5253 | $query .= " GROUP BY spotter_output.airline_country, countries.iso3 |
4994 | 5254 | ORDER BY airline_country_count DESC"; |
4995 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5255 | + if ($limit) { |
|
5256 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5257 | + } |
|
4996 | 5258 | |
4997 | 5259 | $sth = $this->db->prepare($query); |
4998 | 5260 | $sth->execute($query_values); |
@@ -5021,7 +5283,9 @@ discard block |
||
5021 | 5283 | global $globalDBdriver; |
5022 | 5284 | //$filter_query = $this->getFilter($filters,true,true); |
5023 | 5285 | $Connection= new Connection($this->db); |
5024 | - if (!$Connection->tableExists('countries')) return array(); |
|
5286 | + if (!$Connection->tableExists('countries')) { |
|
5287 | + return array(); |
|
5288 | + } |
|
5025 | 5289 | /* |
5026 | 5290 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
5027 | 5291 | FROM countries c, spotter_output s |
@@ -5053,7 +5317,9 @@ discard block |
||
5053 | 5317 | } |
5054 | 5318 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country "; |
5055 | 5319 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
5056 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5320 | + if ($limit) { |
|
5321 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5322 | + } |
|
5057 | 5323 | |
5058 | 5324 | |
5059 | 5325 | $sth = $this->db->prepare($query); |
@@ -5130,7 +5396,9 @@ discard block |
||
5130 | 5396 | } |
5131 | 5397 | |
5132 | 5398 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5133 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5399 | + if ($limit) { |
|
5400 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5401 | + } |
|
5134 | 5402 | |
5135 | 5403 | $sth = $this->db->prepare($query); |
5136 | 5404 | $sth->execute($query_values); |
@@ -5204,7 +5472,9 @@ discard block |
||
5204 | 5472 | } |
5205 | 5473 | |
5206 | 5474 | $query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5207 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5475 | + if ($limit) { |
|
5476 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5477 | + } |
|
5208 | 5478 | |
5209 | 5479 | $sth = $this->db->prepare($query); |
5210 | 5480 | $sth->execute($query_values); |
@@ -5251,7 +5521,9 @@ discard block |
||
5251 | 5521 | } |
5252 | 5522 | |
5253 | 5523 | $query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
5254 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5524 | + if ($limit) { |
|
5525 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5526 | + } |
|
5255 | 5527 | |
5256 | 5528 | $sth = $this->db->prepare($query); |
5257 | 5529 | $sth->execute(); |
@@ -5304,7 +5576,9 @@ discard block |
||
5304 | 5576 | if($row['registration'] != "") |
5305 | 5577 | { |
5306 | 5578 | $image_array = $Image->getSpotterImage($row['registration']); |
5307 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5579 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5580 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5581 | + } |
|
5308 | 5582 | } |
5309 | 5583 | $temp_array['registration_count'] = $row['registration_count']; |
5310 | 5584 | |
@@ -5379,7 +5653,9 @@ discard block |
||
5379 | 5653 | if($row['registration'] != "") |
5380 | 5654 | { |
5381 | 5655 | $image_array = $Image->getSpotterImage($row['registration']); |
5382 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5656 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5657 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5658 | + } |
|
5383 | 5659 | } |
5384 | 5660 | $temp_array['registration_count'] = $row['registration_count']; |
5385 | 5661 | |
@@ -5486,7 +5762,9 @@ discard block |
||
5486 | 5762 | if($row['registration'] != "") |
5487 | 5763 | { |
5488 | 5764 | $image_array = $Image->getSpotterImage($row['registration']); |
5489 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5765 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5766 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5767 | + } |
|
5490 | 5768 | } |
5491 | 5769 | $temp_array['registration_count'] = $row['registration_count']; |
5492 | 5770 | $aircraft_array[] = $temp_array; |
@@ -5611,7 +5889,9 @@ discard block |
||
5611 | 5889 | date_default_timezone_set($globalTimezone); |
5612 | 5890 | $datetime = new DateTime($date); |
5613 | 5891 | $offset = $datetime->format('P'); |
5614 | - } else $offset = '+00:00'; |
|
5892 | + } else { |
|
5893 | + $offset = '+00:00'; |
|
5894 | + } |
|
5615 | 5895 | |
5616 | 5896 | if ($globalDBdriver == 'mysql') { |
5617 | 5897 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
@@ -5658,7 +5938,9 @@ discard block |
||
5658 | 5938 | date_default_timezone_set($globalTimezone); |
5659 | 5939 | $datetime = new DateTime($date); |
5660 | 5940 | $offset = $datetime->format('P'); |
5661 | - } else $offset = '+00:00'; |
|
5941 | + } else { |
|
5942 | + $offset = '+00:00'; |
|
5943 | + } |
|
5662 | 5944 | |
5663 | 5945 | if ($globalDBdriver == 'mysql') { |
5664 | 5946 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
@@ -5687,7 +5969,9 @@ discard block |
||
5687 | 5969 | if($row['registration'] != "") |
5688 | 5970 | { |
5689 | 5971 | $image_array = $Image->getSpotterImage($row['registration']); |
5690 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5972 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5973 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5974 | + } |
|
5691 | 5975 | } |
5692 | 5976 | $temp_array['registration_count'] = $row['registration_count']; |
5693 | 5977 | |
@@ -5712,7 +5996,9 @@ discard block |
||
5712 | 5996 | date_default_timezone_set($globalTimezone); |
5713 | 5997 | $datetime = new DateTime($date); |
5714 | 5998 | $offset = $datetime->format('P'); |
5715 | - } else $offset = '+00:00'; |
|
5999 | + } else { |
|
6000 | + $offset = '+00:00'; |
|
6001 | + } |
|
5716 | 6002 | |
5717 | 6003 | if ($globalDBdriver == 'mysql') { |
5718 | 6004 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
@@ -5908,8 +6194,11 @@ discard block |
||
5908 | 6194 | if($row['registration'] != "") |
5909 | 6195 | { |
5910 | 6196 | $image_array = $Image->getSpotterImage($row['registration']); |
5911 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5912 | - else $temp_array['image_thumbnail'] = ''; |
|
6197 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6198 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6199 | + } else { |
|
6200 | + $temp_array['image_thumbnail'] = ''; |
|
6201 | + } |
|
5913 | 6202 | } |
5914 | 6203 | $temp_array['registration_count'] = $row['registration_count']; |
5915 | 6204 | $aircraft_array[] = $temp_array; |
@@ -5983,8 +6272,11 @@ discard block |
||
5983 | 6272 | if($row['registration'] != "") |
5984 | 6273 | { |
5985 | 6274 | $image_array = $Image->getSpotterImage($row['registration']); |
5986 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5987 | - else $temp_array['image_thumbnail'] = ''; |
|
6275 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6276 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6277 | + } else { |
|
6278 | + $temp_array['image_thumbnail'] = ''; |
|
6279 | + } |
|
5988 | 6280 | } |
5989 | 6281 | $temp_array['registration_count'] = $row['registration_count']; |
5990 | 6282 | $aircraft_array[] = $temp_array; |
@@ -6058,8 +6350,11 @@ discard block |
||
6058 | 6350 | if($row['registration'] != "") |
6059 | 6351 | { |
6060 | 6352 | $image_array = $Image->getSpotterImage($row['registration']); |
6061 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6062 | - else $temp_array['image_thumbnail'] = ''; |
|
6353 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6354 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6355 | + } else { |
|
6356 | + $temp_array['image_thumbnail'] = ''; |
|
6357 | + } |
|
6063 | 6358 | } |
6064 | 6359 | $temp_array['registration_count'] = $row['registration_count']; |
6065 | 6360 | $aircraft_array[] = $temp_array; |
@@ -6270,7 +6565,9 @@ discard block |
||
6270 | 6565 | if($row['registration'] != "") |
6271 | 6566 | { |
6272 | 6567 | $image_array = $Image->getSpotterImage($row['registration']); |
6273 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6568 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6569 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6570 | + } |
|
6274 | 6571 | } |
6275 | 6572 | $temp_array['registration_count'] = $row['registration_count']; |
6276 | 6573 | |
@@ -6387,7 +6684,9 @@ discard block |
||
6387 | 6684 | if($row['registration'] != "") |
6388 | 6685 | { |
6389 | 6686 | $image_array = $Image->getSpotterImage($row['registration']); |
6390 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6687 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6688 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6689 | + } |
|
6391 | 6690 | } |
6392 | 6691 | $temp_array['registration_count'] = $row['registration_count']; |
6393 | 6692 | |
@@ -6553,7 +6852,9 @@ discard block |
||
6553 | 6852 | } |
6554 | 6853 | } |
6555 | 6854 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
6556 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6855 | + if ($limit) { |
|
6856 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6857 | + } |
|
6557 | 6858 | |
6558 | 6859 | $sth = $this->db->prepare($query); |
6559 | 6860 | $sth->execute($query_values); |
@@ -6572,7 +6873,9 @@ discard block |
||
6572 | 6873 | if($row['registration'] != "") |
6573 | 6874 | { |
6574 | 6875 | $image_array = $Image->getSpotterImage($row['registration']); |
6575 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6876 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6877 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6878 | + } |
|
6576 | 6879 | } |
6577 | 6880 | |
6578 | 6881 | $aircraft_array[] = $temp_array; |
@@ -6613,7 +6916,9 @@ discard block |
||
6613 | 6916 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
6614 | 6917 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6615 | 6918 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
6616 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6919 | + if ($limit) { |
|
6920 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6921 | + } |
|
6617 | 6922 | |
6618 | 6923 | $sth = $this->db->prepare($query); |
6619 | 6924 | $sth->execute(); |
@@ -6633,7 +6938,9 @@ discard block |
||
6633 | 6938 | if($row['registration'] != "") |
6634 | 6939 | { |
6635 | 6940 | $image_array = $Image->getSpotterImage($row['registration']); |
6636 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6941 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
6942 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
6943 | + } |
|
6637 | 6944 | } |
6638 | 6945 | |
6639 | 6946 | $aircraft_array[] = $temp_array; |
@@ -6699,7 +7006,9 @@ discard block |
||
6699 | 7006 | } |
6700 | 7007 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude |
6701 | 7008 | ORDER BY airport_departure_icao_count DESC"; |
6702 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7009 | + if ($limit) { |
|
7010 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7011 | + } |
|
6703 | 7012 | |
6704 | 7013 | $sth = $this->db->prepare($query); |
6705 | 7014 | $sth->execute($query_values); |
@@ -6751,7 +7060,9 @@ discard block |
||
6751 | 7060 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6752 | 7061 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
6753 | 7062 | ORDER BY airport_departure_icao_count DESC"; |
6754 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7063 | + if ($limit) { |
|
7064 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7065 | + } |
|
6755 | 7066 | |
6756 | 7067 | $sth = $this->db->prepare($query); |
6757 | 7068 | $sth->execute(); |
@@ -6829,7 +7140,9 @@ discard block |
||
6829 | 7140 | } |
6830 | 7141 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude |
6831 | 7142 | ORDER BY airport_departure_icao_count DESC"; |
6832 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7143 | + if ($limit) { |
|
7144 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7145 | + } |
|
6833 | 7146 | //echo $query; |
6834 | 7147 | $sth = $this->db->prepare($query); |
6835 | 7148 | $sth->execute($query_values); |
@@ -6883,7 +7196,9 @@ discard block |
||
6883 | 7196 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6884 | 7197 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
6885 | 7198 | ORDER BY airport_departure_icao_count DESC"; |
6886 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7199 | + if ($limit) { |
|
7200 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7201 | + } |
|
6887 | 7202 | |
6888 | 7203 | $sth = $this->db->prepare($query); |
6889 | 7204 | $sth->execute(); |
@@ -7274,7 +7589,9 @@ discard block |
||
7274 | 7589 | date_default_timezone_set($globalTimezone); |
7275 | 7590 | $datetime = new DateTime($date); |
7276 | 7591 | $offset = $datetime->format('P'); |
7277 | - } else $offset = '+00:00'; |
|
7592 | + } else { |
|
7593 | + $offset = '+00:00'; |
|
7594 | + } |
|
7278 | 7595 | |
7279 | 7596 | if ($globalDBdriver == 'mysql') { |
7280 | 7597 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
@@ -7324,7 +7641,9 @@ discard block |
||
7324 | 7641 | date_default_timezone_set($globalTimezone); |
7325 | 7642 | $datetime = new DateTime($date); |
7326 | 7643 | $offset = $datetime->format('P'); |
7327 | - } else $offset = '+00:00'; |
|
7644 | + } else { |
|
7645 | + $offset = '+00:00'; |
|
7646 | + } |
|
7328 | 7647 | |
7329 | 7648 | if ($globalDBdriver == 'mysql') { |
7330 | 7649 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
@@ -7673,7 +7992,9 @@ discard block |
||
7673 | 7992 | } |
7674 | 7993 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude |
7675 | 7994 | ORDER BY airport_arrival_icao_count DESC"; |
7676 | - if ($limit) $query .= " LIMIT 10"; |
|
7995 | + if ($limit) { |
|
7996 | + $query .= " LIMIT 10"; |
|
7997 | + } |
|
7677 | 7998 | |
7678 | 7999 | |
7679 | 8000 | $sth = $this->db->prepare($query); |
@@ -7695,7 +8016,9 @@ discard block |
||
7695 | 8016 | if ($icaoaskey) { |
7696 | 8017 | $icao = $row['arrival_airport_icao']; |
7697 | 8018 | $airport_array[$icao] = $temp_array; |
7698 | - } else $airport_array[] = $temp_array; |
|
8019 | + } else { |
|
8020 | + $airport_array[] = $temp_array; |
|
8021 | + } |
|
7699 | 8022 | } |
7700 | 8023 | |
7701 | 8024 | return $airport_array; |
@@ -7732,7 +8055,9 @@ discard block |
||
7732 | 8055 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
7733 | 8056 | $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, countries.iso3 |
7734 | 8057 | ORDER BY airport_arrival_icao_count DESC"; |
7735 | - if ($limit) $query .= " LIMIT 10"; |
|
8058 | + if ($limit) { |
|
8059 | + $query .= " LIMIT 10"; |
|
8060 | + } |
|
7736 | 8061 | |
7737 | 8062 | |
7738 | 8063 | $sth = $this->db->prepare($query); |
@@ -7754,7 +8079,9 @@ discard block |
||
7754 | 8079 | if ($icaoaskey) { |
7755 | 8080 | $icao = $row['arrival_airport_icao']; |
7756 | 8081 | $airport_array[$icao] = $temp_array; |
7757 | - } else $airport_array[] = $temp_array; |
|
8082 | + } else { |
|
8083 | + $airport_array[] = $temp_array; |
|
8084 | + } |
|
7758 | 8085 | } |
7759 | 8086 | |
7760 | 8087 | return $airport_array; |
@@ -7817,7 +8144,9 @@ discard block |
||
7817 | 8144 | } |
7818 | 8145 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude |
7819 | 8146 | ORDER BY airport_arrival_icao_count DESC"; |
7820 | - if ($limit) $query .= " LIMIT 10"; |
|
8147 | + if ($limit) { |
|
8148 | + $query .= " LIMIT 10"; |
|
8149 | + } |
|
7821 | 8150 | |
7822 | 8151 | |
7823 | 8152 | $sth = $this->db->prepare($query); |
@@ -7836,7 +8165,9 @@ discard block |
||
7836 | 8165 | if ($icaoaskey) { |
7837 | 8166 | $icao = $row['arrival_airport_icao']; |
7838 | 8167 | $airport_array[$icao] = $temp_array; |
7839 | - } else $airport_array[] = $temp_array; |
|
8168 | + } else { |
|
8169 | + $airport_array[] = $temp_array; |
|
8170 | + } |
|
7840 | 8171 | } |
7841 | 8172 | |
7842 | 8173 | return $airport_array; |
@@ -7873,7 +8204,9 @@ discard block |
||
7873 | 8204 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
7874 | 8205 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
7875 | 8206 | ORDER BY airport_arrival_icao_count DESC"; |
7876 | - if ($limit) $query .= " LIMIT 10"; |
|
8207 | + if ($limit) { |
|
8208 | + $query .= " LIMIT 10"; |
|
8209 | + } |
|
7877 | 8210 | |
7878 | 8211 | |
7879 | 8212 | $sth = $this->db->prepare($query); |
@@ -7894,7 +8227,9 @@ discard block |
||
7894 | 8227 | if ($icaoaskey) { |
7895 | 8228 | $icao = $row['arrival_airport_icao']; |
7896 | 8229 | $airport_array[$icao] = $temp_array; |
7897 | - } else $airport_array[] = $temp_array; |
|
8230 | + } else { |
|
8231 | + $airport_array[] = $temp_array; |
|
8232 | + } |
|
7898 | 8233 | } |
7899 | 8234 | |
7900 | 8235 | return $airport_array; |
@@ -8272,7 +8607,9 @@ discard block |
||
8272 | 8607 | date_default_timezone_set($globalTimezone); |
8273 | 8608 | $datetime = new DateTime($date); |
8274 | 8609 | $offset = $datetime->format('P'); |
8275 | - } else $offset = '+00:00'; |
|
8610 | + } else { |
|
8611 | + $offset = '+00:00'; |
|
8612 | + } |
|
8276 | 8613 | |
8277 | 8614 | if ($globalDBdriver == 'mysql') { |
8278 | 8615 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
@@ -8322,7 +8659,9 @@ discard block |
||
8322 | 8659 | date_default_timezone_set($globalTimezone); |
8323 | 8660 | $datetime = new DateTime($date); |
8324 | 8661 | $offset = $datetime->format('P'); |
8325 | - } else $offset = '+00:00'; |
|
8662 | + } else { |
|
8663 | + $offset = '+00:00'; |
|
8664 | + } |
|
8326 | 8665 | |
8327 | 8666 | if ($globalDBdriver == 'mysql') { |
8328 | 8667 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
@@ -8713,7 +9052,9 @@ discard block |
||
8713 | 9052 | } |
8714 | 9053 | $query .= " GROUP BY spotter_output.arrival_airport_country, countries.iso3 |
8715 | 9054 | ORDER BY airport_arrival_country_count DESC"; |
8716 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9055 | + if ($limit) { |
|
9056 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9057 | + } |
|
8717 | 9058 | |
8718 | 9059 | |
8719 | 9060 | $sth = $this->db->prepare($query); |
@@ -9001,7 +9342,9 @@ discard block |
||
9001 | 9342 | date_default_timezone_set($globalTimezone); |
9002 | 9343 | $datetime = new DateTime($date); |
9003 | 9344 | $offset = $datetime->format('P'); |
9004 | - } else $offset = '+00:00'; |
|
9345 | + } else { |
|
9346 | + $offset = '+00:00'; |
|
9347 | + } |
|
9005 | 9348 | |
9006 | 9349 | if ($globalDBdriver == 'mysql') { |
9007 | 9350 | $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
@@ -9257,12 +9600,18 @@ discard block |
||
9257 | 9600 | $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
9258 | 9601 | FROM spotter_output".$filter_query." spotter_output.ident <> ''"; |
9259 | 9602 | if ($olderthanmonths > 0) { |
9260 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
9261 | - else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
9603 | + if ($globalDBdriver == 'mysql') { |
|
9604 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
9605 | + } else { |
|
9606 | + $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
9607 | + } |
|
9262 | 9608 | } |
9263 | 9609 | if ($sincedate != '') { |
9264 | - if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
9265 | - else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
9610 | + if ($globalDBdriver == 'mysql') { |
|
9611 | + $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
9612 | + } else { |
|
9613 | + $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
9614 | + } |
|
9266 | 9615 | } |
9267 | 9616 | $query_values = array(); |
9268 | 9617 | if ($year != '') { |
@@ -9293,7 +9642,9 @@ discard block |
||
9293 | 9642 | } |
9294 | 9643 | } |
9295 | 9644 | $query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
9296 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9645 | + if ($limit) { |
|
9646 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9647 | + } |
|
9297 | 9648 | |
9298 | 9649 | $sth = $this->db->prepare($query); |
9299 | 9650 | $sth->execute($query_values); |
@@ -9327,15 +9678,23 @@ discard block |
||
9327 | 9678 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
9328 | 9679 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
9329 | 9680 | if ($olderthanmonths > 0) { |
9330 | - if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
9331 | - else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
9681 | + if ($globalDBdriver == 'mysql') { |
|
9682 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
9683 | + } else { |
|
9684 | + $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
9685 | + } |
|
9332 | 9686 | } |
9333 | 9687 | if ($sincedate != '') { |
9334 | - if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
9335 | - else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
9688 | + if ($globalDBdriver == 'mysql') { |
|
9689 | + $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
9690 | + } else { |
|
9691 | + $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
9692 | + } |
|
9336 | 9693 | } |
9337 | 9694 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
9338 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
9695 | + if ($limit) { |
|
9696 | + $query .= " LIMIT 10 OFFSET 0"; |
|
9697 | + } |
|
9339 | 9698 | |
9340 | 9699 | $sth = $this->db->prepare($query); |
9341 | 9700 | $sth->execute(); |
@@ -9372,7 +9731,9 @@ discard block |
||
9372 | 9731 | date_default_timezone_set($globalTimezone); |
9373 | 9732 | $datetime = new DateTime(); |
9374 | 9733 | $offset = $datetime->format('P'); |
9375 | - } else $offset = '+00:00'; |
|
9734 | + } else { |
|
9735 | + $offset = '+00:00'; |
|
9736 | + } |
|
9376 | 9737 | |
9377 | 9738 | if ($globalDBdriver == 'mysql') { |
9378 | 9739 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9421,7 +9782,9 @@ discard block |
||
9421 | 9782 | date_default_timezone_set($globalTimezone); |
9422 | 9783 | $datetime = new DateTime(); |
9423 | 9784 | $offset = $datetime->format('P'); |
9424 | - } else $offset = '+00:00'; |
|
9785 | + } else { |
|
9786 | + $offset = '+00:00'; |
|
9787 | + } |
|
9425 | 9788 | $filter_query = $this->getFilter($filters,true,true); |
9426 | 9789 | if ($globalDBdriver == 'mysql') { |
9427 | 9790 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9470,7 +9833,9 @@ discard block |
||
9470 | 9833 | date_default_timezone_set($globalTimezone); |
9471 | 9834 | $datetime = new DateTime(); |
9472 | 9835 | $offset = $datetime->format('P'); |
9473 | - } else $offset = '+00:00'; |
|
9836 | + } else { |
|
9837 | + $offset = '+00:00'; |
|
9838 | + } |
|
9474 | 9839 | $filter_query = $this->getFilter($filters,true,true); |
9475 | 9840 | if ($globalDBdriver == 'mysql') { |
9476 | 9841 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9516,7 +9881,9 @@ discard block |
||
9516 | 9881 | date_default_timezone_set($globalTimezone); |
9517 | 9882 | $datetime = new DateTime(); |
9518 | 9883 | $offset = $datetime->format('P'); |
9519 | - } else $offset = '+00:00'; |
|
9884 | + } else { |
|
9885 | + $offset = '+00:00'; |
|
9886 | + } |
|
9520 | 9887 | $filter_query = $this->getFilter($filters,true,true); |
9521 | 9888 | if ($globalDBdriver == 'mysql') { |
9522 | 9889 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9564,7 +9931,9 @@ discard block |
||
9564 | 9931 | date_default_timezone_set($globalTimezone); |
9565 | 9932 | $datetime = new DateTime(); |
9566 | 9933 | $offset = $datetime->format('P'); |
9567 | - } else $offset = '+00:00'; |
|
9934 | + } else { |
|
9935 | + $offset = '+00:00'; |
|
9936 | + } |
|
9568 | 9937 | |
9569 | 9938 | if ($globalDBdriver == 'mysql') { |
9570 | 9939 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -9612,7 +9981,9 @@ discard block |
||
9612 | 9981 | date_default_timezone_set($globalTimezone); |
9613 | 9982 | $datetime = new DateTime(); |
9614 | 9983 | $offset = $datetime->format('P'); |
9615 | - } else $offset = '+00:00'; |
|
9984 | + } else { |
|
9985 | + $offset = '+00:00'; |
|
9986 | + } |
|
9616 | 9987 | |
9617 | 9988 | if ($globalDBdriver == 'mysql') { |
9618 | 9989 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9659,7 +10030,9 @@ discard block |
||
9659 | 10030 | date_default_timezone_set($globalTimezone); |
9660 | 10031 | $datetime = new DateTime(); |
9661 | 10032 | $offset = $datetime->format('P'); |
9662 | - } else $offset = '+00:00'; |
|
10033 | + } else { |
|
10034 | + $offset = '+00:00'; |
|
10035 | + } |
|
9663 | 10036 | |
9664 | 10037 | if ($globalDBdriver == 'mysql') { |
9665 | 10038 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9707,7 +10080,9 @@ discard block |
||
9707 | 10080 | date_default_timezone_set($globalTimezone); |
9708 | 10081 | $datetime = new DateTime(); |
9709 | 10082 | $offset = $datetime->format('P'); |
9710 | - } else $offset = '+00:00'; |
|
10083 | + } else { |
|
10084 | + $offset = '+00:00'; |
|
10085 | + } |
|
9711 | 10086 | $filter_query = $this->getFilter($filters,true,true); |
9712 | 10087 | if ($globalDBdriver == 'mysql') { |
9713 | 10088 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -9752,7 +10127,9 @@ discard block |
||
9752 | 10127 | date_default_timezone_set($globalTimezone); |
9753 | 10128 | $datetime = new DateTime(); |
9754 | 10129 | $offset = $datetime->format('P'); |
9755 | - } else $offset = '+00:00'; |
|
10130 | + } else { |
|
10131 | + $offset = '+00:00'; |
|
10132 | + } |
|
9756 | 10133 | $filter_query = $this->getFilter($filters,true,true); |
9757 | 10134 | |
9758 | 10135 | if ($globalDBdriver == 'mysql') { |
@@ -9799,7 +10176,9 @@ discard block |
||
9799 | 10176 | date_default_timezone_set($globalTimezone); |
9800 | 10177 | $datetime = new DateTime(); |
9801 | 10178 | $offset = $datetime->format('P'); |
9802 | - } else $offset = '+00:00'; |
|
10179 | + } else { |
|
10180 | + $offset = '+00:00'; |
|
10181 | + } |
|
9803 | 10182 | |
9804 | 10183 | if ($globalDBdriver == 'mysql') { |
9805 | 10184 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
@@ -9845,7 +10224,9 @@ discard block |
||
9845 | 10224 | date_default_timezone_set($globalTimezone); |
9846 | 10225 | $datetime = new DateTime(); |
9847 | 10226 | $offset = $datetime->format('P'); |
9848 | - } else $offset = '+00:00'; |
|
10227 | + } else { |
|
10228 | + $offset = '+00:00'; |
|
10229 | + } |
|
9849 | 10230 | $filter_query = $this->getFilter($filters,true,true); |
9850 | 10231 | |
9851 | 10232 | if ($globalDBdriver == 'mysql') { |
@@ -9892,7 +10273,9 @@ discard block |
||
9892 | 10273 | date_default_timezone_set($globalTimezone); |
9893 | 10274 | $datetime = new DateTime(); |
9894 | 10275 | $offset = $datetime->format('P'); |
9895 | - } else $offset = '+00:00'; |
|
10276 | + } else { |
|
10277 | + $offset = '+00:00'; |
|
10278 | + } |
|
9896 | 10279 | |
9897 | 10280 | if ($globalDBdriver == 'mysql') { |
9898 | 10281 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
@@ -9939,7 +10322,9 @@ discard block |
||
9939 | 10322 | date_default_timezone_set($globalTimezone); |
9940 | 10323 | $datetime = new DateTime(); |
9941 | 10324 | $offset = $datetime->format('P'); |
9942 | - } else $offset = '+00:00'; |
|
10325 | + } else { |
|
10326 | + $offset = '+00:00'; |
|
10327 | + } |
|
9943 | 10328 | |
9944 | 10329 | if ($globalDBdriver == 'mysql') { |
9945 | 10330 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
@@ -9984,7 +10369,9 @@ discard block |
||
9984 | 10369 | date_default_timezone_set($globalTimezone); |
9985 | 10370 | $datetime = new DateTime(); |
9986 | 10371 | $offset = $datetime->format('P'); |
9987 | - } else $offset = '+00:00'; |
|
10372 | + } else { |
|
10373 | + $offset = '+00:00'; |
|
10374 | + } |
|
9988 | 10375 | $filter_query = $this->getFilter($filters,true,true); |
9989 | 10376 | |
9990 | 10377 | if ($globalDBdriver == 'mysql') { |
@@ -10032,7 +10419,9 @@ discard block |
||
10032 | 10419 | date_default_timezone_set($globalTimezone); |
10033 | 10420 | $datetime = new DateTime(); |
10034 | 10421 | $offset = $datetime->format('P'); |
10035 | - } else $offset = '+00:00'; |
|
10422 | + } else { |
|
10423 | + $offset = '+00:00'; |
|
10424 | + } |
|
10036 | 10425 | |
10037 | 10426 | if ($globalDBdriver == 'mysql') { |
10038 | 10427 | $query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
@@ -10078,7 +10467,9 @@ discard block |
||
10078 | 10467 | date_default_timezone_set($globalTimezone); |
10079 | 10468 | $datetime = new DateTime(); |
10080 | 10469 | $offset = $datetime->format('P'); |
10081 | - } else $offset = '+00:00'; |
|
10470 | + } else { |
|
10471 | + $offset = '+00:00'; |
|
10472 | + } |
|
10082 | 10473 | $filter_query = $this->getFilter($filters,true,true); |
10083 | 10474 | |
10084 | 10475 | if ($globalDBdriver == 'mysql') { |
@@ -10126,7 +10517,9 @@ discard block |
||
10126 | 10517 | date_default_timezone_set($globalTimezone); |
10127 | 10518 | $datetime = new DateTime(); |
10128 | 10519 | $offset = $datetime->format('P'); |
10129 | - } else $offset = '+00:00'; |
|
10520 | + } else { |
|
10521 | + $offset = '+00:00'; |
|
10522 | + } |
|
10130 | 10523 | |
10131 | 10524 | if ($globalDBdriver == 'mysql') { |
10132 | 10525 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
@@ -10173,7 +10566,9 @@ discard block |
||
10173 | 10566 | date_default_timezone_set($globalTimezone); |
10174 | 10567 | $datetime = new DateTime(); |
10175 | 10568 | $offset = $datetime->format('P'); |
10176 | - } else $offset = '+00:00'; |
|
10569 | + } else { |
|
10570 | + $offset = '+00:00'; |
|
10571 | + } |
|
10177 | 10572 | $filter_query = $this->getFilter($filters,true,true); |
10178 | 10573 | if ($globalDBdriver == 'mysql') { |
10179 | 10574 | $query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -10222,7 +10617,9 @@ discard block |
||
10222 | 10617 | date_default_timezone_set($globalTimezone); |
10223 | 10618 | $datetime = new DateTime(); |
10224 | 10619 | $offset = $datetime->format('P'); |
10225 | - } else $offset = '+00:00'; |
|
10620 | + } else { |
|
10621 | + $offset = '+00:00'; |
|
10622 | + } |
|
10226 | 10623 | |
10227 | 10624 | $orderby_sql = ''; |
10228 | 10625 | if ($orderby == "hour") |
@@ -10288,7 +10685,9 @@ discard block |
||
10288 | 10685 | date_default_timezone_set($globalTimezone); |
10289 | 10686 | $datetime = new DateTime(); |
10290 | 10687 | $offset = $datetime->format('P'); |
10291 | - } else $offset = '+00:00'; |
|
10688 | + } else { |
|
10689 | + $offset = '+00:00'; |
|
10690 | + } |
|
10292 | 10691 | |
10293 | 10692 | $orderby_sql = ''; |
10294 | 10693 | if ($orderby == "hour") |
@@ -10355,7 +10754,9 @@ discard block |
||
10355 | 10754 | date_default_timezone_set($globalTimezone); |
10356 | 10755 | $datetime = new DateTime(); |
10357 | 10756 | $offset = $datetime->format('P'); |
10358 | - } else $offset = '+00:00'; |
|
10757 | + } else { |
|
10758 | + $offset = '+00:00'; |
|
10759 | + } |
|
10359 | 10760 | |
10360 | 10761 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
10361 | 10762 | |
@@ -10406,7 +10807,9 @@ discard block |
||
10406 | 10807 | date_default_timezone_set($globalTimezone); |
10407 | 10808 | $datetime = new DateTime(); |
10408 | 10809 | $offset = $datetime->format('P'); |
10409 | - } else $offset = '+00:00'; |
|
10810 | + } else { |
|
10811 | + $offset = '+00:00'; |
|
10812 | + } |
|
10410 | 10813 | |
10411 | 10814 | if ($globalDBdriver == 'mysql') { |
10412 | 10815 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10453,7 +10856,9 @@ discard block |
||
10453 | 10856 | date_default_timezone_set($globalTimezone); |
10454 | 10857 | $datetime = new DateTime(); |
10455 | 10858 | $offset = $datetime->format('P'); |
10456 | - } else $offset = '+00:00'; |
|
10859 | + } else { |
|
10860 | + $offset = '+00:00'; |
|
10861 | + } |
|
10457 | 10862 | |
10458 | 10863 | if ($globalDBdriver == 'mysql') { |
10459 | 10864 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10500,7 +10905,9 @@ discard block |
||
10500 | 10905 | date_default_timezone_set($globalTimezone); |
10501 | 10906 | $datetime = new DateTime(); |
10502 | 10907 | $offset = $datetime->format('P'); |
10503 | - } else $offset = '+00:00'; |
|
10908 | + } else { |
|
10909 | + $offset = '+00:00'; |
|
10910 | + } |
|
10504 | 10911 | |
10505 | 10912 | if ($globalDBdriver == 'mysql') { |
10506 | 10913 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10548,7 +10955,9 @@ discard block |
||
10548 | 10955 | date_default_timezone_set($globalTimezone); |
10549 | 10956 | $datetime = new DateTime(); |
10550 | 10957 | $offset = $datetime->format('P'); |
10551 | - } else $offset = '+00:00'; |
|
10958 | + } else { |
|
10959 | + $offset = '+00:00'; |
|
10960 | + } |
|
10552 | 10961 | |
10553 | 10962 | if ($globalDBdriver == 'mysql') { |
10554 | 10963 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10596,7 +11005,9 @@ discard block |
||
10596 | 11005 | date_default_timezone_set($globalTimezone); |
10597 | 11006 | $datetime = new DateTime($date); |
10598 | 11007 | $offset = $datetime->format('P'); |
10599 | - } else $offset = '+00:00'; |
|
11008 | + } else { |
|
11009 | + $offset = '+00:00'; |
|
11010 | + } |
|
10600 | 11011 | |
10601 | 11012 | if ($globalDBdriver == 'mysql') { |
10602 | 11013 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10644,7 +11055,9 @@ discard block |
||
10644 | 11055 | date_default_timezone_set($globalTimezone); |
10645 | 11056 | $datetime = new DateTime(); |
10646 | 11057 | $offset = $datetime->format('P'); |
10647 | - } else $offset = '+00:00'; |
|
11058 | + } else { |
|
11059 | + $offset = '+00:00'; |
|
11060 | + } |
|
10648 | 11061 | |
10649 | 11062 | if ($globalDBdriver == 'mysql') { |
10650 | 11063 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10691,7 +11104,9 @@ discard block |
||
10691 | 11104 | date_default_timezone_set($globalTimezone); |
10692 | 11105 | $datetime = new DateTime(); |
10693 | 11106 | $offset = $datetime->format('P'); |
10694 | - } else $offset = '+00:00'; |
|
11107 | + } else { |
|
11108 | + $offset = '+00:00'; |
|
11109 | + } |
|
10695 | 11110 | |
10696 | 11111 | if ($globalDBdriver == 'mysql') { |
10697 | 11112 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10738,7 +11153,9 @@ discard block |
||
10738 | 11153 | date_default_timezone_set($globalTimezone); |
10739 | 11154 | $datetime = new DateTime(); |
10740 | 11155 | $offset = $datetime->format('P'); |
10741 | - } else $offset = '+00:00'; |
|
11156 | + } else { |
|
11157 | + $offset = '+00:00'; |
|
11158 | + } |
|
10742 | 11159 | |
10743 | 11160 | if ($globalDBdriver == 'mysql') { |
10744 | 11161 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10788,7 +11205,9 @@ discard block |
||
10788 | 11205 | date_default_timezone_set($globalTimezone); |
10789 | 11206 | $datetime = new DateTime(); |
10790 | 11207 | $offset = $datetime->format('P'); |
10791 | - } else $offset = '+00:00'; |
|
11208 | + } else { |
|
11209 | + $offset = '+00:00'; |
|
11210 | + } |
|
10792 | 11211 | |
10793 | 11212 | if ($globalDBdriver == 'mysql') { |
10794 | 11213 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -10835,7 +11254,9 @@ discard block |
||
10835 | 11254 | date_default_timezone_set($globalTimezone); |
10836 | 11255 | $datetime = new DateTime(); |
10837 | 11256 | $offset = $datetime->format('P'); |
10838 | - } else $offset = '+00:00'; |
|
11257 | + } else { |
|
11258 | + $offset = '+00:00'; |
|
11259 | + } |
|
10839 | 11260 | |
10840 | 11261 | if ($globalDBdriver == 'mysql') { |
10841 | 11262 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -11046,8 +11467,11 @@ discard block |
||
11046 | 11467 | $query_values = array_merge($query_values,array(':month' => $month)); |
11047 | 11468 | } |
11048 | 11469 | } |
11049 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
11050 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11470 | + if (empty($query_values)) { |
|
11471 | + $queryi .= $this->getFilter($filters); |
|
11472 | + } else { |
|
11473 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11474 | + } |
|
11051 | 11475 | |
11052 | 11476 | $sth = $this->db->prepare($queryi); |
11053 | 11477 | $sth->execute($query_values); |
@@ -11125,8 +11549,11 @@ discard block |
||
11125 | 11549 | $query_values = array_merge($query_values,array(':month' => $month)); |
11126 | 11550 | } |
11127 | 11551 | } |
11128 | - if ($query == '') $queryi .= $this->getFilter($filters); |
|
11129 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11552 | + if ($query == '') { |
|
11553 | + $queryi .= $this->getFilter($filters); |
|
11554 | + } else { |
|
11555 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
11556 | + } |
|
11130 | 11557 | |
11131 | 11558 | |
11132 | 11559 | $sth = $this->db->prepare($queryi); |
@@ -11149,7 +11576,9 @@ discard block |
||
11149 | 11576 | date_default_timezone_set($globalTimezone); |
11150 | 11577 | $datetime = new DateTime(); |
11151 | 11578 | $offset = $datetime->format('P'); |
11152 | - } else $offset = '+00:00'; |
|
11579 | + } else { |
|
11580 | + $offset = '+00:00'; |
|
11581 | + } |
|
11153 | 11582 | |
11154 | 11583 | if ($globalDBdriver == 'mysql') { |
11155 | 11584 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -11335,7 +11764,9 @@ discard block |
||
11335 | 11764 | */ |
11336 | 11765 | public function parseDirection($direction = 0) |
11337 | 11766 | { |
11338 | - if ($direction == '') $direction = 0; |
|
11767 | + if ($direction == '') { |
|
11768 | + $direction = 0; |
|
11769 | + } |
|
11339 | 11770 | $direction_array = array(); |
11340 | 11771 | $temp_array = array(); |
11341 | 11772 | |
@@ -11436,7 +11867,9 @@ discard block |
||
11436 | 11867 | if (isset($result->AirlineFlightInfoResult)) |
11437 | 11868 | { |
11438 | 11869 | $registration = $result->AirlineFlightInfoResult->tailnumber; |
11439 | - } else return ''; |
|
11870 | + } else { |
|
11871 | + return ''; |
|
11872 | + } |
|
11440 | 11873 | |
11441 | 11874 | $registration = $this->convertAircraftRegistration($registration); |
11442 | 11875 | |
@@ -11470,7 +11903,9 @@ discard block |
||
11470 | 11903 | return $row['registration']; |
11471 | 11904 | } elseif ($source_type == 'flarm') { |
11472 | 11905 | return $this->getAircraftRegistrationBymodeS($aircraft_modes); |
11473 | - } else return ''; |
|
11906 | + } else { |
|
11907 | + return ''; |
|
11908 | + } |
|
11474 | 11909 | |
11475 | 11910 | } |
11476 | 11911 | |
@@ -11497,11 +11932,16 @@ discard block |
||
11497 | 11932 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
11498 | 11933 | $sth->closeCursor(); |
11499 | 11934 | if (count($row) > 0) { |
11500 | - if ($row['type_flight'] == null) return ''; |
|
11501 | - else return $row['type_flight']; |
|
11935 | + if ($row['type_flight'] == null) { |
|
11936 | + return ''; |
|
11937 | + } else { |
|
11938 | + return $row['type_flight']; |
|
11939 | + } |
|
11502 | 11940 | } elseif ($source_type == 'flarm') { |
11503 | 11941 | return $this->getAircraftTypeBymodeS($aircraft_modes); |
11504 | - } else return ''; |
|
11942 | + } else { |
|
11943 | + return ''; |
|
11944 | + } |
|
11505 | 11945 | |
11506 | 11946 | } |
11507 | 11947 | |
@@ -11519,7 +11959,9 @@ discard block |
||
11519 | 11959 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
11520 | 11960 | |
11521 | 11961 | $Connection = new Connection($this->db); |
11522 | - if (!$Connection->tableExists('countries')) return ''; |
|
11962 | + if (!$Connection->tableExists('countries')) { |
|
11963 | + return ''; |
|
11964 | + } |
|
11523 | 11965 | |
11524 | 11966 | try { |
11525 | 11967 | /* |
@@ -11539,9 +11981,13 @@ discard block |
||
11539 | 11981 | $sth->closeCursor(); |
11540 | 11982 | if (count($row) > 0) { |
11541 | 11983 | return $row; |
11542 | - } else return ''; |
|
11984 | + } else { |
|
11985 | + return ''; |
|
11986 | + } |
|
11543 | 11987 | } catch (PDOException $e) { |
11544 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
11988 | + if (isset($globalDebug) && $globalDebug) { |
|
11989 | + echo 'Error : '.$e->getMessage()."\n"; |
|
11990 | + } |
|
11545 | 11991 | return ''; |
11546 | 11992 | } |
11547 | 11993 | |
@@ -11559,7 +12005,9 @@ discard block |
||
11559 | 12005 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
11560 | 12006 | |
11561 | 12007 | $Connection = new Connection($this->db); |
11562 | - if (!$Connection->tableExists('countries')) return ''; |
|
12008 | + if (!$Connection->tableExists('countries')) { |
|
12009 | + return ''; |
|
12010 | + } |
|
11563 | 12011 | |
11564 | 12012 | try { |
11565 | 12013 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -11571,9 +12019,13 @@ discard block |
||
11571 | 12019 | $sth->closeCursor(); |
11572 | 12020 | if (count($row) > 0) { |
11573 | 12021 | return $row; |
11574 | - } else return ''; |
|
12022 | + } else { |
|
12023 | + return ''; |
|
12024 | + } |
|
11575 | 12025 | } catch (PDOException $e) { |
11576 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
12026 | + if (isset($globalDebug) && $globalDebug) { |
|
12027 | + echo 'Error : '.$e->getMessage()."\n"; |
|
12028 | + } |
|
11577 | 12029 | return ''; |
11578 | 12030 | } |
11579 | 12031 | |
@@ -11823,7 +12275,9 @@ discard block |
||
11823 | 12275 | { |
11824 | 12276 | global $globalBitlyAccessToken; |
11825 | 12277 | |
11826 | - if ($globalBitlyAccessToken == '') return $url; |
|
12278 | + if ($globalBitlyAccessToken == '') { |
|
12279 | + return $url; |
|
12280 | + } |
|
11827 | 12281 | |
11828 | 12282 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
11829 | 12283 | |
@@ -11972,7 +12426,9 @@ discard block |
||
11972 | 12426 | |
11973 | 12427 | |
11974 | 12428 | // routes |
11975 | - if ($globalDebug) print "Routes...\n"; |
|
12429 | + if ($globalDebug) { |
|
12430 | + print "Routes...\n"; |
|
12431 | + } |
|
11976 | 12432 | if ($globalDBdriver == 'mysql') { |
11977 | 12433 | $query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
11978 | 12434 | } else { |
@@ -11991,7 +12447,9 @@ discard block |
||
11991 | 12447 | } |
11992 | 12448 | } |
11993 | 12449 | |
11994 | - if ($globalDebug) print "Airlines...\n"; |
|
12450 | + if ($globalDebug) { |
|
12451 | + print "Airlines...\n"; |
|
12452 | + } |
|
11995 | 12453 | //airlines |
11996 | 12454 | if ($globalDBdriver == 'mysql') { |
11997 | 12455 | $query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
@@ -12005,10 +12463,15 @@ discard block |
||
12005 | 12463 | if (is_numeric(substr($row['ident'], -1, 1))) |
12006 | 12464 | { |
12007 | 12465 | $fromsource = NULL; |
12008 | - if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
12009 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
12010 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
12011 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
12466 | + if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
12467 | + $fromsource = 'vatsim'; |
|
12468 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
12469 | + $fromsource = 'ivao'; |
|
12470 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
12471 | + $fromsource = 'vatsim'; |
|
12472 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
12473 | + $fromsource = 'ivao'; |
|
12474 | + } |
|
12012 | 12475 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
12013 | 12476 | if (isset($airline_array[0]['name'])) { |
12014 | 12477 | $update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
@@ -12018,13 +12481,17 @@ discard block |
||
12018 | 12481 | } |
12019 | 12482 | } |
12020 | 12483 | |
12021 | - if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
12484 | + if ($globalDebug) { |
|
12485 | + print "Remove Duplicate in aircraft_modes...\n"; |
|
12486 | + } |
|
12022 | 12487 | //duplicate modes |
12023 | 12488 | $query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; |
12024 | 12489 | $sth = $this->db->prepare($query); |
12025 | 12490 | $sth->execute(); |
12026 | 12491 | |
12027 | - if ($globalDebug) print "Aircraft...\n"; |
|
12492 | + if ($globalDebug) { |
|
12493 | + print "Aircraft...\n"; |
|
12494 | + } |
|
12028 | 12495 | //aircraft |
12029 | 12496 | if ($globalDBdriver == 'mysql') { |
12030 | 12497 | $query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -12067,26 +12534,38 @@ discard block |
||
12067 | 12534 | if (isset($closestAirports[0])) { |
12068 | 12535 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
12069 | 12536 | $airport_icao = $closestAirports[0]['icao']; |
12070 | - if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12537 | + if ($globalDebug) { |
|
12538 | + echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12539 | + } |
|
12071 | 12540 | } elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
12072 | 12541 | foreach ($closestAirports as $airport) { |
12073 | 12542 | if ($row['arrival_airport_icao'] == $airport['icao']) { |
12074 | 12543 | $airport_icao = $airport['icao']; |
12075 | - if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12544 | + if ($globalDebug) { |
|
12545 | + echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
12546 | + } |
|
12076 | 12547 | break; |
12077 | 12548 | } |
12078 | 12549 | } |
12079 | 12550 | } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
12080 | 12551 | $airport_icao = $closestAirports[0]['icao']; |
12081 | - if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12552 | + if ($globalDebug) { |
|
12553 | + echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12554 | + } |
|
12082 | 12555 | } else { |
12083 | - if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12556 | + if ($globalDebug) { |
|
12557 | + echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
12558 | + } |
|
12084 | 12559 | } |
12085 | 12560 | } else { |
12086 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
12561 | + if ($globalDebug) { |
|
12562 | + echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
12563 | + } |
|
12087 | 12564 | } |
12088 | 12565 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
12089 | - if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
12566 | + if ($globalDebug) { |
|
12567 | + echo "Updating airport to ".$airport_icao."...\n"; |
|
12568 | + } |
|
12090 | 12569 | $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
12091 | 12570 | $sthu = $this->db->prepare($update_query); |
12092 | 12571 | $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
@@ -107,17 +107,23 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
110 | + if ($globalDebug) { |
|
111 | + echo '!!! APRS invalid : '.$input."\n"; |
|
112 | + } |
|
111 | 113 | return false; |
112 | 114 | } |
113 | 115 | |
114 | - if ($debug) echo 'input : '.$input."\n"; |
|
116 | + if ($debug) { |
|
117 | + echo 'input : '.$input."\n"; |
|
118 | + } |
|
115 | 119 | /* Save header and body. */ |
116 | 120 | $body = substr($input,$splitpos+1,$input_len); |
117 | 121 | $body_len = strlen($body); |
118 | 122 | $header = substr($input,0,$splitpos); |
119 | 123 | //$header_len = strlen($header); |
120 | - if ($debug) echo 'header : '.$header."\n"; |
|
124 | + if ($debug) { |
|
125 | + echo 'header : '.$header."\n"; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | /* Parse source, target and path. */ |
123 | 129 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -131,10 +137,14 @@ discard block |
||
131 | 137 | $result['format_source'] = 'famaprs'; |
132 | 138 | $result['source_type'] = 'ais'; |
133 | 139 | } else { |
134 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
140 | + if ($debug) { |
|
141 | + echo 'ident : '.$ident."\n"; |
|
142 | + } |
|
135 | 143 | $result['ident'] = $ident; |
136 | 144 | } |
137 | - } else return false; |
|
145 | + } else { |
|
146 | + return false; |
|
147 | + } |
|
138 | 148 | $elements = explode(',',$all_elements); |
139 | 149 | $source = end($elements); |
140 | 150 | $result['source'] = $source; |
@@ -143,7 +153,9 @@ discard block |
||
143 | 153 | //echo "ok"; |
144 | 154 | //if ($element == 'TCPIP*') return false; |
145 | 155 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
146 | - if ($debug) echo 'element : '.$element."\n"; |
|
156 | + if ($debug) { |
|
157 | + echo 'element : '.$element."\n"; |
|
158 | + } |
|
147 | 159 | return false; |
148 | 160 | } |
149 | 161 | /* |
@@ -156,11 +168,15 @@ discard block |
||
156 | 168 | } |
157 | 169 | |
158 | 170 | $type = substr($body,0,1); |
159 | - if ($debug) echo 'type : '.$type."\n"; |
|
171 | + if ($debug) { |
|
172 | + echo 'type : '.$type."\n"; |
|
173 | + } |
|
160 | 174 | if ($type == ';') { |
161 | 175 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | 176 | $result['address'] = trim(substr($body,1,9)); |
163 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
177 | + } else { |
|
178 | + $result['ident'] = trim(substr($body,1,9)); |
|
179 | + } |
|
164 | 180 | } elseif ($type == ',') { |
165 | 181 | // Invalid data or test data |
166 | 182 | return false; |
@@ -228,7 +244,9 @@ discard block |
||
228 | 244 | //$symbol_table = $matches[4]; |
229 | 245 | $lat = intval($lat_deg); |
230 | 246 | $lon = intval($lon_deg); |
231 | - if ($lat > 89 || $lon > 179) return false; |
|
247 | + if ($lat > 89 || $lon > 179) { |
|
248 | + return false; |
|
249 | + } |
|
232 | 250 | |
233 | 251 | /* |
234 | 252 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -238,8 +256,12 @@ discard block |
||
238 | 256 | */ |
239 | 257 | $latitude = $lat + floatval($lat_min)/60; |
240 | 258 | $longitude = $lon + floatval($lon_min)/60; |
241 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
242 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
259 | + if ($sind == 'S') { |
|
260 | + $latitude = 0-$latitude; |
|
261 | + } |
|
262 | + if ($wind == 'W') { |
|
263 | + $longitude = 0-$longitude; |
|
264 | + } |
|
243 | 265 | $result['latitude'] = $latitude; |
244 | 266 | $result['longitude'] = $longitude; |
245 | 267 | $body_parse = substr($body_parse,18); |
@@ -273,7 +295,9 @@ discard block |
||
273 | 295 | $body_parse = substr($body_parse,1); |
274 | 296 | $body_parse_len = strlen($body_parse); |
275 | 297 | $result['symbol_code'] = $symbol_code; |
276 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
298 | + if (isset($this->symbols[$symbol_code])) { |
|
299 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
300 | + } |
|
277 | 301 | if ($symbol_code != '_') { |
278 | 302 | } |
279 | 303 | //$body_parse = substr($body_parse,1); |
@@ -284,7 +308,9 @@ discard block |
||
284 | 308 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
285 | 309 | $course = substr($body_parse,0,3); |
286 | 310 | $tmp_s = intval($course); |
287 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
311 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
312 | + $result['heading'] = intval($course); |
|
313 | + } |
|
288 | 314 | $speed = substr($body_parse,4,3); |
289 | 315 | if ($speed != '...') { |
290 | 316 | //$result['speed'] = round($speed*1.852); |
@@ -325,10 +351,16 @@ discard block |
||
325 | 351 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
326 | 352 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
327 | 353 | |
328 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
329 | - else $result['latitude'] += $lat_off; |
|
330 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
331 | - else $result['longitude'] += $lon_off; |
|
354 | + if ($result['latitude'] < 0) { |
|
355 | + $result['latitude'] -= $lat_off; |
|
356 | + } else { |
|
357 | + $result['latitude'] += $lat_off; |
|
358 | + } |
|
359 | + if ($result['longitude'] < 0) { |
|
360 | + $result['longitude'] -= $lon_off; |
|
361 | + } else { |
|
362 | + $result['longitude'] += $lon_off; |
|
363 | + } |
|
332 | 364 | } |
333 | 365 | |
334 | 366 | $body_parse = substr($body_parse,6); |
@@ -364,27 +396,48 @@ discard block |
||
364 | 396 | $address = substr($id,2); |
365 | 397 | //print_r($matches); |
366 | 398 | $addressType = (intval(substr($id,0,2),16))&3; |
367 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
368 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
369 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
370 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
399 | + if ($addressType == 0) { |
|
400 | + $result['addresstype'] = "RANDOM"; |
|
401 | + } elseif ($addressType == 1) { |
|
402 | + $result['addresstype'] = "ICAO"; |
|
403 | + } elseif ($addressType == 2) { |
|
404 | + $result['addresstype'] = "FLARM"; |
|
405 | + } elseif ($addressType == 3) { |
|
406 | + $result['addresstype'] = "OGN"; |
|
407 | + } |
|
371 | 408 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
372 | 409 | $result['aircrafttype_code'] = $aircraftType; |
373 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
374 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
375 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
376 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
377 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
378 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
379 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
380 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
381 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
382 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
383 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
384 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
385 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
386 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
387 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
410 | + if ($aircraftType == 0) { |
|
411 | + $result['aircrafttype'] = "UNKNOWN"; |
|
412 | + } elseif ($aircraftType == 1) { |
|
413 | + $result['aircrafttype'] = "GLIDER"; |
|
414 | + } elseif ($aircraftType == 2) { |
|
415 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
416 | + } elseif ($aircraftType == 3) { |
|
417 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
418 | + } elseif ($aircraftType == 4) { |
|
419 | + $result['aircrafttype'] = "PARACHUTE"; |
|
420 | + } elseif ($aircraftType == 5) { |
|
421 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
422 | + } elseif ($aircraftType == 6) { |
|
423 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
424 | + } elseif ($aircraftType == 7) { |
|
425 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
426 | + } elseif ($aircraftType == 8) { |
|
427 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
428 | + } elseif ($aircraftType == 9) { |
|
429 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
430 | + } elseif ($aircraftType == 10) { |
|
431 | + $result['aircrafttype'] = "UFO"; |
|
432 | + } elseif ($aircraftType == 11) { |
|
433 | + $result['aircrafttype'] = "BALLOON"; |
|
434 | + } elseif ($aircraftType == 12) { |
|
435 | + $result['aircrafttype'] = "AIRSHIP"; |
|
436 | + } elseif ($aircraftType == 13) { |
|
437 | + $result['aircrafttype'] = "UAV"; |
|
438 | + } elseif ($aircraftType == 15) { |
|
439 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
440 | + } |
|
388 | 441 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
389 | 442 | $result['stealth'] = $stealth; |
390 | 443 | $result['address'] = $address; |
@@ -424,13 +477,21 @@ discard block |
||
424 | 477 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
425 | 478 | } |
426 | 479 | } |
427 | - } else $result['comment'] = trim($body_parse); |
|
480 | + } else { |
|
481 | + $result['comment'] = trim($body_parse); |
|
482 | + } |
|
428 | 483 | |
429 | 484 | } |
430 | 485 | //} |
431 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
432 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
433 | - if ($debug) print_r($result); |
|
486 | + if (isset($result['latitude'])) { |
|
487 | + $result['latitude'] = round($result['latitude'],4); |
|
488 | + } |
|
489 | + if (isset($result['longitude'])) { |
|
490 | + $result['longitude'] = round($result['longitude'],4); |
|
491 | + } |
|
492 | + if ($debug) { |
|
493 | + print_r($result); |
|
494 | + } |
|
434 | 495 | return $result; |
435 | 496 | } |
436 | 497 | |
@@ -439,12 +500,21 @@ discard block |
||
439 | 500 | $aprs_connect = 0; |
440 | 501 | $aprs_keep = 120; |
441 | 502 | $aprs_last_tx = time(); |
442 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
443 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
444 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
445 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
446 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
447 | - else $aprs_pass = '-1'; |
|
503 | + if (isset($globalAPRSversion)) { |
|
504 | + $aprs_version = $globalAPRSversion; |
|
505 | + } else { |
|
506 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
507 | + } |
|
508 | + if (isset($globalServerAPRSssid)) { |
|
509 | + $aprs_ssid = $globalServerAPRSssid; |
|
510 | + } else { |
|
511 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
512 | + } |
|
513 | + if (isset($globalServerAPRSpass)) { |
|
514 | + $aprs_pass = $globalServerAPRSpass; |
|
515 | + } else { |
|
516 | + $aprs_pass = '-1'; |
|
517 | + } |
|
448 | 518 | |
449 | 519 | $aprs_filter = ''; |
450 | 520 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -476,7 +546,9 @@ discard block |
||
476 | 546 | } |
477 | 547 | |
478 | 548 | public function send($data) { |
479 | - if ($this->connected === false) $this->connect(); |
|
549 | + if ($this->connected === false) { |
|
550 | + $this->connect(); |
|
551 | + } |
|
480 | 552 | $send = socket_send( $this->socket , $data , strlen($data),0); |
481 | 553 | if ($send === FALSE) { |
482 | 554 | socket_close($this->socket); |
@@ -498,18 +570,26 @@ discard block |
||
498 | 570 | //$w = '00'; |
499 | 571 | $custom = ''; |
500 | 572 | if ($ident != '') { |
501 | - if ($custom != '') $custom .= '/'; |
|
573 | + if ($custom != '') { |
|
574 | + $custom .= '/'; |
|
575 | + } |
|
502 | 576 | $custom .= 'CS='.$ident; |
503 | 577 | } |
504 | 578 | if ($squawk != '') { |
505 | - if ($custom != '') $custom .= '/'; |
|
579 | + if ($custom != '') { |
|
580 | + $custom .= '/'; |
|
581 | + } |
|
506 | 582 | $custom .= 'SQ='.$squawk; |
507 | 583 | } |
508 | 584 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
509 | - if ($custom != '') $custom .= '/'; |
|
585 | + if ($custom != '') { |
|
586 | + $custom .= '/'; |
|
587 | + } |
|
510 | 588 | $custom .= 'AI='.$aircraft_icao; |
511 | 589 | } |
512 | - if ($custom != '') $custom = ' '.$custom; |
|
590 | + if ($custom != '') { |
|
591 | + $custom = ' '.$custom; |
|
592 | + } |
|
513 | 593 | $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
514 | 594 | } |
515 | 595 | } |
@@ -527,26 +607,38 @@ discard block |
||
527 | 607 | //$w = '00'; |
528 | 608 | $custom = ''; |
529 | 609 | if ($ident != '') { |
530 | - if ($custom != '') $custom .= '/'; |
|
610 | + if ($custom != '') { |
|
611 | + $custom .= '/'; |
|
612 | + } |
|
531 | 613 | $custom .= 'CS='.$ident; |
532 | 614 | } |
533 | 615 | if ($typeid != '') { |
534 | - if ($custom != '') $custom .= '/'; |
|
616 | + if ($custom != '') { |
|
617 | + $custom .= '/'; |
|
618 | + } |
|
535 | 619 | $custom .= 'TI='.$typeid; |
536 | 620 | } |
537 | 621 | if ($imo != '') { |
538 | - if ($custom != '') $custom .= '/'; |
|
622 | + if ($custom != '') { |
|
623 | + $custom .= '/'; |
|
624 | + } |
|
539 | 625 | $custom .= 'IMO='.$imo; |
540 | 626 | } |
541 | 627 | if ($arrival_date != '') { |
542 | - if ($custom != '') $custom .= '/'; |
|
628 | + if ($custom != '') { |
|
629 | + $custom .= '/'; |
|
630 | + } |
|
543 | 631 | $custom .= 'AD='.strtotime($arrival_date); |
544 | 632 | } |
545 | 633 | if ($arrival_code != '') { |
546 | - if ($custom != '') $custom .= '/'; |
|
634 | + if ($custom != '') { |
|
635 | + $custom .= '/'; |
|
636 | + } |
|
547 | 637 | $custom .= 'AC='.$arrival_code; |
548 | 638 | } |
549 | - if ($custom != '') $custom = ' '.$custom; |
|
639 | + if ($custom != '') { |
|
640 | + $custom = ' '.$custom; |
|
641 | + } |
|
550 | 642 | $altitude = 0; |
551 | 643 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
552 | 644 | } |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
4 | -if ($date == '') $date = date('Y-m-d'); |
|
4 | +if ($date == '') { |
|
5 | + $date = date('Y-m-d'); |
|
6 | +} |
|
5 | 7 | header('Location: '.$globalURL.'/incident/'.$date); |
6 | 8 | ?> |
7 | 9 | \ No newline at end of file |