@@ -22,11 +22,15 @@ discard block |
||
| 22 | 22 | require_once('require/class.Spotter.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 25 | +if (!isset($filter_name)) { |
|
| 26 | + $filter_name = ''; |
|
| 27 | +} |
|
| 26 | 28 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 27 | 29 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
| 28 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 29 | -} |
|
| 30 | + if (isset($globalFilter['airline'])) { |
|
| 31 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 32 | + } |
|
| 33 | + } |
|
| 30 | 34 | if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') { |
| 31 | 35 | $Spotter = new Spotter(); |
| 32 | 36 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -61,7 +65,12 @@ discard block |
||
| 61 | 65 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
| 62 | 66 | <div class="column"> |
| 63 | 67 | <div class="info"> |
| 64 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
| 68 | + <h1><?php if (isset($airline_name)) { |
|
| 69 | + echo _("Statistics for ").$airline_name; |
|
| 70 | +} else { |
|
| 71 | + echo _("Statistics"); |
|
| 72 | +} |
|
| 73 | +?></h1> |
|
| 65 | 74 | <?php |
| 66 | 75 | if ($type == 'aircraft') { |
| 67 | 76 | $last_update = $Stats->getLastStatsUpdate(); |
@@ -73,7 +82,9 @@ discard block |
||
| 73 | 82 | if (isset($last_update[0]['value'])) { |
| 74 | 83 | date_default_timezone_set('UTC'); |
| 75 | 84 | $lastupdate = strtotime($last_update[0]['value']); |
| 76 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
| 85 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
| 86 | + date_default_timezone_set($globalTimezone); |
|
| 87 | + } |
|
| 77 | 88 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
| 78 | 89 | } |
| 79 | 90 | |
@@ -158,8 +169,11 @@ discard block |
||
| 158 | 169 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 159 | 170 | $aircraft_data = ''; |
| 160 | 171 | foreach($aircraft_array as $aircraft_item) { |
| 161 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 162 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 172 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
| 173 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 174 | + } else { |
|
| 175 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 176 | + } |
|
| 163 | 177 | } |
| 164 | 178 | $aircraft_data = substr($aircraft_data, 0, -1); |
| 165 | 179 | print 'var series = ['.$aircraft_data.'];'; |
@@ -176,11 +190,17 @@ discard block |
||
| 176 | 190 | <?php |
| 177 | 191 | if ($year != '' && $month != '') { |
| 178 | 192 | ?> |
| 179 | - <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> |
|
| 193 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 194 | + echo '/'.$airline_icao; |
|
| 195 | +} |
|
| 196 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 180 | 197 | <?php |
| 181 | 198 | } else { |
| 182 | 199 | ?> |
| 183 | - <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> |
|
| 200 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 201 | + echo '/'.$airline_icao; |
|
| 202 | +} |
|
| 203 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 184 | 204 | <?php |
| 185 | 205 | } |
| 186 | 206 | ?> |
@@ -209,11 +229,15 @@ discard block |
||
| 209 | 229 | print '</script>'; |
| 210 | 230 | if ($year != '' && $month != '') { |
| 211 | 231 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
| 212 | - 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 | + } |
|
| 213 | 235 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 214 | 236 | } else { |
| 215 | 237 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
| 216 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 238 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 239 | + echo '/'.$airline_icao; |
|
| 240 | + } |
|
| 217 | 241 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 218 | 242 | } |
| 219 | 243 | print '</div>'; |
@@ -233,8 +257,9 @@ discard block |
||
| 233 | 257 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
| 234 | 258 | <?php |
| 235 | 259 | $marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month); |
| 236 | - if (count($marine_array) == 0) print _("No data available"); |
|
| 237 | - else { |
|
| 260 | + if (count($marine_array) == 0) { |
|
| 261 | + print _("No data available"); |
|
| 262 | + } else { |
|
| 238 | 263 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 239 | 264 | $marine_data = ''; |
| 240 | 265 | foreach($marine_array as $marine_item) { |
@@ -277,8 +302,9 @@ discard block |
||
| 277 | 302 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
| 278 | 303 | <?php |
| 279 | 304 | $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
| 280 | - if (count($tracker_array) == 0) print _("No data available"); |
|
| 281 | - else { |
|
| 305 | + if (count($tracker_array) == 0) { |
|
| 306 | + print _("No data available"); |
|
| 307 | + } else { |
|
| 282 | 308 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 283 | 309 | $tracker_data = ''; |
| 284 | 310 | foreach($tracker_array as $tracker_item) { |
@@ -322,8 +348,9 @@ discard block |
||
| 322 | 348 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
| 323 | 349 | <?php |
| 324 | 350 | $owner_array = $Satellite->countAllOwners(true); |
| 325 | - if (count($owner_array) == 0) print _("No data available"); |
|
| 326 | - else { |
|
| 351 | + if (count($owner_array) == 0) { |
|
| 352 | + print _("No data available"); |
|
| 353 | + } else { |
|
| 327 | 354 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 328 | 355 | $owner_data = ''; |
| 329 | 356 | foreach($owner_array as $owner_item) { |
@@ -342,7 +369,10 @@ discard block |
||
| 342 | 369 | ?> |
| 343 | 370 | <!-- |
| 344 | 371 | <div class="more"> |
| 345 | - <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> |
|
| 372 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 373 | + echo '/'.$airline_icao; |
|
| 374 | +} |
|
| 375 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 346 | 376 | </div> |
| 347 | 377 | --> |
| 348 | 378 | </div> |
@@ -351,8 +381,9 @@ discard block |
||
| 351 | 381 | <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2> |
| 352 | 382 | <?php |
| 353 | 383 | $countries_array = $Satellite->countAllCountriesOwners(true); |
| 354 | - if (count($countries_array) == 0) print _("No data available"); |
|
| 355 | - else { |
|
| 384 | + if (count($countries_array) == 0) { |
|
| 385 | + print _("No data available"); |
|
| 386 | + } else { |
|
| 356 | 387 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 357 | 388 | $owner_data = ''; |
| 358 | 389 | foreach($countries_array as $owner_item) { |
@@ -371,7 +402,10 @@ discard block |
||
| 371 | 402 | ?> |
| 372 | 403 | <!-- |
| 373 | 404 | <div class="more"> |
| 374 | - <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> |
|
| 405 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 406 | + echo '/'.$airline_icao; |
|
| 407 | +} |
|
| 408 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 375 | 409 | </div> |
| 376 | 410 | --> |
| 377 | 411 | </div> |
@@ -383,8 +417,9 @@ discard block |
||
| 383 | 417 | <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2> |
| 384 | 418 | <?php |
| 385 | 419 | $launch_site_array = $Satellite->countAllLaunchSite(true); |
| 386 | - if (count($launch_site_array) == 0) print _("No data available"); |
|
| 387 | - else { |
|
| 420 | + if (count($launch_site_array) == 0) { |
|
| 421 | + print _("No data available"); |
|
| 422 | + } else { |
|
| 388 | 423 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 389 | 424 | $launch_site_data = ''; |
| 390 | 425 | foreach($launch_site_array as $launch_site_item) { |
@@ -403,7 +438,10 @@ discard block |
||
| 403 | 438 | ?> |
| 404 | 439 | <!-- |
| 405 | 440 | <div class="more"> |
| 406 | - <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> |
|
| 441 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 442 | + echo '/'.$airline_icao; |
|
| 443 | +} |
|
| 444 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 407 | 445 | </div> |
| 408 | 446 | --> |
| 409 | 447 | </div> |
@@ -426,8 +464,9 @@ discard block |
||
| 426 | 464 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
| 427 | 465 | <?php |
| 428 | 466 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
| 429 | - if (count($pilot_array) == 0) print _("No data available"); |
|
| 430 | - else { |
|
| 467 | + if (count($pilot_array) == 0) { |
|
| 468 | + print _("No data available"); |
|
| 469 | + } else { |
|
| 431 | 470 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 432 | 471 | $pilot_data = ''; |
| 433 | 472 | foreach($pilot_array as $pilot_item) { |
@@ -445,7 +484,9 @@ discard block |
||
| 445 | 484 | } |
| 446 | 485 | print '<div class="more">'; |
| 447 | 486 | print '<a href="'.$globalURL.'/statistics/pilot'; |
| 448 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 487 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 488 | + echo '/'.$airline_icao; |
|
| 489 | + } |
|
| 449 | 490 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
| 450 | 491 | print '</div>'; |
| 451 | 492 | ?> |
@@ -461,8 +502,9 @@ discard block |
||
| 461 | 502 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
| 462 | 503 | <?php |
| 463 | 504 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
| 464 | - if (count($owner_array) == 0) print _("No data available"); |
|
| 465 | - else { |
|
| 505 | + if (count($owner_array) == 0) { |
|
| 506 | + print _("No data available"); |
|
| 507 | + } else { |
|
| 466 | 508 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 467 | 509 | $owner_data = ''; |
| 468 | 510 | foreach($owner_array as $owner_item) { |
@@ -480,7 +522,10 @@ discard block |
||
| 480 | 522 | } |
| 481 | 523 | ?> |
| 482 | 524 | <div class="more"> |
| 483 | - <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> |
|
| 525 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 526 | + echo '/'.$airline_icao; |
|
| 527 | +} |
|
| 528 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 484 | 529 | </div> |
| 485 | 530 | </div> |
| 486 | 531 | |
@@ -493,8 +538,9 @@ discard block |
||
| 493 | 538 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
| 494 | 539 | <?php |
| 495 | 540 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
| 496 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 497 | - else { |
|
| 541 | + if (count($flightover_array) == 0) { |
|
| 542 | + print _("No data available"); |
|
| 543 | + } else { |
|
| 498 | 544 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 499 | 545 | print 'var series = ['; |
| 500 | 546 | $flightover_data = ''; |
@@ -536,7 +582,10 @@ discard block |
||
| 536 | 582 | } |
| 537 | 583 | ?> |
| 538 | 584 | <div class="more"> |
| 539 | - <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> |
|
| 585 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 586 | + echo '/'.$airline_icao; |
|
| 587 | +} |
|
| 588 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 540 | 589 | </div> |
| 541 | 590 | </div> |
| 542 | 591 | <?php |
@@ -554,8 +603,9 @@ discard block |
||
| 554 | 603 | <div class="col-md-6"> |
| 555 | 604 | <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2> |
| 556 | 605 | <?php |
| 557 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 558 | - else { |
|
| 606 | + if (count($flightover_array) == 0) { |
|
| 607 | + print _("No data available"); |
|
| 608 | + } else { |
|
| 559 | 609 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 560 | 610 | print 'var series = ['; |
| 561 | 611 | $flightover_data = ''; |
@@ -611,8 +661,9 @@ discard block |
||
| 611 | 661 | <div class="col-md-6"> |
| 612 | 662 | <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2> |
| 613 | 663 | <?php |
| 614 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 615 | - else { |
|
| 664 | + if (count($flightover_array) == 0) { |
|
| 665 | + print _("No data available"); |
|
| 666 | + } else { |
|
| 616 | 667 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 617 | 668 | print 'var series = ['; |
| 618 | 669 | $flightover_data = ''; |
@@ -718,7 +769,9 @@ discard block |
||
| 718 | 769 | });"; |
| 719 | 770 | print '</script>'; |
| 720 | 771 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
| 721 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 772 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 773 | + echo '/'.$airline_icao; |
|
| 774 | + } |
|
| 722 | 775 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 723 | 776 | } |
| 724 | 777 | ?> |
@@ -782,7 +835,9 @@ discard block |
||
| 782 | 835 | });"; |
| 783 | 836 | print '</script>'; |
| 784 | 837 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
| 785 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 838 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 839 | + echo '/'.$airline_icao; |
|
| 840 | + } |
|
| 786 | 841 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 787 | 842 | } |
| 788 | 843 | ?> |
@@ -801,8 +856,9 @@ discard block |
||
| 801 | 856 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 802 | 857 | <?php |
| 803 | 858 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
| 804 | - if (count($year_array) == 0) print _("No data available"); |
|
| 805 | - else { |
|
| 859 | + if (count($year_array) == 0) { |
|
| 860 | + print _("No data available"); |
|
| 861 | + } else { |
|
| 806 | 862 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 807 | 863 | $year_data = ''; |
| 808 | 864 | $year_cnt = ''; |
@@ -821,7 +877,10 @@ discard block |
||
| 821 | 877 | } |
| 822 | 878 | ?> |
| 823 | 879 | <div class="more"> |
| 824 | - <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> |
|
| 880 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 881 | + echo '/'.$airline_icao; |
|
| 882 | +} |
|
| 883 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 825 | 884 | </div> |
| 826 | 885 | </div> |
| 827 | 886 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -829,8 +888,9 @@ discard block |
||
| 829 | 888 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 830 | 889 | <?php |
| 831 | 890 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
| 832 | - if (count($month_array) == 0) print _("No data available"); |
|
| 833 | - else { |
|
| 891 | + if (count($month_array) == 0) { |
|
| 892 | + print _("No data available"); |
|
| 893 | + } else { |
|
| 834 | 894 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 835 | 895 | $month_data = ''; |
| 836 | 896 | $month_cnt = ''; |
@@ -849,7 +909,10 @@ discard block |
||
| 849 | 909 | } |
| 850 | 910 | ?> |
| 851 | 911 | <div class="more"> |
| 852 | - <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> |
|
| 912 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 913 | + echo '/'.$airline_icao; |
|
| 914 | +} |
|
| 915 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 853 | 916 | </div> |
| 854 | 917 | </div> |
| 855 | 918 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -858,8 +921,9 @@ discard block |
||
| 858 | 921 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 859 | 922 | <?php |
| 860 | 923 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
| 861 | - if (empty($date_array)) print _("No data available"); |
|
| 862 | - else { |
|
| 924 | + if (empty($date_array)) { |
|
| 925 | + print _("No data available"); |
|
| 926 | + } else { |
|
| 863 | 927 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 864 | 928 | $date_data = ''; |
| 865 | 929 | $date_cnt = ''; |
@@ -878,7 +942,10 @@ discard block |
||
| 878 | 942 | } |
| 879 | 943 | ?> |
| 880 | 944 | <div class="more"> |
| 881 | - <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> |
|
| 945 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 946 | + echo '/'.$airline_icao; |
|
| 947 | +} |
|
| 948 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 882 | 949 | </div> |
| 883 | 950 | </div> |
| 884 | 951 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -886,8 +953,9 @@ discard block |
||
| 886 | 953 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 887 | 954 | <?php |
| 888 | 955 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
| 889 | - if (empty($hour_array)) print _("No data available"); |
|
| 890 | - else { |
|
| 956 | + if (empty($hour_array)) { |
|
| 957 | + print _("No data available"); |
|
| 958 | + } else { |
|
| 891 | 959 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 892 | 960 | $hour_data = ''; |
| 893 | 961 | $hour_cnt = ''; |
@@ -906,7 +974,10 @@ discard block |
||
| 906 | 974 | } |
| 907 | 975 | ?> |
| 908 | 976 | <div class="more"> |
| 909 | - <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> |
|
| 977 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 978 | + echo '/'.$airline_icao; |
|
| 979 | +} |
|
| 980 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 910 | 981 | </div> |
| 911 | 982 | </div> |
| 912 | 983 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -926,8 +997,9 @@ discard block |
||
| 926 | 997 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 927 | 998 | <?php |
| 928 | 999 | $year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
| 929 | - if (count($year_array) == 0) print _("No data available"); |
|
| 930 | - else { |
|
| 1000 | + if (count($year_array) == 0) { |
|
| 1001 | + print _("No data available"); |
|
| 1002 | + } else { |
|
| 931 | 1003 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 932 | 1004 | $year_data = ''; |
| 933 | 1005 | $year_cnt = ''; |
@@ -955,8 +1027,9 @@ discard block |
||
| 955 | 1027 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 956 | 1028 | <?php |
| 957 | 1029 | $month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name); |
| 958 | - if (count($month_array) == 0) print _("No data available"); |
|
| 959 | - else { |
|
| 1030 | + if (count($month_array) == 0) { |
|
| 1031 | + print _("No data available"); |
|
| 1032 | + } else { |
|
| 960 | 1033 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 961 | 1034 | $month_data = ''; |
| 962 | 1035 | $month_cnt = ''; |
@@ -984,8 +1057,9 @@ discard block |
||
| 984 | 1057 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 985 | 1058 | <?php |
| 986 | 1059 | $date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name); |
| 987 | - if (empty($date_array)) print _("No data available"); |
|
| 988 | - else { |
|
| 1060 | + if (empty($date_array)) { |
|
| 1061 | + print _("No data available"); |
|
| 1062 | + } else { |
|
| 989 | 1063 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 990 | 1064 | $date_data = ''; |
| 991 | 1065 | $date_cnt = ''; |
@@ -1012,8 +1086,9 @@ discard block |
||
| 1012 | 1086 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 1013 | 1087 | <?php |
| 1014 | 1088 | $hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name); |
| 1015 | - if (empty($hour_array)) print _("No data available"); |
|
| 1016 | - else { |
|
| 1089 | + if (empty($hour_array)) { |
|
| 1090 | + print _("No data available"); |
|
| 1091 | + } else { |
|
| 1017 | 1092 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 1018 | 1093 | $hour_data = ''; |
| 1019 | 1094 | $hour_cnt = ''; |
@@ -1052,8 +1127,9 @@ discard block |
||
| 1052 | 1127 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 1053 | 1128 | <?php |
| 1054 | 1129 | $year_array = $Tracker->countAllMonthsLastYear(true); |
| 1055 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1056 | - else { |
|
| 1130 | + if (count($year_array) == 0) { |
|
| 1131 | + print _("No data available"); |
|
| 1132 | + } else { |
|
| 1057 | 1133 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 1058 | 1134 | $year_data = ''; |
| 1059 | 1135 | $year_cnt = ''; |
@@ -1081,8 +1157,9 @@ discard block |
||
| 1081 | 1157 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 1082 | 1158 | <?php |
| 1083 | 1159 | $month_array = $Tracker->countAllDatesLastMonth(); |
| 1084 | - if (count($month_array) == 0) print _("No data available"); |
|
| 1085 | - else { |
|
| 1160 | + if (count($month_array) == 0) { |
|
| 1161 | + print _("No data available"); |
|
| 1162 | + } else { |
|
| 1086 | 1163 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 1087 | 1164 | $month_data = ''; |
| 1088 | 1165 | $month_cnt = ''; |
@@ -1110,8 +1187,9 @@ discard block |
||
| 1110 | 1187 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 1111 | 1188 | <?php |
| 1112 | 1189 | $date_array = $Tracker->countAllDatesLast7Days(); |
| 1113 | - if (empty($date_array)) print _("No data available"); |
|
| 1114 | - else { |
|
| 1190 | + if (empty($date_array)) { |
|
| 1191 | + print _("No data available"); |
|
| 1192 | + } else { |
|
| 1115 | 1193 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 1116 | 1194 | $date_data = ''; |
| 1117 | 1195 | $date_cnt = ''; |
@@ -1138,8 +1216,9 @@ discard block |
||
| 1138 | 1216 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 1139 | 1217 | <?php |
| 1140 | 1218 | $hour_array = $Tracker->countAllHours('hour',true); |
| 1141 | - if (empty($hour_array)) print _("No data available"); |
|
| 1142 | - else { |
|
| 1219 | + if (empty($hour_array)) { |
|
| 1220 | + print _("No data available"); |
|
| 1221 | + } else { |
|
| 1143 | 1222 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 1144 | 1223 | $hour_data = ''; |
| 1145 | 1224 | $hour_cnt = ''; |
@@ -1178,8 +1257,9 @@ discard block |
||
| 1178 | 1257 | <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2> |
| 1179 | 1258 | <?php |
| 1180 | 1259 | $year_array = $Satellite->countAllMonthsLastYear(); |
| 1181 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1182 | - else { |
|
| 1260 | + if (count($year_array) == 0) { |
|
| 1261 | + print _("No data available"); |
|
| 1262 | + } else { |
|
| 1183 | 1263 | print '<div id="chart21" class="chart" width="100%"></div><script>'; |
| 1184 | 1264 | $year_data = ''; |
| 1185 | 1265 | $year_cnt = ''; |
@@ -1209,8 +1289,9 @@ discard block |
||
| 1209 | 1289 | <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2> |
| 1210 | 1290 | <?php |
| 1211 | 1291 | $year_array = $Satellite->countAllYears(); |
| 1212 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1213 | - else { |
|
| 1292 | + if (count($year_array) == 0) { |
|
| 1293 | + print _("No data available"); |
|
| 1294 | + } else { |
|
| 1214 | 1295 | print '<div id="chart22" class="chart" width="100%"></div><script>'; |
| 1215 | 1296 | $year_data = ''; |
| 1216 | 1297 | $year_cnt = ''; |
@@ -1252,8 +1333,9 @@ discard block |
||
| 1252 | 1333 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
| 1253 | 1334 | <?php |
| 1254 | 1335 | $year_array = $Stats->countFatalitiesByYear(); |
| 1255 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1256 | - else { |
|
| 1336 | + if (count($year_array) == 0) { |
|
| 1337 | + print _("No data available"); |
|
| 1338 | + } else { |
|
| 1257 | 1339 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
| 1258 | 1340 | $year_data = ''; |
| 1259 | 1341 | $year_cnt = ''; |
@@ -1282,8 +1364,9 @@ discard block |
||
| 1282 | 1364 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
| 1283 | 1365 | <?php |
| 1284 | 1366 | $year_array = $Stats->countFatalitiesLast12Months(); |
| 1285 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1286 | - else { |
|
| 1367 | + if (count($year_array) == 0) { |
|
| 1368 | + print _("No data available"); |
|
| 1369 | + } else { |
|
| 1287 | 1370 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
| 1288 | 1371 | $year_data = ''; |
| 1289 | 1372 | $year_cnt = ''; |
@@ -1354,8 +1437,11 @@ discard block |
||
| 1354 | 1437 | $distance = $distance; |
| 1355 | 1438 | $unit = 'km'; |
| 1356 | 1439 | } |
| 1357 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1358 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1440 | + if (!isset($polar_data)) { |
|
| 1441 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1442 | + } else { |
|
| 1443 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1444 | + } |
|
| 1359 | 1445 | } |
| 1360 | 1446 | ?> |
| 1361 | 1447 | <div class="col-md-6"> |
@@ -1419,9 +1505,12 @@ discard block |
||
| 1419 | 1505 | foreach ($msg as $eachmsg) { |
| 1420 | 1506 | //$eachmsg = $msg[0]; |
| 1421 | 1507 | $data = $eachmsg['source_data']; |
| 1422 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
| 1423 | - else $max = 500; |
|
| 1424 | -?> |
|
| 1508 | + if ($data > 500) { |
|
| 1509 | + $max = (round(($data+100)/100))*100; |
|
| 1510 | + } else { |
|
| 1511 | + $max = 500; |
|
| 1512 | + } |
|
| 1513 | + ?> |
|
| 1425 | 1514 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
| 1426 | 1515 | <script> |
| 1427 | 1516 | var g = new JustGage({ |
@@ -15,10 +15,14 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function __construct($dbc = null) { |
| 17 | 17 | global $globalFilterName; |
| 18 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 18 | + if (isset($globalFilterName)) { |
|
| 19 | + $this->filter_name = $globalFilterName; |
|
| 20 | + } |
|
| 19 | 21 | $Connection = new Connection($dbc); |
| 20 | 22 | $this->db = $Connection->db(); |
| 21 | - if ($this->db === null) die('Error: No DB connection. (Stats)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Stats)'); |
|
| 25 | + } |
|
| 22 | 26 | } |
| 23 | 27 | |
| 24 | 28 | public function addLastStatsUpdate($type,$stats_date) { |
@@ -86,7 +90,9 @@ discard block |
||
| 86 | 90 | |
| 87 | 91 | public function getAllAirlineNames($filter_name = '') { |
| 88 | 92 | global $globalStatsFilters; |
| 89 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 93 | + if ($filter_name == '') { |
|
| 94 | + $filter_name = $this->filter_name; |
|
| 95 | + } |
|
| 90 | 96 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 91 | 97 | try { |
| 92 | 98 | $sth = $this->db->prepare($query); |
@@ -106,7 +112,9 @@ discard block |
||
| 106 | 112 | return $all; |
| 107 | 113 | } |
| 108 | 114 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 109 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 115 | + if ($filter_name == '') { |
|
| 116 | + $filter_name = $this->filter_name; |
|
| 117 | + } |
|
| 110 | 118 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 111 | 119 | try { |
| 112 | 120 | $sth = $this->db->prepare($query); |
@@ -118,7 +126,9 @@ discard block |
||
| 118 | 126 | return $all; |
| 119 | 127 | } |
| 120 | 128 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 121 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 129 | + if ($filter_name == '') { |
|
| 130 | + $filter_name = $this->filter_name; |
|
| 131 | + } |
|
| 122 | 132 | $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"; |
| 123 | 133 | try { |
| 124 | 134 | $sth = $this->db->prepare($query); |
@@ -130,7 +140,9 @@ discard block |
||
| 130 | 140 | return $all; |
| 131 | 141 | } |
| 132 | 142 | public function getAllAirportNames($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 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"; |
| 135 | 147 | try { |
| 136 | 148 | $sth = $this->db->prepare($query); |
@@ -143,7 +155,9 @@ discard block |
||
| 143 | 155 | } |
| 144 | 156 | |
| 145 | 157 | public function getAllOwnerNames($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 owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 148 | 162 | try { |
| 149 | 163 | $sth = $this->db->prepare($query); |
@@ -156,7 +170,9 @@ discard block |
||
| 156 | 170 | } |
| 157 | 171 | |
| 158 | 172 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 159 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 173 | + if ($filter_name == '') { |
|
| 174 | + $filter_name = $this->filter_name; |
|
| 175 | + } |
|
| 160 | 176 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 161 | 177 | try { |
| 162 | 178 | $sth = $this->db->prepare($query); |
@@ -171,7 +187,9 @@ discard block |
||
| 171 | 187 | |
| 172 | 188 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 173 | 189 | global $globalStatsFilters; |
| 174 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 190 | + if ($filter_name == '') { |
|
| 191 | + $filter_name = $this->filter_name; |
|
| 192 | + } |
|
| 175 | 193 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 176 | 194 | $Spotter = new Spotter($this->db); |
| 177 | 195 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -180,8 +198,11 @@ discard block |
||
| 180 | 198 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 181 | 199 | } |
| 182 | 200 | if ($year == '' && $month == '') { |
| 183 | - 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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 184 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 201 | + if ($limit) { |
|
| 202 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 203 | + } else { |
|
| 204 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 205 | + } |
|
| 185 | 206 | try { |
| 186 | 207 | $sth = $this->db->prepare($query); |
| 187 | 208 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,11 +210,16 @@ discard block |
||
| 189 | 210 | echo "error : ".$e->getMessage(); |
| 190 | 211 | } |
| 191 | 212 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 192 | - } else $all = array(); |
|
| 213 | + } else { |
|
| 214 | + $all = array(); |
|
| 215 | + } |
|
| 193 | 216 | } else { |
| 194 | 217 | if ($year == '' && $month == '') { |
| 195 | - 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 aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 196 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 218 | + if ($limit) { |
|
| 219 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 220 | + } else { |
|
| 221 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 222 | + } |
|
| 197 | 223 | try { |
| 198 | 224 | $sth = $this->db->prepare($query); |
| 199 | 225 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -201,7 +227,9 @@ discard block |
||
| 201 | 227 | echo "error : ".$e->getMessage(); |
| 202 | 228 | } |
| 203 | 229 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 204 | - } else $all = array(); |
|
| 230 | + } else { |
|
| 231 | + $all = array(); |
|
| 232 | + } |
|
| 205 | 233 | } |
| 206 | 234 | if (empty($all)) { |
| 207 | 235 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -220,10 +248,15 @@ discard block |
||
| 220 | 248 | } |
| 221 | 249 | public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') { |
| 222 | 250 | global $globalStatsFilters; |
| 223 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 251 | + if ($filter_name == '') { |
|
| 252 | + $filter_name = $this->filter_name; |
|
| 253 | + } |
|
| 224 | 254 | if ($year == '' && $month == '') { |
| 225 | - if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
| 226 | - else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 255 | + if ($limit) { |
|
| 256 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0"; |
|
| 257 | + } else { |
|
| 258 | + $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 259 | + } |
|
| 227 | 260 | try { |
| 228 | 261 | $sth = $this->db->prepare($query); |
| 229 | 262 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -231,7 +264,9 @@ discard block |
||
| 231 | 264 | echo "error : ".$e->getMessage(); |
| 232 | 265 | } |
| 233 | 266 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 234 | - } else $all = array(); |
|
| 267 | + } else { |
|
| 268 | + $all = array(); |
|
| 269 | + } |
|
| 235 | 270 | if (empty($all)) { |
| 236 | 271 | $filters = array('year' => $year,'month' => $month); |
| 237 | 272 | if ($filter_name != '') { |
@@ -245,10 +280,15 @@ discard block |
||
| 245 | 280 | } |
| 246 | 281 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 247 | 282 | global $globalStatsFilters; |
| 248 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 283 | + if ($filter_name == '') { |
|
| 284 | + $filter_name = $this->filter_name; |
|
| 285 | + } |
|
| 249 | 286 | if ($year == '' && $month == '') { |
| 250 | - 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"; |
|
| 251 | - 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"; |
|
| 287 | + if ($limit) { |
|
| 288 | + $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"; |
|
| 289 | + } else { |
|
| 290 | + $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"; |
|
| 291 | + } |
|
| 252 | 292 | try { |
| 253 | 293 | $sth = $this->db->prepare($query); |
| 254 | 294 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -256,7 +296,9 @@ discard block |
||
| 256 | 296 | echo "error : ".$e->getMessage(); |
| 257 | 297 | } |
| 258 | 298 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 259 | - } else $all = array(); |
|
| 299 | + } else { |
|
| 300 | + $all = array(); |
|
| 301 | + } |
|
| 260 | 302 | if (empty($all)) { |
| 261 | 303 | $Spotter = new Spotter($this->db); |
| 262 | 304 | $filters = array(); |
@@ -271,7 +313,9 @@ discard block |
||
| 271 | 313 | } |
| 272 | 314 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 273 | 315 | global $globalStatsFilters; |
| 274 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 316 | + if ($filter_name == '') { |
|
| 317 | + $filter_name = $this->filter_name; |
|
| 318 | + } |
|
| 275 | 319 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 276 | 320 | $Spotter = new Spotter($this->db); |
| 277 | 321 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -280,8 +324,11 @@ discard block |
||
| 280 | 324 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 281 | 325 | } |
| 282 | 326 | if ($year == '' && $month == '') { |
| 283 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 284 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 327 | + if ($limit) { |
|
| 328 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 329 | + } else { |
|
| 330 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 331 | + } |
|
| 285 | 332 | try { |
| 286 | 333 | $sth = $this->db->prepare($query); |
| 287 | 334 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -289,11 +336,16 @@ discard block |
||
| 289 | 336 | echo "error : ".$e->getMessage(); |
| 290 | 337 | } |
| 291 | 338 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 292 | - } else $all = array(); |
|
| 339 | + } else { |
|
| 340 | + $all = array(); |
|
| 341 | + } |
|
| 293 | 342 | } else { |
| 294 | 343 | if ($year == '' && $month == '') { |
| 295 | - 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"; |
|
| 296 | - 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"; |
|
| 344 | + if ($limit) { |
|
| 345 | + $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"; |
|
| 346 | + } else { |
|
| 347 | + $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"; |
|
| 348 | + } |
|
| 297 | 349 | try { |
| 298 | 350 | $sth = $this->db->prepare($query); |
| 299 | 351 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -301,7 +353,9 @@ discard block |
||
| 301 | 353 | echo "error : ".$e->getMessage(); |
| 302 | 354 | } |
| 303 | 355 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 304 | - } else $all = array(); |
|
| 356 | + } else { |
|
| 357 | + $all = array(); |
|
| 358 | + } |
|
| 305 | 359 | } |
| 306 | 360 | if (empty($all)) { |
| 307 | 361 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -321,7 +375,9 @@ discard block |
||
| 321 | 375 | |
| 322 | 376 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 323 | 377 | global $globalStatsFilters; |
| 324 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 378 | + if ($filter_name == '') { |
|
| 379 | + $filter_name = $this->filter_name; |
|
| 380 | + } |
|
| 325 | 381 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 326 | 382 | $Spotter = new Spotter($this->db); |
| 327 | 383 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -330,8 +386,11 @@ discard block |
||
| 330 | 386 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 331 | 387 | } |
| 332 | 388 | if ($year == '' && $month == '') { |
| 333 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 334 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 389 | + if ($limit) { |
|
| 390 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 391 | + } else { |
|
| 392 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
|
| 393 | + } |
|
| 335 | 394 | try { |
| 336 | 395 | $sth = $this->db->prepare($query); |
| 337 | 396 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -339,11 +398,16 @@ discard block |
||
| 339 | 398 | echo "error : ".$e->getMessage(); |
| 340 | 399 | } |
| 341 | 400 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 342 | - } else $all = array(); |
|
| 401 | + } else { |
|
| 402 | + $all = array(); |
|
| 403 | + } |
|
| 343 | 404 | } else { |
| 344 | 405 | if ($year == '' && $month == '') { |
| 345 | - 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"; |
|
| 346 | - 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"; |
|
| 406 | + if ($limit) { |
|
| 407 | + $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"; |
|
| 408 | + } else { |
|
| 409 | + $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"; |
|
| 410 | + } |
|
| 347 | 411 | try { |
| 348 | 412 | $sth = $this->db->prepare($query); |
| 349 | 413 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -351,7 +415,9 @@ discard block |
||
| 351 | 415 | echo "error : ".$e->getMessage(); |
| 352 | 416 | } |
| 353 | 417 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 354 | - } else $all = array(); |
|
| 418 | + } else { |
|
| 419 | + $all = array(); |
|
| 420 | + } |
|
| 355 | 421 | } |
| 356 | 422 | if (empty($all)) { |
| 357 | 423 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -370,7 +436,9 @@ discard block |
||
| 370 | 436 | } |
| 371 | 437 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 372 | 438 | global $globalStatsFilters; |
| 373 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 439 | + if ($filter_name == '') { |
|
| 440 | + $filter_name = $this->filter_name; |
|
| 441 | + } |
|
| 374 | 442 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 375 | 443 | $Spotter = new Spotter($this->db); |
| 376 | 444 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -378,12 +446,18 @@ discard block |
||
| 378 | 446 | foreach ($airlines as $airline) { |
| 379 | 447 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 380 | 448 | } |
| 381 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 382 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 449 | + if ($limit) { |
|
| 450 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 451 | + } else { |
|
| 452 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
|
| 453 | + } |
|
| 383 | 454 | $query_values = array(':filter_name' => $filter_name); |
| 384 | 455 | } else { |
| 385 | - 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"; |
|
| 386 | - 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"; |
|
| 456 | + if ($limit) { |
|
| 457 | + $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"; |
|
| 458 | + } else { |
|
| 459 | + $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"; |
|
| 460 | + } |
|
| 387 | 461 | $query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 388 | 462 | } |
| 389 | 463 | try { |
@@ -411,17 +485,29 @@ discard block |
||
| 411 | 485 | |
| 412 | 486 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 413 | 487 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 414 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 488 | + if ($filter_name == '') { |
|
| 489 | + $filter_name = $this->filter_name; |
|
| 490 | + } |
|
| 415 | 491 | if ($year == '' && $month == '') { |
| 416 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 417 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 492 | + if ($globalVATSIM) { |
|
| 493 | + $forsource = 'vatsim'; |
|
| 494 | + } |
|
| 495 | + if ($globalIVAO) { |
|
| 496 | + $forsource = 'ivao'; |
|
| 497 | + } |
|
| 418 | 498 | if (isset($forsource)) { |
| 419 | - 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"; |
|
| 420 | - 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"; |
|
| 499 | + if ($limit) { |
|
| 500 | + $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"; |
|
| 501 | + } else { |
|
| 502 | + $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"; |
|
| 503 | + } |
|
| 421 | 504 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 422 | 505 | } else { |
| 423 | - 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"; |
|
| 424 | - 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"; |
|
| 506 | + if ($limit) { |
|
| 507 | + $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"; |
|
| 508 | + } else { |
|
| 509 | + $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"; |
|
| 510 | + } |
|
| 425 | 511 | $query_values = array(':filter_name' => $filter_name); |
| 426 | 512 | } |
| 427 | 513 | try { |
@@ -431,7 +517,9 @@ discard block |
||
| 431 | 517 | echo "error : ".$e->getMessage(); |
| 432 | 518 | } |
| 433 | 519 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 434 | - } else $all = array(); |
|
| 520 | + } else { |
|
| 521 | + $all = array(); |
|
| 522 | + } |
|
| 435 | 523 | if (empty($all)) { |
| 436 | 524 | $Spotter = new Spotter($this->db); |
| 437 | 525 | $filters = array(); |
@@ -446,7 +534,9 @@ discard block |
||
| 446 | 534 | } |
| 447 | 535 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 448 | 536 | global $globalStatsFilters; |
| 449 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 537 | + if ($filter_name == '') { |
|
| 538 | + $filter_name = $this->filter_name; |
|
| 539 | + } |
|
| 450 | 540 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 451 | 541 | $Spotter = new Spotter($this->db); |
| 452 | 542 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -455,8 +545,11 @@ discard block |
||
| 455 | 545 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 456 | 546 | } |
| 457 | 547 | if ($year == '' && $month == '') { |
| 458 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 459 | - else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 548 | + if ($limit) { |
|
| 549 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 550 | + } else { |
|
| 551 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC"; |
|
| 552 | + } |
|
| 460 | 553 | try { |
| 461 | 554 | $sth = $this->db->prepare($query); |
| 462 | 555 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -464,11 +557,16 @@ discard block |
||
| 464 | 557 | echo "error : ".$e->getMessage(); |
| 465 | 558 | } |
| 466 | 559 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 467 | - } else $all = array(); |
|
| 560 | + } else { |
|
| 561 | + $all = array(); |
|
| 562 | + } |
|
| 468 | 563 | } else { |
| 469 | 564 | if ($year == '' && $month == '') { |
| 470 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 471 | - else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC"; |
|
| 565 | + if ($limit) { |
|
| 566 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 567 | + } else { |
|
| 568 | + $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC"; |
|
| 569 | + } |
|
| 472 | 570 | try { |
| 473 | 571 | $sth = $this->db->prepare($query); |
| 474 | 572 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -476,7 +574,9 @@ discard block |
||
| 476 | 574 | echo "error : ".$e->getMessage(); |
| 477 | 575 | } |
| 478 | 576 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 479 | - } else $all = array(); |
|
| 577 | + } else { |
|
| 578 | + $all = array(); |
|
| 579 | + } |
|
| 480 | 580 | } |
| 481 | 581 | if (empty($all)) { |
| 482 | 582 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -495,7 +595,9 @@ discard block |
||
| 495 | 595 | } |
| 496 | 596 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 497 | 597 | global $globalStatsFilters; |
| 498 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 598 | + if ($filter_name == '') { |
|
| 599 | + $filter_name = $this->filter_name; |
|
| 600 | + } |
|
| 499 | 601 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 500 | 602 | $Spotter = new Spotter($this->db); |
| 501 | 603 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -504,8 +606,11 @@ discard block |
||
| 504 | 606 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 505 | 607 | } |
| 506 | 608 | if ($year == '' && $month == '') { |
| 507 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 508 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 609 | + if ($limit) { |
|
| 610 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 611 | + } else { |
|
| 612 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 613 | + } |
|
| 509 | 614 | try { |
| 510 | 615 | $sth = $this->db->prepare($query); |
| 511 | 616 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -513,11 +618,16 @@ discard block |
||
| 513 | 618 | echo "error : ".$e->getMessage(); |
| 514 | 619 | } |
| 515 | 620 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 516 | - } else $all = array(); |
|
| 621 | + } else { |
|
| 622 | + $all = array(); |
|
| 623 | + } |
|
| 517 | 624 | } else { |
| 518 | 625 | if ($year == '' && $month == '') { |
| 519 | - 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"; |
|
| 520 | - 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"; |
|
| 626 | + if ($limit) { |
|
| 627 | + $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"; |
|
| 628 | + } else { |
|
| 629 | + $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"; |
|
| 630 | + } |
|
| 521 | 631 | try { |
| 522 | 632 | $sth = $this->db->prepare($query); |
| 523 | 633 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -525,7 +635,9 @@ discard block |
||
| 525 | 635 | echo "error : ".$e->getMessage(); |
| 526 | 636 | } |
| 527 | 637 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 528 | - } else $all = array(); |
|
| 638 | + } else { |
|
| 639 | + $all = array(); |
|
| 640 | + } |
|
| 529 | 641 | } |
| 530 | 642 | if (empty($all)) { |
| 531 | 643 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -544,7 +656,9 @@ discard block |
||
| 544 | 656 | } |
| 545 | 657 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 546 | 658 | $Connection = new Connection($this->db); |
| 547 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 659 | + if ($filter_name == '') { |
|
| 660 | + $filter_name = $this->filter_name; |
|
| 661 | + } |
|
| 548 | 662 | if ($Connection->tableExists('countries')) { |
| 549 | 663 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 550 | 664 | $Spotter = new Spotter($this->db); |
@@ -554,8 +668,11 @@ discard block |
||
| 554 | 668 | foreach ($airlines as $airline) { |
| 555 | 669 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 556 | 670 | } |
| 557 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 558 | - 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 671 | + if ($limit) { |
|
| 672 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 673 | + } else { |
|
| 674 | + $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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 675 | + } |
|
| 559 | 676 | try { |
| 560 | 677 | $sth = $this->db->prepare($query); |
| 561 | 678 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -564,11 +681,16 @@ discard block |
||
| 564 | 681 | } |
| 565 | 682 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 566 | 683 | return $all; |
| 567 | - } else return array(); |
|
| 684 | + } else { |
|
| 685 | + return array(); |
|
| 686 | + } |
|
| 568 | 687 | } else { |
| 569 | 688 | if ($year == '' && $month == '') { |
| 570 | - 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"; |
|
| 571 | - 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"; |
|
| 689 | + if ($limit) { |
|
| 690 | + $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"; |
|
| 691 | + } else { |
|
| 692 | + $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"; |
|
| 693 | + } |
|
| 572 | 694 | try { |
| 573 | 695 | $sth = $this->db->prepare($query); |
| 574 | 696 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -577,20 +699,29 @@ discard block |
||
| 577 | 699 | } |
| 578 | 700 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 579 | 701 | return $all; |
| 580 | - } else return array(); |
|
| 702 | + } else { |
|
| 703 | + return array(); |
|
| 704 | + } |
|
| 581 | 705 | } |
| 582 | 706 | $Spotter = new Spotter($this->db); |
| 583 | 707 | return $Spotter->countAllFlightOverCountries($limit); |
| 584 | - } else return array(); |
|
| 708 | + } else { |
|
| 709 | + return array(); |
|
| 710 | + } |
|
| 585 | 711 | } |
| 586 | 712 | public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
| 587 | 713 | $Connection = new Connection($this->db); |
| 588 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 714 | + if ($filter_name == '') { |
|
| 715 | + $filter_name = $this->filter_name; |
|
| 716 | + } |
|
| 589 | 717 | if ($Connection->tableExists('countries')) { |
| 590 | 718 | $all = array(); |
| 591 | 719 | if ($year == '' && $month == '') { |
| 592 | - if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
| 593 | - else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
| 720 | + if ($limit) { |
|
| 721 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0"; |
|
| 722 | + } else { |
|
| 723 | + $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC"; |
|
| 724 | + } |
|
| 594 | 725 | try { |
| 595 | 726 | $sth = $this->db->prepare($query); |
| 596 | 727 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -608,17 +739,24 @@ discard block |
||
| 608 | 739 | $all = $Marine->countAllMarineOverCountries($limit,0,'',$filters); |
| 609 | 740 | } |
| 610 | 741 | return $all; |
| 611 | - } else return array(); |
|
| 742 | + } else { |
|
| 743 | + return array(); |
|
| 744 | + } |
|
| 612 | 745 | } |
| 613 | 746 | public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') { |
| 614 | 747 | global $globalStatsFilters; |
| 615 | 748 | $Connection = new Connection($this->db); |
| 616 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 749 | + if ($filter_name == '') { |
|
| 750 | + $filter_name = $this->filter_name; |
|
| 751 | + } |
|
| 617 | 752 | if ($Connection->tableExists('countries')) { |
| 618 | 753 | $all = array(); |
| 619 | 754 | if ($year == '' && $month == '') { |
| 620 | - if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
| 621 | - else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
| 755 | + if ($limit) { |
|
| 756 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0"; |
|
| 757 | + } else { |
|
| 758 | + $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC"; |
|
| 759 | + } |
|
| 622 | 760 | try { |
| 623 | 761 | $sth = $this->db->prepare($query); |
| 624 | 762 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -637,14 +775,21 @@ discard block |
||
| 637 | 775 | $all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters); |
| 638 | 776 | } |
| 639 | 777 | return $all; |
| 640 | - } else return array(); |
|
| 778 | + } else { |
|
| 779 | + return array(); |
|
| 780 | + } |
|
| 641 | 781 | } |
| 642 | 782 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 643 | 783 | global $globalStatsFilters; |
| 644 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 784 | + if ($filter_name == '') { |
|
| 785 | + $filter_name = $this->filter_name; |
|
| 786 | + } |
|
| 645 | 787 | if ($year == '' && $month == '') { |
| 646 | - 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"; |
|
| 647 | - 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"; |
|
| 788 | + if ($limit) { |
|
| 789 | + $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"; |
|
| 790 | + } else { |
|
| 791 | + $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"; |
|
| 792 | + } |
|
| 648 | 793 | try { |
| 649 | 794 | $sth = $this->db->prepare($query); |
| 650 | 795 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -652,7 +797,9 @@ discard block |
||
| 652 | 797 | echo "error : ".$e->getMessage(); |
| 653 | 798 | } |
| 654 | 799 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 655 | - } else $all = array(); |
|
| 800 | + } else { |
|
| 801 | + $all = array(); |
|
| 802 | + } |
|
| 656 | 803 | if (empty($all)) { |
| 657 | 804 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 658 | 805 | if ($filter_name != '') { |
@@ -667,7 +814,9 @@ discard block |
||
| 667 | 814 | |
| 668 | 815 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 669 | 816 | global $globalStatsFilters; |
| 670 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 817 | + if ($filter_name == '') { |
|
| 818 | + $filter_name = $this->filter_name; |
|
| 819 | + } |
|
| 671 | 820 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 672 | 821 | $Spotter = new Spotter($this->db); |
| 673 | 822 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -676,8 +825,11 @@ discard block |
||
| 676 | 825 | foreach ($airlines as $airline) { |
| 677 | 826 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 678 | 827 | } |
| 679 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 680 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 828 | + if ($limit) { |
|
| 829 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 830 | + } else { |
|
| 831 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 832 | + } |
|
| 681 | 833 | try { |
| 682 | 834 | $sth = $this->db->prepare($query); |
| 683 | 835 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -685,11 +837,16 @@ discard block |
||
| 685 | 837 | echo "error : ".$e->getMessage(); |
| 686 | 838 | } |
| 687 | 839 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 688 | - } else $all = array(); |
|
| 840 | + } else { |
|
| 841 | + $all = array(); |
|
| 842 | + } |
|
| 689 | 843 | } else { |
| 690 | 844 | if ($year == '' && $month == '') { |
| 691 | - 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"; |
|
| 692 | - 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"; |
|
| 845 | + if ($limit) { |
|
| 846 | + $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"; |
|
| 847 | + } else { |
|
| 848 | + $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"; |
|
| 849 | + } |
|
| 693 | 850 | try { |
| 694 | 851 | $sth = $this->db->prepare($query); |
| 695 | 852 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -697,7 +854,9 @@ discard block |
||
| 697 | 854 | echo "error : ".$e->getMessage(); |
| 698 | 855 | } |
| 699 | 856 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 700 | - } else $all = array(); |
|
| 857 | + } else { |
|
| 858 | + $all = array(); |
|
| 859 | + } |
|
| 701 | 860 | } |
| 702 | 861 | if (empty($all)) { |
| 703 | 862 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -716,7 +875,9 @@ discard block |
||
| 716 | 875 | } |
| 717 | 876 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 718 | 877 | global $globalStatsFilters; |
| 719 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 878 | + if ($filter_name == '') { |
|
| 879 | + $filter_name = $this->filter_name; |
|
| 880 | + } |
|
| 720 | 881 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 721 | 882 | $Spotter = new Spotter($this->db); |
| 722 | 883 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -725,8 +886,11 @@ discard block |
||
| 725 | 886 | foreach ($airlines as $airline) { |
| 726 | 887 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 727 | 888 | } |
| 728 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 729 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 889 | + if ($limit) { |
|
| 890 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 891 | + } else { |
|
| 892 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 893 | + } |
|
| 730 | 894 | try { |
| 731 | 895 | $sth = $this->db->prepare($query); |
| 732 | 896 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -734,11 +898,16 @@ discard block |
||
| 734 | 898 | echo "error : ".$e->getMessage(); |
| 735 | 899 | } |
| 736 | 900 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 737 | - } else $all = array(); |
|
| 901 | + } else { |
|
| 902 | + $all = array(); |
|
| 903 | + } |
|
| 738 | 904 | } else { |
| 739 | 905 | if ($year == '' && $month == '') { |
| 740 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 741 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 906 | + if ($limit) { |
|
| 907 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 908 | + } else { |
|
| 909 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,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"; |
|
| 910 | + } |
|
| 742 | 911 | try { |
| 743 | 912 | $sth = $this->db->prepare($query); |
| 744 | 913 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -746,7 +915,9 @@ discard block |
||
| 746 | 915 | echo "error : ".$e->getMessage(); |
| 747 | 916 | } |
| 748 | 917 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 749 | - } else $all = array(); |
|
| 918 | + } else { |
|
| 919 | + $all = array(); |
|
| 920 | + } |
|
| 750 | 921 | } |
| 751 | 922 | if (empty($all)) { |
| 752 | 923 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -771,7 +942,9 @@ discard block |
||
| 771 | 942 | $icao = $value['airport_departure_icao']; |
| 772 | 943 | if (isset($all[$icao])) { |
| 773 | 944 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 774 | - } else $all[$icao] = $value; |
|
| 945 | + } else { |
|
| 946 | + $all[$icao] = $value; |
|
| 947 | + } |
|
| 775 | 948 | } |
| 776 | 949 | $count = array(); |
| 777 | 950 | foreach ($all as $key => $row) { |
@@ -783,7 +956,9 @@ discard block |
||
| 783 | 956 | } |
| 784 | 957 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 785 | 958 | global $globalStatsFilters; |
| 786 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 959 | + if ($filter_name == '') { |
|
| 960 | + $filter_name = $this->filter_name; |
|
| 961 | + } |
|
| 787 | 962 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 788 | 963 | $Spotter = new Spotter($this->db); |
| 789 | 964 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -792,8 +967,11 @@ discard block |
||
| 792 | 967 | foreach ($airlines as $airline) { |
| 793 | 968 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 794 | 969 | } |
| 795 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 796 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 970 | + if ($limit) { |
|
| 971 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 972 | + } else { |
|
| 973 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 974 | + } |
|
| 797 | 975 | try { |
| 798 | 976 | $sth = $this->db->prepare($query); |
| 799 | 977 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -801,11 +979,16 @@ discard block |
||
| 801 | 979 | echo "error : ".$e->getMessage(); |
| 802 | 980 | } |
| 803 | 981 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 804 | - } else $all = array(); |
|
| 982 | + } else { |
|
| 983 | + $all = array(); |
|
| 984 | + } |
|
| 805 | 985 | } else { |
| 806 | 986 | if ($year == '' && $month == '') { |
| 807 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 808 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 987 | + if ($limit) { |
|
| 988 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 989 | + } else { |
|
| 990 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, 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"; |
|
| 991 | + } |
|
| 809 | 992 | try { |
| 810 | 993 | $sth = $this->db->prepare($query); |
| 811 | 994 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -813,7 +996,9 @@ discard block |
||
| 813 | 996 | echo "error : ".$e->getMessage(); |
| 814 | 997 | } |
| 815 | 998 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 816 | - } else $all = array(); |
|
| 999 | + } else { |
|
| 1000 | + $all = array(); |
|
| 1001 | + } |
|
| 817 | 1002 | } |
| 818 | 1003 | if (empty($all)) { |
| 819 | 1004 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -838,7 +1023,9 @@ discard block |
||
| 838 | 1023 | $icao = $value['airport_arrival_icao']; |
| 839 | 1024 | if (isset($all[$icao])) { |
| 840 | 1025 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 841 | - } else $all[$icao] = $value; |
|
| 1026 | + } else { |
|
| 1027 | + $all[$icao] = $value; |
|
| 1028 | + } |
|
| 842 | 1029 | } |
| 843 | 1030 | $count = array(); |
| 844 | 1031 | foreach ($all as $key => $row) { |
@@ -850,7 +1037,9 @@ discard block |
||
| 850 | 1037 | } |
| 851 | 1038 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 852 | 1039 | global $globalDBdriver, $globalStatsFilters; |
| 853 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1040 | + if ($filter_name == '') { |
|
| 1041 | + $filter_name = $this->filter_name; |
|
| 1042 | + } |
|
| 854 | 1043 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 855 | 1044 | $Spotter = new Spotter($this->db); |
| 856 | 1045 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -859,20 +1048,32 @@ discard block |
||
| 859 | 1048 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 860 | 1049 | } |
| 861 | 1050 | if ($globalDBdriver == 'mysql') { |
| 862 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 863 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1051 | + if ($limit) { |
|
| 1052 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1053 | + } else { |
|
| 1054 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1055 | + } |
|
| 864 | 1056 | } else { |
| 865 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 866 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1057 | + if ($limit) { |
|
| 1058 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1059 | + } else { |
|
| 1060 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date"; |
|
| 1061 | + } |
|
| 867 | 1062 | } |
| 868 | 1063 | $query_data = array(':filter_name' => $filter_name); |
| 869 | 1064 | } else { |
| 870 | 1065 | if ($globalDBdriver == 'mysql') { |
| 871 | - 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"; |
|
| 872 | - 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"; |
|
| 1066 | + if ($limit) { |
|
| 1067 | + $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"; |
|
| 1068 | + } else { |
|
| 1069 | + $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"; |
|
| 1070 | + } |
|
| 873 | 1071 | } else { |
| 874 | - 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"; |
|
| 875 | - 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"; |
|
| 1072 | + if ($limit) { |
|
| 1073 | + $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"; |
|
| 1074 | + } else { |
|
| 1075 | + $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"; |
|
| 1076 | + } |
|
| 876 | 1077 | } |
| 877 | 1078 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 878 | 1079 | } |
@@ -900,7 +1101,9 @@ discard block |
||
| 900 | 1101 | |
| 901 | 1102 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 902 | 1103 | global $globalStatsFilters; |
| 903 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1104 | + if ($filter_name == '') { |
|
| 1105 | + $filter_name = $this->filter_name; |
|
| 1106 | + } |
|
| 904 | 1107 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 905 | 1108 | $Spotter = new Spotter($this->db); |
| 906 | 1109 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -937,7 +1140,9 @@ discard block |
||
| 937 | 1140 | } |
| 938 | 1141 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 939 | 1142 | global $globalDBdriver, $globalStatsFilters; |
| 940 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1143 | + if ($filter_name == '') { |
|
| 1144 | + $filter_name = $this->filter_name; |
|
| 1145 | + } |
|
| 941 | 1146 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 942 | 1147 | $Spotter = new Spotter($this->db); |
| 943 | 1148 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -982,7 +1187,9 @@ discard block |
||
| 982 | 1187 | } |
| 983 | 1188 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 984 | 1189 | global $globalStatsFilters; |
| 985 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1190 | + if ($filter_name == '') { |
|
| 1191 | + $filter_name = $this->filter_name; |
|
| 1192 | + } |
|
| 986 | 1193 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 987 | 1194 | $Spotter = new Spotter($this->db); |
| 988 | 1195 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1019,7 +1226,9 @@ discard block |
||
| 1019 | 1226 | } |
| 1020 | 1227 | public function countAllDatesMarine($filter_name = '') { |
| 1021 | 1228 | global $globalStatsFilters; |
| 1022 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1229 | + if ($filter_name == '') { |
|
| 1230 | + $filter_name = $this->filter_name; |
|
| 1231 | + } |
|
| 1023 | 1232 | $query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 1024 | 1233 | $query_data = array(':filter_name' => $filter_name); |
| 1025 | 1234 | try { |
@@ -1041,7 +1250,9 @@ discard block |
||
| 1041 | 1250 | } |
| 1042 | 1251 | public function countAllDatesTracker($filter_name = '') { |
| 1043 | 1252 | global $globalStatsFilters; |
| 1044 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1253 | + if ($filter_name == '') { |
|
| 1254 | + $filter_name = $this->filter_name; |
|
| 1255 | + } |
|
| 1045 | 1256 | $query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC"; |
| 1046 | 1257 | $query_data = array(':filter_name' => $filter_name); |
| 1047 | 1258 | try { |
@@ -1063,7 +1274,9 @@ discard block |
||
| 1063 | 1274 | } |
| 1064 | 1275 | public function countAllDatesByAirlines($filter_name = '') { |
| 1065 | 1276 | global $globalStatsFilters; |
| 1066 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1277 | + if ($filter_name == '') { |
|
| 1278 | + $filter_name = $this->filter_name; |
|
| 1279 | + } |
|
| 1067 | 1280 | $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"; |
| 1068 | 1281 | $query_data = array('filter_name' => $filter_name); |
| 1069 | 1282 | try { |
@@ -1085,7 +1298,9 @@ discard block |
||
| 1085 | 1298 | } |
| 1086 | 1299 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 1087 | 1300 | global $globalStatsFilters, $globalDBdriver; |
| 1088 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1301 | + if ($filter_name == '') { |
|
| 1302 | + $filter_name = $this->filter_name; |
|
| 1303 | + } |
|
| 1089 | 1304 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1090 | 1305 | $Spotter = new Spotter($this->db); |
| 1091 | 1306 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1170,7 +1385,9 @@ discard block |
||
| 1170 | 1385 | } |
| 1171 | 1386 | public function countAllMilitaryMonths($filter_name = '') { |
| 1172 | 1387 | global $globalStatsFilters; |
| 1173 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1388 | + if ($filter_name == '') { |
|
| 1389 | + $filter_name = $this->filter_name; |
|
| 1390 | + } |
|
| 1174 | 1391 | $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"; |
| 1175 | 1392 | try { |
| 1176 | 1393 | $sth = $this->db->prepare($query); |
@@ -1191,7 +1408,9 @@ discard block |
||
| 1191 | 1408 | } |
| 1192 | 1409 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 1193 | 1410 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 1194 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1411 | + if ($filter_name == '') { |
|
| 1412 | + $filter_name = $this->filter_name; |
|
| 1413 | + } |
|
| 1195 | 1414 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1196 | 1415 | $Spotter = new Spotter($this->db); |
| 1197 | 1416 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1199,12 +1418,18 @@ discard block |
||
| 1199 | 1418 | foreach ($airlines as $airline) { |
| 1200 | 1419 | $alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao'])); |
| 1201 | 1420 | } |
| 1202 | - if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1203 | - else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1421 | + if ($limit) { |
|
| 1422 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1423 | + } else { |
|
| 1424 | + $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date"; |
|
| 1425 | + } |
|
| 1204 | 1426 | $query_data = array(':filter_name' => $filter_name); |
| 1205 | 1427 | } else { |
| 1206 | - 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"; |
|
| 1207 | - 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"; |
|
| 1428 | + if ($limit) { |
|
| 1429 | + $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"; |
|
| 1430 | + } else { |
|
| 1431 | + $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"; |
|
| 1432 | + } |
|
| 1208 | 1433 | $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 1209 | 1434 | } |
| 1210 | 1435 | if ($orderby == 'hour') { |
@@ -1214,7 +1439,9 @@ discard block |
||
| 1214 | 1439 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 1215 | 1440 | } |
| 1216 | 1441 | } |
| 1217 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 1442 | + if ($orderby == 'count') { |
|
| 1443 | + $query .= " ORDER BY hour_count DESC"; |
|
| 1444 | + } |
|
| 1218 | 1445 | try { |
| 1219 | 1446 | $sth = $this->db->prepare($query); |
| 1220 | 1447 | $sth->execute($query_data); |
@@ -1238,8 +1465,12 @@ discard block |
||
| 1238 | 1465 | } |
| 1239 | 1466 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 1240 | 1467 | global $globalStatsFilters; |
| 1241 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1242 | - if ($year == '') $year = date('Y'); |
|
| 1468 | + if ($filter_name == '') { |
|
| 1469 | + $filter_name = $this->filter_name; |
|
| 1470 | + } |
|
| 1471 | + if ($year == '') { |
|
| 1472 | + $year = date('Y'); |
|
| 1473 | + } |
|
| 1243 | 1474 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1244 | 1475 | if (empty($all)) { |
| 1245 | 1476 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1258,8 +1489,12 @@ discard block |
||
| 1258 | 1489 | } |
| 1259 | 1490 | public function countOverallMarine($filter_name = '',$year = '',$month = '') { |
| 1260 | 1491 | global $globalStatsFilters; |
| 1261 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1262 | - if ($year == '') $year = date('Y'); |
|
| 1492 | + if ($filter_name == '') { |
|
| 1493 | + $filter_name = $this->filter_name; |
|
| 1494 | + } |
|
| 1495 | + if ($year == '') { |
|
| 1496 | + $year = date('Y'); |
|
| 1497 | + } |
|
| 1263 | 1498 | $all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month); |
| 1264 | 1499 | if (empty($all)) { |
| 1265 | 1500 | $filters = array('year' => $year,'month' => $month); |
@@ -1274,8 +1509,12 @@ discard block |
||
| 1274 | 1509 | } |
| 1275 | 1510 | public function countOverallTracker($filter_name = '',$year = '',$month = '') { |
| 1276 | 1511 | global $globalStatsFilters; |
| 1277 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1278 | - if ($year == '') $year = date('Y'); |
|
| 1512 | + if ($filter_name == '') { |
|
| 1513 | + $filter_name = $this->filter_name; |
|
| 1514 | + } |
|
| 1515 | + if ($year == '') { |
|
| 1516 | + $year = date('Y'); |
|
| 1517 | + } |
|
| 1279 | 1518 | $all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month); |
| 1280 | 1519 | if (empty($all)) { |
| 1281 | 1520 | $filters = array('year' => $year,'month' => $month); |
@@ -1290,8 +1529,12 @@ discard block |
||
| 1290 | 1529 | } |
| 1291 | 1530 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 1292 | 1531 | global $globalStatsFilters; |
| 1293 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1294 | - if ($year == '') $year = date('Y'); |
|
| 1532 | + if ($filter_name == '') { |
|
| 1533 | + $filter_name = $this->filter_name; |
|
| 1534 | + } |
|
| 1535 | + if ($year == '') { |
|
| 1536 | + $year = date('Y'); |
|
| 1537 | + } |
|
| 1295 | 1538 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 1296 | 1539 | if (empty($all)) { |
| 1297 | 1540 | $filters = array(); |
@@ -1307,8 +1550,12 @@ discard block |
||
| 1307 | 1550 | } |
| 1308 | 1551 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 1309 | 1552 | global $globalStatsFilters; |
| 1310 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1311 | - if ($year == '') $year = date('Y'); |
|
| 1553 | + if ($filter_name == '') { |
|
| 1554 | + $filter_name = $this->filter_name; |
|
| 1555 | + } |
|
| 1556 | + if ($year == '') { |
|
| 1557 | + $year = date('Y'); |
|
| 1558 | + } |
|
| 1312 | 1559 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 1313 | 1560 | if (empty($all)) { |
| 1314 | 1561 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1327,7 +1574,9 @@ discard block |
||
| 1327 | 1574 | } |
| 1328 | 1575 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1329 | 1576 | global $globalStatsFilters; |
| 1330 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1577 | + if ($filter_name == '') { |
|
| 1578 | + $filter_name = $this->filter_name; |
|
| 1579 | + } |
|
| 1331 | 1580 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1332 | 1581 | $Spotter = new Spotter($this->db); |
| 1333 | 1582 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1345,7 +1594,9 @@ discard block |
||
| 1345 | 1594 | } |
| 1346 | 1595 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1347 | 1596 | $all = $result[0]['nb']; |
| 1348 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1597 | + } else { |
|
| 1598 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1599 | + } |
|
| 1349 | 1600 | } else { |
| 1350 | 1601 | if ($year == '' && $month == '') { |
| 1351 | 1602 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1357,7 +1608,9 @@ discard block |
||
| 1357 | 1608 | } |
| 1358 | 1609 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1359 | 1610 | $all = $result[0]['nb']; |
| 1360 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1611 | + } else { |
|
| 1612 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 1613 | + } |
|
| 1361 | 1614 | } |
| 1362 | 1615 | if (empty($all)) { |
| 1363 | 1616 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
@@ -1376,7 +1629,9 @@ discard block |
||
| 1376 | 1629 | } |
| 1377 | 1630 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 1378 | 1631 | global $globalStatsFilters; |
| 1379 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1632 | + if ($filter_name == '') { |
|
| 1633 | + $filter_name = $this->filter_name; |
|
| 1634 | + } |
|
| 1380 | 1635 | if ($year == '' && $month == '') { |
| 1381 | 1636 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 1382 | 1637 | try { |
@@ -1387,7 +1642,9 @@ discard block |
||
| 1387 | 1642 | } |
| 1388 | 1643 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1389 | 1644 | $all = $result[0]['nb_airline']; |
| 1390 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1645 | + } else { |
|
| 1646 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 1647 | + } |
|
| 1391 | 1648 | if (empty($all)) { |
| 1392 | 1649 | $filters = array(); |
| 1393 | 1650 | $filters = array('year' => $year,'month' => $month); |
@@ -1402,7 +1659,9 @@ discard block |
||
| 1402 | 1659 | } |
| 1403 | 1660 | public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') { |
| 1404 | 1661 | global $globalStatsFilters; |
| 1405 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1662 | + if ($filter_name == '') { |
|
| 1663 | + $filter_name = $this->filter_name; |
|
| 1664 | + } |
|
| 1406 | 1665 | $all = array(); |
| 1407 | 1666 | if ($year == '' && $month == '') { |
| 1408 | 1667 | $query = "SELECT SUM(cnt) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name"; |
@@ -1429,7 +1688,9 @@ discard block |
||
| 1429 | 1688 | } |
| 1430 | 1689 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 1431 | 1690 | global $globalStatsFilters; |
| 1432 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1691 | + if ($filter_name == '') { |
|
| 1692 | + $filter_name = $this->filter_name; |
|
| 1693 | + } |
|
| 1433 | 1694 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1434 | 1695 | $Spotter = new Spotter($this->db); |
| 1435 | 1696 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1484,7 +1745,9 @@ discard block |
||
| 1484 | 1745 | } |
| 1485 | 1746 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 1486 | 1747 | global $globalStatsFilters; |
| 1487 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1748 | + if ($filter_name == '') { |
|
| 1749 | + $filter_name = $this->filter_name; |
|
| 1750 | + } |
|
| 1488 | 1751 | //if ($year == '') $year = date('Y'); |
| 1489 | 1752 | if ($year == '' && $month == '') { |
| 1490 | 1753 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -1513,7 +1776,9 @@ discard block |
||
| 1513 | 1776 | } |
| 1514 | 1777 | |
| 1515 | 1778 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 1516 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1779 | + if ($filter_name == '') { |
|
| 1780 | + $filter_name = $this->filter_name; |
|
| 1781 | + } |
|
| 1517 | 1782 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1518 | 1783 | $Spotter = new Spotter($this->db); |
| 1519 | 1784 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1537,7 +1802,9 @@ discard block |
||
| 1537 | 1802 | return $all; |
| 1538 | 1803 | } |
| 1539 | 1804 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 1540 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1805 | + if ($filter_name == '') { |
|
| 1806 | + $filter_name = $this->filter_name; |
|
| 1807 | + } |
|
| 1541 | 1808 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 1542 | 1809 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1543 | 1810 | try { |
@@ -1550,7 +1817,9 @@ discard block |
||
| 1550 | 1817 | return $all; |
| 1551 | 1818 | } |
| 1552 | 1819 | public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
| 1553 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1820 | + if ($filter_name == '') { |
|
| 1821 | + $filter_name = $this->filter_name; |
|
| 1822 | + } |
|
| 1554 | 1823 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 1555 | 1824 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 1556 | 1825 | try { |
@@ -1561,7 +1830,9 @@ discard block |
||
| 1561 | 1830 | } |
| 1562 | 1831 | } |
| 1563 | 1832 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 1564 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1833 | + if ($filter_name == '') { |
|
| 1834 | + $filter_name = $this->filter_name; |
|
| 1835 | + } |
|
| 1565 | 1836 | global $globalArchiveMonths, $globalDBdriver; |
| 1566 | 1837 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1567 | 1838 | $Spotter = new Spotter($this->db); |
@@ -1617,7 +1888,9 @@ discard block |
||
| 1617 | 1888 | } |
| 1618 | 1889 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 1619 | 1890 | global $globalArchiveMonths, $globalDBdriver; |
| 1620 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1891 | + if ($filter_name == '') { |
|
| 1892 | + $filter_name = $this->filter_name; |
|
| 1893 | + } |
|
| 1621 | 1894 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1622 | 1895 | $Spotter = new Spotter($this->db); |
| 1623 | 1896 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1650,7 +1923,9 @@ discard block |
||
| 1650 | 1923 | } |
| 1651 | 1924 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 1652 | 1925 | global $globalArchiveMonths, $globalDBdriver; |
| 1653 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1926 | + if ($filter_name == '') { |
|
| 1927 | + $filter_name = $this->filter_name; |
|
| 1928 | + } |
|
| 1654 | 1929 | if (strpos($stats_airline,'alliance_') !== FALSE) { |
| 1655 | 1930 | $Spotter = new Spotter($this->db); |
| 1656 | 1931 | $airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline))); |
@@ -1681,7 +1956,9 @@ discard block |
||
| 1681 | 1956 | } |
| 1682 | 1957 | public function getStatsAirlineTotal($filter_name = '') { |
| 1683 | 1958 | global $globalArchiveMonths, $globalDBdriver; |
| 1684 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1959 | + if ($filter_name == '') { |
|
| 1960 | + $filter_name = $this->filter_name; |
|
| 1961 | + } |
|
| 1685 | 1962 | if ($globalDBdriver == 'mysql') { |
| 1686 | 1963 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 1687 | 1964 | } else { |
@@ -1698,7 +1975,9 @@ discard block |
||
| 1698 | 1975 | } |
| 1699 | 1976 | public function getStatsOwnerTotal($filter_name = '') { |
| 1700 | 1977 | global $globalArchiveMonths, $globalDBdriver; |
| 1701 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1978 | + if ($filter_name == '') { |
|
| 1979 | + $filter_name = $this->filter_name; |
|
| 1980 | + } |
|
| 1702 | 1981 | if ($globalDBdriver == 'mysql') { |
| 1703 | 1982 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1704 | 1983 | } else { |
@@ -1715,7 +1994,9 @@ discard block |
||
| 1715 | 1994 | } |
| 1716 | 1995 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1717 | 1996 | global $globalArchiveMonths, $globalDBdriver; |
| 1718 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1997 | + if ($filter_name == '') { |
|
| 1998 | + $filter_name = $this->filter_name; |
|
| 1999 | + } |
|
| 1719 | 2000 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1720 | 2001 | try { |
| 1721 | 2002 | $sth = $this->db->prepare($query); |
@@ -1724,12 +2005,17 @@ discard block |
||
| 1724 | 2005 | echo "error : ".$e->getMessage(); |
| 1725 | 2006 | } |
| 1726 | 2007 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1727 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1728 | - else return 0; |
|
| 2008 | + if (isset($all[0]['cnt'])) { |
|
| 2009 | + return $all[0]['cnt']; |
|
| 2010 | + } else { |
|
| 2011 | + return 0; |
|
| 2012 | + } |
|
| 1729 | 2013 | } |
| 1730 | 2014 | public function getStatsPilotTotal($filter_name = '') { |
| 1731 | 2015 | global $globalArchiveMonths, $globalDBdriver; |
| 1732 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2016 | + if ($filter_name == '') { |
|
| 2017 | + $filter_name = $this->filter_name; |
|
| 2018 | + } |
|
| 1733 | 2019 | if ($globalDBdriver == 'mysql') { |
| 1734 | 2020 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1735 | 2021 | } else { |
@@ -1746,7 +2032,9 @@ discard block |
||
| 1746 | 2032 | } |
| 1747 | 2033 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1748 | 2034 | global $globalArchiveMonths, $globalDBdriver; |
| 1749 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2035 | + if ($filter_name == '') { |
|
| 2036 | + $filter_name = $this->filter_name; |
|
| 2037 | + } |
|
| 1750 | 2038 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1751 | 2039 | try { |
| 1752 | 2040 | $sth = $this->db->prepare($query); |
@@ -1755,13 +2043,18 @@ discard block |
||
| 1755 | 2043 | echo "error : ".$e->getMessage(); |
| 1756 | 2044 | } |
| 1757 | 2045 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1758 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1759 | - else return 0; |
|
| 2046 | + if (isset($all[0]['cnt'])) { |
|
| 2047 | + return $all[0]['cnt']; |
|
| 2048 | + } else { |
|
| 2049 | + return 0; |
|
| 2050 | + } |
|
| 1760 | 2051 | } |
| 1761 | 2052 | |
| 1762 | 2053 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1763 | 2054 | global $globalDBdriver; |
| 1764 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2055 | + if ($filter_name == '') { |
|
| 2056 | + $filter_name = $this->filter_name; |
|
| 2057 | + } |
|
| 1765 | 2058 | if ($globalDBdriver == 'mysql') { |
| 1766 | 2059 | $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"; |
| 1767 | 2060 | } else { |
@@ -1777,7 +2070,9 @@ discard block |
||
| 1777 | 2070 | } |
| 1778 | 2071 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1779 | 2072 | global $globalDBdriver; |
| 1780 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 2073 | + if ($filter_name == '') { |
|
| 2074 | + $filter_name = $this->filter_name; |
|
| 2075 | + } |
|
| 1781 | 2076 | if ($globalDBdriver == 'mysql') { |
| 1782 | 2077 | $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"; |
| 1783 | 2078 | } else { |
@@ -2273,27 +2568,37 @@ discard block |
||
| 2273 | 2568 | date_default_timezone_set('UTC'); |
| 2274 | 2569 | if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2275 | 2570 | $last_update = $this->getLastStatsUpdate('last_update_stats_marine'); |
| 2276 | - if ($globalDebug) echo '!!! Update Marine stats !!!'."\n"; |
|
| 2571 | + if ($globalDebug) { |
|
| 2572 | + echo '!!! Update Marine stats !!!'."\n"; |
|
| 2573 | + } |
|
| 2277 | 2574 | if (isset($last_update[0]['value'])) { |
| 2278 | 2575 | $last_update_day = $last_update[0]['value']; |
| 2279 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2576 | + } else { |
|
| 2577 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2578 | + } |
|
| 2280 | 2579 | $reset = false; |
| 2281 | 2580 | $Marine = new Marine($this->db); |
| 2282 | 2581 | $filtername = 'marine'; |
| 2283 | 2582 | if ($Connection->tableExists('countries')) { |
| 2284 | - if ($globalDebug) echo 'Count all vessels by countries...'."\n"; |
|
| 2583 | + if ($globalDebug) { |
|
| 2584 | + echo 'Count all vessels by countries...'."\n"; |
|
| 2585 | + } |
|
| 2285 | 2586 | $alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day); |
| 2286 | 2587 | foreach ($alldata as $number) { |
| 2287 | 2588 | echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset); |
| 2288 | 2589 | } |
| 2289 | 2590 | } |
| 2290 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
| 2591 | + if ($globalDebug) { |
|
| 2592 | + echo 'Count all vessels by months...'."\n"; |
|
| 2593 | + } |
|
| 2291 | 2594 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2292 | 2595 | $filter_last_month = array('since_date' => $last_month); |
| 2293 | 2596 | $alldata = $Marine->countAllMonths($filter_last_month); |
| 2294 | 2597 | $lastyear = false; |
| 2295 | 2598 | foreach ($alldata as $number) { |
| 2296 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2599 | + if ($number['year_name'] != date('Y')) { |
|
| 2600 | + $lastyear = true; |
|
| 2601 | + } |
|
| 2297 | 2602 | $this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2298 | 2603 | } |
| 2299 | 2604 | echo 'Marine data...'."\n"; |
@@ -2323,7 +2628,9 @@ discard block |
||
| 2323 | 2628 | foreach ($alldata as $number) { |
| 2324 | 2629 | $this->addStatMarine('hour',$number['hour_name'],$number['hour_count']); |
| 2325 | 2630 | } |
| 2326 | - if ($globalDebug) echo 'Count all types...'."\n"; |
|
| 2631 | + if ($globalDebug) { |
|
| 2632 | + echo 'Count all types...'."\n"; |
|
| 2633 | + } |
|
| 2327 | 2634 | $alldata = $Marine->countAllMarineTypes(false,0,$last_update_day); |
| 2328 | 2635 | foreach ($alldata as $number) { |
| 2329 | 2636 | $this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset); |
@@ -2335,26 +2642,36 @@ discard block |
||
| 2335 | 2642 | } |
| 2336 | 2643 | if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2337 | 2644 | $last_update = $this->getLastStatsUpdate('last_update_stats_tracker'); |
| 2338 | - if ($globalDebug) echo '!!! Update tracker stats !!!'."\n"; |
|
| 2645 | + if ($globalDebug) { |
|
| 2646 | + echo '!!! Update tracker stats !!!'."\n"; |
|
| 2647 | + } |
|
| 2339 | 2648 | if (isset($last_update[0]['value'])) { |
| 2340 | 2649 | $last_update_day = $last_update[0]['value']; |
| 2341 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2650 | + } else { |
|
| 2651 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2652 | + } |
|
| 2342 | 2653 | $reset = false; |
| 2343 | 2654 | $Tracker = new Tracker($this->db); |
| 2344 | 2655 | if ($Connection->tableExists('countries')) { |
| 2345 | - if ($globalDebug) echo 'Count all trackers by countries...'."\n"; |
|
| 2656 | + if ($globalDebug) { |
|
| 2657 | + echo 'Count all trackers by countries...'."\n"; |
|
| 2658 | + } |
|
| 2346 | 2659 | $alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day); |
| 2347 | 2660 | foreach ($alldata as $number) { |
| 2348 | 2661 | $this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset); |
| 2349 | 2662 | } |
| 2350 | 2663 | } |
| 2351 | - if ($globalDebug) echo 'Count all vessels by months...'."\n"; |
|
| 2664 | + if ($globalDebug) { |
|
| 2665 | + echo 'Count all vessels by months...'."\n"; |
|
| 2666 | + } |
|
| 2352 | 2667 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2353 | 2668 | $filter_last_month = array('since_date' => $last_month); |
| 2354 | 2669 | $alldata = $Tracker->countAllMonths($filter_last_month); |
| 2355 | 2670 | $lastyear = false; |
| 2356 | 2671 | foreach ($alldata as $number) { |
| 2357 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2672 | + if ($number['year_name'] != date('Y')) { |
|
| 2673 | + $lastyear = true; |
|
| 2674 | + } |
|
| 2358 | 2675 | $this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 2359 | 2676 | } |
| 2360 | 2677 | echo 'Tracker data...'."\n"; |
@@ -2391,10 +2708,14 @@ discard block |
||
| 2391 | 2708 | |
| 2392 | 2709 | if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) { |
| 2393 | 2710 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 2394 | - if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n"; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo '!!! Update aicraft stats !!!'."\n"; |
|
| 2713 | + } |
|
| 2395 | 2714 | if (isset($last_update[0]['value'])) { |
| 2396 | 2715 | $last_update_day = $last_update[0]['value']; |
| 2397 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2716 | + } else { |
|
| 2717 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2718 | + } |
|
| 2398 | 2719 | $reset = false; |
| 2399 | 2720 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 2400 | 2721 | if ($globalStatsResetYear) { |
@@ -2403,43 +2724,63 @@ discard block |
||
| 2403 | 2724 | } |
| 2404 | 2725 | $Spotter = new Spotter($this->db); |
| 2405 | 2726 | |
| 2406 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 2727 | + if ($globalDebug) { |
|
| 2728 | + echo 'Count all aircraft types...'."\n"; |
|
| 2729 | + } |
|
| 2407 | 2730 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 2408 | 2731 | foreach ($alldata as $number) { |
| 2409 | 2732 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 2410 | 2733 | } |
| 2411 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 2734 | + if ($globalDebug) { |
|
| 2735 | + echo 'Count all airlines...'."\n"; |
|
| 2736 | + } |
|
| 2412 | 2737 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 2413 | 2738 | foreach ($alldata as $number) { |
| 2414 | 2739 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 2415 | 2740 | } |
| 2416 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 2741 | + if ($globalDebug) { |
|
| 2742 | + echo 'Count all registrations...'."\n"; |
|
| 2743 | + } |
|
| 2417 | 2744 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 2418 | 2745 | foreach ($alldata as $number) { |
| 2419 | 2746 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 2420 | 2747 | } |
| 2421 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 2748 | + if ($globalDebug) { |
|
| 2749 | + echo 'Count all callsigns...'."\n"; |
|
| 2750 | + } |
|
| 2422 | 2751 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 2423 | 2752 | foreach ($alldata as $number) { |
| 2424 | 2753 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2425 | 2754 | } |
| 2426 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 2755 | + if ($globalDebug) { |
|
| 2756 | + echo 'Count all owners...'."\n"; |
|
| 2757 | + } |
|
| 2427 | 2758 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 2428 | 2759 | foreach ($alldata as $number) { |
| 2429 | 2760 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 2430 | 2761 | } |
| 2431 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 2762 | + if ($globalDebug) { |
|
| 2763 | + echo 'Count all pilots...'."\n"; |
|
| 2764 | + } |
|
| 2432 | 2765 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 2433 | 2766 | foreach ($alldata as $number) { |
| 2434 | - if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
|
| 2767 | + if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') { |
|
| 2768 | + $number['pilot_id'] = $number['pilot_name']; |
|
| 2769 | + } |
|
| 2435 | 2770 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 2436 | 2771 | } |
| 2437 | 2772 | |
| 2438 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 2773 | + if ($globalDebug) { |
|
| 2774 | + echo 'Count all departure airports...'."\n"; |
|
| 2775 | + } |
|
| 2439 | 2776 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 2440 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 2777 | + if ($globalDebug) { |
|
| 2778 | + echo 'Count all detected departure airports...'."\n"; |
|
| 2779 | + } |
|
| 2441 | 2780 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 2442 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 2781 | + if ($globalDebug) { |
|
| 2782 | + echo 'Order departure airports...'."\n"; |
|
| 2783 | + } |
|
| 2443 | 2784 | $alldata = array(); |
| 2444 | 2785 | foreach ($pall as $value) { |
| 2445 | 2786 | $icao = $value['airport_departure_icao']; |
@@ -2449,7 +2790,9 @@ discard block |
||
| 2449 | 2790 | $icao = $value['airport_departure_icao']; |
| 2450 | 2791 | if (isset($alldata[$icao])) { |
| 2451 | 2792 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2452 | - } else $alldata[$icao] = $value; |
|
| 2793 | + } else { |
|
| 2794 | + $alldata[$icao] = $value; |
|
| 2795 | + } |
|
| 2453 | 2796 | } |
| 2454 | 2797 | $count = array(); |
| 2455 | 2798 | foreach ($alldata as $key => $row) { |
@@ -2459,11 +2802,17 @@ discard block |
||
| 2459 | 2802 | foreach ($alldata as $number) { |
| 2460 | 2803 | 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); |
| 2461 | 2804 | } |
| 2462 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 2805 | + if ($globalDebug) { |
|
| 2806 | + echo 'Count all arrival airports...'."\n"; |
|
| 2807 | + } |
|
| 2463 | 2808 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 2464 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 2809 | + if ($globalDebug) { |
|
| 2810 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 2811 | + } |
|
| 2465 | 2812 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 2466 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 2813 | + if ($globalDebug) { |
|
| 2814 | + echo 'Order arrival airports...'."\n"; |
|
| 2815 | + } |
|
| 2467 | 2816 | $alldata = array(); |
| 2468 | 2817 | foreach ($pall as $value) { |
| 2469 | 2818 | $icao = $value['airport_arrival_icao']; |
@@ -2473,7 +2822,9 @@ discard block |
||
| 2473 | 2822 | $icao = $value['airport_arrival_icao']; |
| 2474 | 2823 | if (isset($alldata[$icao])) { |
| 2475 | 2824 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2476 | - } else $alldata[$icao] = $value; |
|
| 2825 | + } else { |
|
| 2826 | + $alldata[$icao] = $value; |
|
| 2827 | + } |
|
| 2477 | 2828 | } |
| 2478 | 2829 | $count = array(); |
| 2479 | 2830 | foreach ($alldata as $key => $row) { |
@@ -2484,7 +2835,9 @@ discard block |
||
| 2484 | 2835 | 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); |
| 2485 | 2836 | } |
| 2486 | 2837 | if ($Connection->tableExists('countries')) { |
| 2487 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 2838 | + if ($globalDebug) { |
|
| 2839 | + echo 'Count all flights by countries...'."\n"; |
|
| 2840 | + } |
|
| 2488 | 2841 | //$SpotterArchive = new SpotterArchive(); |
| 2489 | 2842 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 2490 | 2843 | $Spotter = new Spotter($this->db); |
@@ -2495,7 +2848,9 @@ discard block |
||
| 2495 | 2848 | } |
| 2496 | 2849 | |
| 2497 | 2850 | if (isset($globalAccidents) && $globalAccidents) { |
| 2498 | - if ($globalDebug) echo 'Count fatalities stats...'."\n"; |
|
| 2851 | + if ($globalDebug) { |
|
| 2852 | + echo 'Count fatalities stats...'."\n"; |
|
| 2853 | + } |
|
| 2499 | 2854 | $Accident = new Accident($this->db); |
| 2500 | 2855 | $this->deleteStatsByType('fatalities_byyear'); |
| 2501 | 2856 | $alldata = $Accident->countFatalitiesByYear(); |
@@ -2511,48 +2866,68 @@ discard block |
||
| 2511 | 2866 | |
| 2512 | 2867 | // Add by month using getstat if month finish... |
| 2513 | 2868 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 2514 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 2869 | + if ($globalDebug) { |
|
| 2870 | + echo 'Count all flights by months...'."\n"; |
|
| 2871 | + } |
|
| 2515 | 2872 | $last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day))); |
| 2516 | 2873 | $filter_last_month = array('since_date' => $last_month); |
| 2517 | 2874 | $Spotter = new Spotter($this->db); |
| 2518 | 2875 | $alldata = $Spotter->countAllMonths($filter_last_month); |
| 2519 | 2876 | $lastyear = false; |
| 2520 | 2877 | foreach ($alldata as $number) { |
| 2521 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2878 | + if ($number['year_name'] != date('Y')) { |
|
| 2879 | + $lastyear = true; |
|
| 2880 | + } |
|
| 2522 | 2881 | $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']))); |
| 2523 | 2882 | } |
| 2524 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 2883 | + if ($globalDebug) { |
|
| 2884 | + echo 'Count all military flights by months...'."\n"; |
|
| 2885 | + } |
|
| 2525 | 2886 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
| 2526 | 2887 | foreach ($alldata as $number) { |
| 2527 | 2888 | $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']))); |
| 2528 | 2889 | } |
| 2529 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 2890 | + if ($globalDebug) { |
|
| 2891 | + echo 'Count all owners by months...'."\n"; |
|
| 2892 | + } |
|
| 2530 | 2893 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
| 2531 | 2894 | foreach ($alldata as $number) { |
| 2532 | 2895 | $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']))); |
| 2533 | 2896 | } |
| 2534 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 2897 | + if ($globalDebug) { |
|
| 2898 | + echo 'Count all pilots by months...'."\n"; |
|
| 2899 | + } |
|
| 2535 | 2900 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
| 2536 | 2901 | foreach ($alldata as $number) { |
| 2537 | 2902 | $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']))); |
| 2538 | 2903 | } |
| 2539 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 2904 | + if ($globalDebug) { |
|
| 2905 | + echo 'Count all airlines by months...'."\n"; |
|
| 2906 | + } |
|
| 2540 | 2907 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
| 2541 | 2908 | foreach ($alldata as $number) { |
| 2542 | 2909 | $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']))); |
| 2543 | 2910 | } |
| 2544 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 2911 | + if ($globalDebug) { |
|
| 2912 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 2913 | + } |
|
| 2545 | 2914 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
| 2546 | 2915 | foreach ($alldata as $number) { |
| 2547 | 2916 | $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']))); |
| 2548 | 2917 | } |
| 2549 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 2918 | + if ($globalDebug) { |
|
| 2919 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 2920 | + } |
|
| 2550 | 2921 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
| 2551 | 2922 | foreach ($alldata as $number) { |
| 2552 | 2923 | $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']))); |
| 2553 | 2924 | } |
| 2554 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 2555 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2925 | + if ($globalDebug) { |
|
| 2926 | + echo 'Airports data...'."\n"; |
|
| 2927 | + } |
|
| 2928 | + if ($globalDebug) { |
|
| 2929 | + echo '...Departure'."\n"; |
|
| 2930 | + } |
|
| 2556 | 2931 | $this->deleteStatAirport('daily'); |
| 2557 | 2932 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 2558 | 2933 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -2670,7 +3045,9 @@ discard block |
||
| 2670 | 3045 | // Count by airlines |
| 2671 | 3046 | echo '--- Stats by airlines ---'."\n"; |
| 2672 | 3047 | if ($Connection->tableExists('countries')) { |
| 2673 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 3048 | + if ($globalDebug) { |
|
| 3049 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 3050 | + } |
|
| 2674 | 3051 | $SpotterArchive = new SpotterArchive($this->db); |
| 2675 | 3052 | //$Spotter = new Spotter($this->db); |
| 2676 | 3053 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
@@ -2679,37 +3056,53 @@ discard block |
||
| 2679 | 3056 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 2680 | 3057 | } |
| 2681 | 3058 | } |
| 2682 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 3059 | + if ($globalDebug) { |
|
| 3060 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 3061 | + } |
|
| 2683 | 3062 | $Spotter = new Spotter($this->db); |
| 2684 | 3063 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 2685 | 3064 | foreach ($alldata as $number) { |
| 2686 | 3065 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 2687 | 3066 | } |
| 2688 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 3067 | + if ($globalDebug) { |
|
| 3068 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 3069 | + } |
|
| 2689 | 3070 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 2690 | 3071 | foreach ($alldata as $number) { |
| 2691 | 3072 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 2692 | 3073 | } |
| 2693 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 3074 | + if ($globalDebug) { |
|
| 3075 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 3076 | + } |
|
| 2694 | 3077 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 2695 | 3078 | foreach ($alldata as $number) { |
| 2696 | 3079 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 2697 | 3080 | } |
| 2698 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 3081 | + if ($globalDebug) { |
|
| 3082 | + echo 'Count all owners by airlines...'."\n"; |
|
| 3083 | + } |
|
| 2699 | 3084 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 2700 | 3085 | foreach ($alldata as $number) { |
| 2701 | 3086 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 2702 | 3087 | } |
| 2703 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 3088 | + if ($globalDebug) { |
|
| 3089 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 3090 | + } |
|
| 2704 | 3091 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 2705 | 3092 | foreach ($alldata as $number) { |
| 2706 | 3093 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 2707 | 3094 | } |
| 2708 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 3095 | + if ($globalDebug) { |
|
| 3096 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 3097 | + } |
|
| 2709 | 3098 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2710 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 3099 | + if ($globalDebug) { |
|
| 3100 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 3101 | + } |
|
| 2711 | 3102 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 2712 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 3103 | + if ($globalDebug) { |
|
| 3104 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 3105 | + } |
|
| 2713 | 3106 | //$alldata = array(); |
| 2714 | 3107 | foreach ($dall as $value) { |
| 2715 | 3108 | $icao = $value['airport_departure_icao']; |
@@ -2730,11 +3123,17 @@ discard block |
||
| 2730 | 3123 | foreach ($alldata as $number) { |
| 2731 | 3124 | 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); |
| 2732 | 3125 | } |
| 2733 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 3126 | + if ($globalDebug) { |
|
| 3127 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 3128 | + } |
|
| 2734 | 3129 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2735 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 3130 | + if ($globalDebug) { |
|
| 3131 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 3132 | + } |
|
| 2736 | 3133 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 2737 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 3134 | + if ($globalDebug) { |
|
| 3135 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 3136 | + } |
|
| 2738 | 3137 | //$alldata = array(); |
| 2739 | 3138 | foreach ($dall as $value) { |
| 2740 | 3139 | $icao = $value['airport_arrival_icao']; |
@@ -2753,37 +3152,53 @@ discard block |
||
| 2753 | 3152 | } |
| 2754 | 3153 | $alldata = $pall; |
| 2755 | 3154 | foreach ($alldata as $number) { |
| 2756 | - 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); |
|
| 3155 | + if ($number['airline_icao'] != '') { |
|
| 3156 | + 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); |
|
| 3157 | + } |
|
| 3158 | + } |
|
| 3159 | + if ($globalDebug) { |
|
| 3160 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 2757 | 3161 | } |
| 2758 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 2759 | 3162 | $Spotter = new Spotter($this->db); |
| 2760 | 3163 | $alldata = $Spotter->countAllMonthsByAirlines($filter_last_month); |
| 2761 | 3164 | $lastyear = false; |
| 2762 | 3165 | foreach ($alldata as $number) { |
| 2763 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 3166 | + if ($number['year_name'] != date('Y')) { |
|
| 3167 | + $lastyear = true; |
|
| 3168 | + } |
|
| 2764 | 3169 | $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']); |
| 2765 | 3170 | } |
| 2766 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 3171 | + if ($globalDebug) { |
|
| 3172 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 3173 | + } |
|
| 2767 | 3174 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
| 2768 | 3175 | foreach ($alldata as $number) { |
| 2769 | 3176 | $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']); |
| 2770 | 3177 | } |
| 2771 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 3178 | + if ($globalDebug) { |
|
| 3179 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 3180 | + } |
|
| 2772 | 3181 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
| 2773 | 3182 | foreach ($alldata as $number) { |
| 2774 | 3183 | $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']); |
| 2775 | 3184 | } |
| 2776 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 3185 | + if ($globalDebug) { |
|
| 3186 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 3187 | + } |
|
| 2777 | 3188 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
| 2778 | 3189 | foreach ($alldata as $number) { |
| 2779 | 3190 | $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']); |
| 2780 | 3191 | } |
| 2781 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 3192 | + if ($globalDebug) { |
|
| 3193 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 3194 | + } |
|
| 2782 | 3195 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
| 2783 | 3196 | foreach ($alldata as $number) { |
| 2784 | 3197 | $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']); |
| 2785 | 3198 | } |
| 2786 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 3199 | + if ($globalDebug) { |
|
| 3200 | + echo '...Departure'."\n"; |
|
| 3201 | + } |
|
| 2787 | 3202 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 2788 | 3203 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 2789 | 3204 | foreach ($dall as $value) { |
@@ -2806,7 +3221,9 @@ discard block |
||
| 2806 | 3221 | foreach ($alldata as $number) { |
| 2807 | 3222 | $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']); |
| 2808 | 3223 | } |
| 2809 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 3224 | + if ($globalDebug) { |
|
| 3225 | + echo '...Arrival'."\n"; |
|
| 3226 | + } |
|
| 2810 | 3227 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 2811 | 3228 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 2812 | 3229 | foreach ($dall as $value) { |
@@ -2830,13 +3247,19 @@ discard block |
||
| 2830 | 3247 | $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']); |
| 2831 | 3248 | } |
| 2832 | 3249 | |
| 2833 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 2834 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 3250 | + if ($globalDebug) { |
|
| 3251 | + echo 'Flights data...'."\n"; |
|
| 3252 | + } |
|
| 3253 | + if ($globalDebug) { |
|
| 3254 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 3255 | + } |
|
| 2835 | 3256 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
| 2836 | 3257 | foreach ($alldata as $number) { |
| 2837 | 3258 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 2838 | 3259 | } |
| 2839 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 3260 | + if ($globalDebug) { |
|
| 3261 | + echo '-> countAllDates...'."\n"; |
|
| 3262 | + } |
|
| 2840 | 3263 | //$previousdata = $this->countAllDatesByAirlines(); |
| 2841 | 3264 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
| 2842 | 3265 | $values = array(); |
@@ -2849,14 +3272,18 @@ discard block |
||
| 2849 | 3272 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 2850 | 3273 | } |
| 2851 | 3274 | |
| 2852 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 3275 | + if ($globalDebug) { |
|
| 3276 | + echo '-> countAllHours...'."\n"; |
|
| 3277 | + } |
|
| 2853 | 3278 | $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
| 2854 | 3279 | foreach ($alldata as $number) { |
| 2855 | 3280 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
| 2856 | 3281 | } |
| 2857 | 3282 | |
| 2858 | 3283 | // Stats by filters |
| 2859 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 3284 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 3285 | + $globalStatsFilters = array(); |
|
| 3286 | + } |
|
| 2860 | 3287 | foreach ($globalStatsFilters as $name => $filter) { |
| 2861 | 3288 | if (!empty($filter)) { |
| 2862 | 3289 | //$filter_name = $filter['name']; |
@@ -2864,7 +3291,9 @@ discard block |
||
| 2864 | 3291 | $reset = false; |
| 2865 | 3292 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 2866 | 3293 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 2867 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 3294 | + if ($globalDebug) { |
|
| 3295 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 3296 | + } |
|
| 2868 | 3297 | $this->deleteOldStats($filter_name); |
| 2869 | 3298 | unset($last_update); |
| 2870 | 3299 | } |
@@ -2881,39 +3310,55 @@ discard block |
||
| 2881 | 3310 | $reset = true; |
| 2882 | 3311 | } |
| 2883 | 3312 | // Count by filter |
| 2884 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 3313 | + if ($globalDebug) { |
|
| 3314 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 3315 | + } |
|
| 2885 | 3316 | $Spotter = new Spotter($this->db); |
| 2886 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 3317 | + if ($globalDebug) { |
|
| 3318 | + echo 'Count all aircraft types...'."\n"; |
|
| 3319 | + } |
|
| 2887 | 3320 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 2888 | 3321 | foreach ($alldata as $number) { |
| 2889 | 3322 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
| 2890 | 3323 | } |
| 2891 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 3324 | + if ($globalDebug) { |
|
| 3325 | + echo 'Count all airlines...'."\n"; |
|
| 3326 | + } |
|
| 2892 | 3327 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
| 2893 | 3328 | foreach ($alldata as $number) { |
| 2894 | 3329 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
| 2895 | 3330 | } |
| 2896 | - if ($globalDebug) echo 'Count all aircraft registrations...'."\n"; |
|
| 3331 | + if ($globalDebug) { |
|
| 3332 | + echo 'Count all aircraft registrations...'."\n"; |
|
| 3333 | + } |
|
| 2897 | 3334 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
| 2898 | 3335 | foreach ($alldata as $number) { |
| 2899 | 3336 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
| 2900 | 3337 | } |
| 2901 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 3338 | + if ($globalDebug) { |
|
| 3339 | + echo 'Count all callsigns...'."\n"; |
|
| 3340 | + } |
|
| 2902 | 3341 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
| 2903 | 3342 | foreach ($alldata as $number) { |
| 2904 | 3343 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
| 2905 | 3344 | } |
| 2906 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 3345 | + if ($globalDebug) { |
|
| 3346 | + echo 'Count all owners...'."\n"; |
|
| 3347 | + } |
|
| 2907 | 3348 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
| 2908 | 3349 | foreach ($alldata as $number) { |
| 2909 | 3350 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
| 2910 | 3351 | } |
| 2911 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 3352 | + if ($globalDebug) { |
|
| 3353 | + echo 'Count all pilots...'."\n"; |
|
| 3354 | + } |
|
| 2912 | 3355 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
| 2913 | 3356 | foreach ($alldata as $number) { |
| 2914 | 3357 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
| 2915 | 3358 | } |
| 2916 | - if ($globalDebug) echo 'Count departure airports...'."\n"; |
|
| 3359 | + if ($globalDebug) { |
|
| 3360 | + echo 'Count departure airports...'."\n"; |
|
| 3361 | + } |
|
| 2917 | 3362 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
| 2918 | 3363 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
| 2919 | 3364 | $alldata = array(); |
@@ -2925,7 +3370,9 @@ discard block |
||
| 2925 | 3370 | $icao = $value['airport_departure_icao']; |
| 2926 | 3371 | if (isset($alldata[$icao])) { |
| 2927 | 3372 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 2928 | - } else $alldata[$icao] = $value; |
|
| 3373 | + } else { |
|
| 3374 | + $alldata[$icao] = $value; |
|
| 3375 | + } |
|
| 2929 | 3376 | } |
| 2930 | 3377 | $count = array(); |
| 2931 | 3378 | foreach ($alldata as $key => $row) { |
@@ -2935,7 +3382,9 @@ discard block |
||
| 2935 | 3382 | foreach ($alldata as $number) { |
| 2936 | 3383 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
| 2937 | 3384 | } |
| 2938 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 3385 | + if ($globalDebug) { |
|
| 3386 | + echo 'Count all arrival airports...'."\n"; |
|
| 3387 | + } |
|
| 2939 | 3388 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2940 | 3389 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
| 2941 | 3390 | $alldata = array(); |
@@ -2947,7 +3396,9 @@ discard block |
||
| 2947 | 3396 | $icao = $value['airport_arrival_icao']; |
| 2948 | 3397 | if (isset($alldata[$icao])) { |
| 2949 | 3398 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 2950 | - } else $alldata[$icao] = $value; |
|
| 3399 | + } else { |
|
| 3400 | + $alldata[$icao] = $value; |
|
| 3401 | + } |
|
| 2951 | 3402 | } |
| 2952 | 3403 | $count = array(); |
| 2953 | 3404 | foreach ($alldata as $key => $row) { |
@@ -2957,35 +3408,49 @@ discard block |
||
| 2957 | 3408 | foreach ($alldata as $number) { |
| 2958 | 3409 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
| 2959 | 3410 | } |
| 2960 | - if ($globalDebug) echo 'Count all months...'."\n"; |
|
| 3411 | + if ($globalDebug) { |
|
| 3412 | + echo 'Count all months...'."\n"; |
|
| 3413 | + } |
|
| 2961 | 3414 | $Spotter = new Spotter($this->db); |
| 2962 | 3415 | $alldata = $Spotter->countAllMonths($filter); |
| 2963 | 3416 | $lastyear = false; |
| 2964 | 3417 | foreach ($alldata as $number) { |
| 2965 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 3418 | + if ($number['year_name'] != date('Y')) { |
|
| 3419 | + $lastyear = true; |
|
| 3420 | + } |
|
| 2966 | 3421 | $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); |
| 2967 | 3422 | } |
| 2968 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 3423 | + if ($globalDebug) { |
|
| 3424 | + echo 'Count all owners by months...'."\n"; |
|
| 3425 | + } |
|
| 2969 | 3426 | $alldata = $Spotter->countAllMonthsOwners($filter); |
| 2970 | 3427 | foreach ($alldata as $number) { |
| 2971 | 3428 | $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'])),'',$filter_name); |
| 2972 | 3429 | } |
| 2973 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 3430 | + if ($globalDebug) { |
|
| 3431 | + echo 'Count all pilots by months...'."\n"; |
|
| 3432 | + } |
|
| 2974 | 3433 | $alldata = $Spotter->countAllMonthsPilots($filter); |
| 2975 | 3434 | foreach ($alldata as $number) { |
| 2976 | 3435 | $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'])),'',$filter_name); |
| 2977 | 3436 | } |
| 2978 | - if ($globalDebug) echo 'Count all military by months...'."\n"; |
|
| 3437 | + if ($globalDebug) { |
|
| 3438 | + echo 'Count all military by months...'."\n"; |
|
| 3439 | + } |
|
| 2979 | 3440 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
| 2980 | 3441 | foreach ($alldata as $number) { |
| 2981 | 3442 | $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'])),'',$filter_name); |
| 2982 | 3443 | } |
| 2983 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 3444 | + if ($globalDebug) { |
|
| 3445 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 3446 | + } |
|
| 2984 | 3447 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
| 2985 | 3448 | foreach ($alldata as $number) { |
| 2986 | 3449 | $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'])),'',$filter_name); |
| 2987 | 3450 | } |
| 2988 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 3451 | + if ($globalDebug) { |
|
| 3452 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 3453 | + } |
|
| 2989 | 3454 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
| 2990 | 3455 | foreach ($alldata as $number) { |
| 2991 | 3456 | $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'])),'',$filter_name); |