@@ -6,11 +6,15 @@ discard block |
||
| 6 | 6 | $beginpage = microtime(true); |
| 7 | 7 | $Stats = new Stats(); |
| 8 | 8 | |
| 9 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 9 | +if (!isset($filter_name)) { |
|
| 10 | + $filter_name = ''; |
|
| 11 | +} |
|
| 10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 11 | 13 | if ($airline_icao == '' && isset($globalFilter)) { |
| 12 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 13 | -} |
|
| 14 | + if (isset($globalFilter['airline'])) { |
|
| 15 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 16 | + } |
|
| 17 | + } |
|
| 14 | 18 | if ($airline_icao != '' && $airline_icao != 'all') { |
| 15 | 19 | $Spotter = new Spotter(); |
| 16 | 20 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -36,14 +40,21 @@ discard block |
||
| 36 | 40 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script> |
| 37 | 41 | <div class="column"> |
| 38 | 42 | <div class="info"> |
| 39 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
| 43 | + <h1><?php if (isset($airline_name)) { |
|
| 44 | + echo _("Statistics for ").$airline_name; |
|
| 45 | +} else { |
|
| 46 | + echo _("Statistics"); |
|
| 47 | +} |
|
| 48 | +?></h1> |
|
| 40 | 49 | <?php |
| 41 | 50 | $last_update = $Stats->getLastStatsUpdate(); |
| 42 | 51 | //if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->'; |
| 43 | 52 | if (isset($last_update[0]['value'])) { |
| 44 | 53 | date_default_timezone_set('UTC'); |
| 45 | 54 | $lastupdate = strtotime($last_update[0]['value']); |
| 46 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
| 55 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
| 56 | + date_default_timezone_set($globalTimezone); |
|
| 57 | + } |
|
| 47 | 58 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
| 48 | 59 | } |
| 49 | 60 | ?> |
@@ -95,8 +106,9 @@ discard block |
||
| 95 | 106 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
| 96 | 107 | <?php |
| 97 | 108 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
| 98 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
| 99 | - else { |
|
| 109 | + if (count($aircraft_array) == 0) { |
|
| 110 | + print _("No data available"); |
|
| 111 | + } else { |
|
| 100 | 112 | |
| 101 | 113 | print '<div id="chart1" class="chart" width="100%"></div> |
| 102 | 114 | <script> |
@@ -206,8 +218,9 @@ discard block |
||
| 206 | 218 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
| 207 | 219 | <?php |
| 208 | 220 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
| 209 | - if (count($pilot_array) == 0) print _("No data available"); |
|
| 210 | - else { |
|
| 221 | + if (count($pilot_array) == 0) { |
|
| 222 | + print _("No data available"); |
|
| 223 | + } else { |
|
| 211 | 224 | print '<div id="chart7" class="chart" width="100%"></div> |
| 212 | 225 | <script> |
| 213 | 226 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -252,8 +265,9 @@ discard block |
||
| 252 | 265 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
| 253 | 266 | <?php |
| 254 | 267 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
| 255 | - if (count($owner_array) == 0) print _("No data available"); |
|
| 256 | - else { |
|
| 268 | + if (count($owner_array) == 0) { |
|
| 269 | + print _("No data available"); |
|
| 270 | + } else { |
|
| 257 | 271 | print '<div id="chart7" class="chart" width="100%"></div> |
| 258 | 272 | <script> |
| 259 | 273 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -299,8 +313,9 @@ discard block |
||
| 299 | 313 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
| 300 | 314 | <?php |
| 301 | 315 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
| 302 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 303 | - else { |
|
| 316 | + if (count($flightover_array) == 0) { |
|
| 317 | + print _("No data available"); |
|
| 318 | + } else { |
|
| 304 | 319 | print '<div id="chart10" class="chart" width="100%"></div> |
| 305 | 320 | <script> |
| 306 | 321 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -446,8 +461,9 @@ discard block |
||
| 446 | 461 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 447 | 462 | <?php |
| 448 | 463 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
| 449 | - if (count($year_array) == 0) print _("No data available"); |
|
| 450 | - else { |
|
| 464 | + if (count($year_array) == 0) { |
|
| 465 | + print _("No data available"); |
|
| 466 | + } else { |
|
| 451 | 467 | print '<div id="chart8" class="chart" width="100%"></div> |
| 452 | 468 | <script> |
| 453 | 469 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -491,8 +507,9 @@ discard block |
||
| 491 | 507 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 492 | 508 | <?php |
| 493 | 509 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
| 494 | - if (count($month_array) == 0) print _("No data available"); |
|
| 495 | - else { |
|
| 510 | + if (count($month_array) == 0) { |
|
| 511 | + print _("No data available"); |
|
| 512 | + } else { |
|
| 496 | 513 | print '<div id="chart9" class="chart" width="100%"></div> |
| 497 | 514 | <script> |
| 498 | 515 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -537,8 +554,9 @@ discard block |
||
| 537 | 554 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 538 | 555 | <?php |
| 539 | 556 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
| 540 | - if (empty($date_array)) print _("No data available"); |
|
| 541 | - else { |
|
| 557 | + if (empty($date_array)) { |
|
| 558 | + print _("No data available"); |
|
| 559 | + } else { |
|
| 542 | 560 | print '<div id="chart5" class="chart" width="100%"></div> |
| 543 | 561 | <script> |
| 544 | 562 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -583,8 +601,9 @@ discard block |
||
| 583 | 601 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 584 | 602 | <?php |
| 585 | 603 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
| 586 | - if (empty($hour_array)) print _("No data available"); |
|
| 587 | - else { |
|
| 604 | + if (empty($hour_array)) { |
|
| 605 | + print _("No data available"); |
|
| 606 | + } else { |
|
| 588 | 607 | |
| 589 | 608 | print '<div id="chart6" class="chart" width="100%"></div> |
| 590 | 609 | <script> |
@@ -640,8 +659,9 @@ discard block |
||
| 640 | 659 | require_once('require/class.Accident.php'); |
| 641 | 660 | $Accident = new Accident(); |
| 642 | 661 | $year_array = $Accident->countFatalitiesByYear($filter_name); |
| 643 | - if (count($year_array) == 0) print _("No data available"); |
|
| 644 | - else { |
|
| 662 | + if (count($year_array) == 0) { |
|
| 663 | + print _("No data available"); |
|
| 664 | + } else { |
|
| 645 | 665 | print '<div id="chart32" class="chart" width="100%"></div> |
| 646 | 666 | <script> |
| 647 | 667 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -689,8 +709,9 @@ discard block |
||
| 689 | 709 | require_once('require/class.Accident.php'); |
| 690 | 710 | $Accident = new Accident(); |
| 691 | 711 | $year_array = $Accident->countFatalitiesLast12Months($filter_name); |
| 692 | - if (count($year_array) == 0) print _("No data available"); |
|
| 693 | - else { |
|
| 712 | + if (count($year_array) == 0) { |
|
| 713 | + print _("No data available"); |
|
| 714 | + } else { |
|
| 694 | 715 | print '<div id="chart33" class="chart" width="100%"></div> |
| 695 | 716 | <script> |
| 696 | 717 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -766,8 +787,11 @@ discard block |
||
| 766 | 787 | $distance = $distance; |
| 767 | 788 | $unit = 'km'; |
| 768 | 789 | } |
| 769 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 770 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 790 | + if (!isset($polar_data)) { |
|
| 791 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 792 | + } else { |
|
| 793 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 794 | + } |
|
| 771 | 795 | } |
| 772 | 796 | ?> |
| 773 | 797 | <div class="col-md-6"> |
@@ -819,8 +843,11 @@ discard block |
||
| 819 | 843 | foreach ($msg as $eachmsg) { |
| 820 | 844 | //$eachmsg = $msg[0]; |
| 821 | 845 | $data = $eachmsg['source_data']; |
| 822 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
| 823 | - else $max = 500; |
|
| 846 | + if ($data > 500) { |
|
| 847 | + $max = (round(($data+100)/100))*100; |
|
| 848 | + } else { |
|
| 849 | + $max = 500; |
|
| 850 | + } |
|
| 824 | 851 | ?> |
| 825 | 852 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
| 826 | 853 | <script> |
@@ -59,8 +59,11 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 61 | 61 | $sth->closeCursor(); |
| 62 | - if ($row['nb'] > 0) return false; |
|
| 63 | - else return true; |
|
| 62 | + if ($row['nb'] > 0) { |
|
| 63 | + return false; |
|
| 64 | + } else { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | public static function insert_last_update() { |
@@ -84,9 +87,14 @@ discard block |
||
| 84 | 87 | //$pieces = explode(' ',$data); |
| 85 | 88 | $pieces = preg_split('/\s/',$data); |
| 86 | 89 | $pos = 0; |
| 87 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
| 89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 90 | + if ($pieces[0] == 'METAR') { |
|
| 91 | + $pos++; |
|
| 92 | + } elseif ($pieces[0] == 'SPECI') { |
|
| 93 | + $pos++; |
|
| 94 | + } |
|
| 95 | + if (strlen($pieces[$pos]) != 4) { |
|
| 96 | + $pos++; |
|
| 97 | + } |
|
| 90 | 98 | $result = array(); |
| 91 | 99 | $result['location'] = $pieces[$pos]; |
| 92 | 100 | $pos++; |
@@ -95,16 +103,26 @@ discard block |
||
| 95 | 103 | $c = count($pieces); |
| 96 | 104 | for($pos++; $pos < $c; $pos++) { |
| 97 | 105 | $piece = $pieces[$pos]; |
| 98 | - if ($piece == 'RMK') break; |
|
| 99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 100 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 106 | + if ($piece == 'RMK') { |
|
| 107 | + break; |
|
| 108 | + } |
|
| 109 | + if ($piece == 'AUTO') { |
|
| 110 | + $result['auto'] = true; |
|
| 111 | + } |
|
| 112 | + if ($piece == 'COR') { |
|
| 113 | + $result['correction'] = true; |
|
| 114 | + } |
|
| 101 | 115 | // Wind Speed |
| 102 | 116 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 103 | 117 | $result['wind']['direction'] = (float)$matches[1]; |
| 104 | 118 | $result['wind']['unit'] = $matches[4]; |
| 105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 119 | + if ($result['wind']['unit'] == 'KT') { |
|
| 120 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 121 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 122 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 123 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 124 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 125 | + } |
|
| 108 | 126 | $result['wind']['gust'] = (float)$matches[3]; |
| 109 | 127 | $result['wind']['unit'] = $matches[4]; |
| 110 | 128 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +204,23 @@ discard block |
||
| 186 | 204 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 187 | 205 | $type = $matches[1]; |
| 188 | 206 | $cloud = array(); |
| 189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 207 | + if ($type == 'SKC') { |
|
| 208 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 209 | + } elseif ($type == 'CLR') { |
|
| 210 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 211 | + } elseif ($type == 'NSC') { |
|
| 212 | + $cloud['type'] = 'No significant cloud'; |
|
| 213 | + } elseif ($type == 'FEW') { |
|
| 214 | + $cloud['type'] = 'Few'; |
|
| 215 | + } elseif ($type == 'SCT') { |
|
| 216 | + $cloud['type'] = 'Scattered'; |
|
| 217 | + } elseif ($type == 'BKN') { |
|
| 218 | + $cloud['type'] = 'Broken'; |
|
| 219 | + } elseif ($type == 'OVC') { |
|
| 220 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 221 | + } elseif ($type == 'VV') { |
|
| 222 | + $cloud['type'] = 'Vertical visibility'; |
|
| 223 | + } |
|
| 197 | 224 | $cloud['type_code'] = $type; |
| 198 | 225 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 199 | 226 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -223,8 +250,11 @@ discard block |
||
| 223 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 224 | 251 | //echo $piece; |
| 225 | 252 | //print_r($matches); |
| 226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 253 | + if (isset($matches[5])) { |
|
| 254 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 255 | + } else { |
|
| 256 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 257 | + } |
|
| 228 | 258 | if (isset($matches[3])) { |
| 229 | 259 | $range = Array( |
| 230 | 260 | 'from' => (float)$matches[2], |
@@ -257,8 +287,11 @@ discard block |
||
| 257 | 287 | if (isset($matches[3])) { |
| 258 | 288 | $text[] = $this->texts[$matches[3]]; |
| 259 | 289 | } |
| 260 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 261 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 290 | + if (!isset($result['weather'])) { |
|
| 291 | + $result['weather'] = implode(' ', $text); |
|
| 292 | + } else { |
|
| 293 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 294 | + } |
|
| 262 | 295 | } |
| 263 | 296 | } |
| 264 | 297 | return $result; |
@@ -270,8 +303,11 @@ discard block |
||
| 270 | 303 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 271 | 304 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 272 | 305 | } else { |
| 273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 306 | + if ($globalDBdriver == 'mysql') { |
|
| 307 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 308 | + } else { |
|
| 309 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 310 | + } |
|
| 275 | 311 | } |
| 276 | 312 | $query_values = array(':icao' => $icao); |
| 277 | 313 | try { |
@@ -326,7 +362,9 @@ discard block |
||
| 326 | 362 | |
| 327 | 363 | public function addMETARCycle() { |
| 328 | 364 | global $globalDebug, $globalIVAO, $globalTransaction; |
| 329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 365 | + if (isset($globalDebug) && $globalDebug) { |
|
| 366 | + echo "Downloading METAR cycle..."; |
|
| 367 | + } |
|
| 330 | 368 | date_default_timezone_set("UTC"); |
| 331 | 369 | $Common = new Common(); |
| 332 | 370 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -339,33 +377,49 @@ discard block |
||
| 339 | 377 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
| 340 | 378 | } |
| 341 | 379 | if ($handle) { |
| 342 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 380 | + if (isset($globalDebug) && $globalDebug) { |
|
| 381 | + echo "Done - Updating DB..."; |
|
| 382 | + } |
|
| 343 | 383 | $date = ''; |
| 344 | 384 | //foreach(explode("\n",$cycle) as $line) { |
| 345 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 385 | + if ($globalTransaction) { |
|
| 386 | + $this->db->beginTransaction(); |
|
| 387 | + } |
|
| 346 | 388 | while(($line = fgets($handle,4096)) !== false) { |
| 347 | 389 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
| 348 | 390 | $date = $line; |
| 349 | 391 | } elseif ($line != '') { |
| 350 | 392 | //$this->parse($line); |
| 351 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 393 | + if ($date == '') { |
|
| 394 | + $date = date('Y/m/d H:m'); |
|
| 395 | + } |
|
| 352 | 396 | $pos = 0; |
| 353 | 397 | $pieces = preg_split('/\s/',$line); |
| 354 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 355 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 398 | + if ($pieces[0] == 'METAR') { |
|
| 399 | + $pos++; |
|
| 400 | + } |
|
| 401 | + if (strlen($pieces[$pos]) != 4) { |
|
| 402 | + $pos++; |
|
| 403 | + } |
|
| 356 | 404 | $location = $pieces[$pos]; |
| 357 | 405 | echo $this->addMETAR($location,$line,$date); |
| 358 | 406 | } |
| 359 | 407 | } |
| 360 | 408 | fclose($handle); |
| 361 | - if ($globalTransaction) $this->db->commit(); |
|
| 409 | + if ($globalTransaction) { |
|
| 410 | + $this->db->commit(); |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + if (isset($globalDebug) && $globalDebug) { |
|
| 414 | + echo "Done\n"; |
|
| 362 | 415 | } |
| 363 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 364 | 416 | |
| 365 | 417 | } |
| 366 | 418 | public function downloadMETAR($icao) { |
| 367 | 419 | global $globalMETARurl; |
| 368 | - if ($globalMETARurl == '') return array(); |
|
| 420 | + if ($globalMETARurl == '') { |
|
| 421 | + return array(); |
|
| 422 | + } |
|
| 369 | 423 | date_default_timezone_set("UTC"); |
| 370 | 424 | $Common = new Common(); |
| 371 | 425 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -379,16 +433,24 @@ discard block |
||
| 379 | 433 | if ($line != '') { |
| 380 | 434 | //$this->parse($line); |
| 381 | 435 | //echo $line; |
| 382 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 436 | + if ($date == '') { |
|
| 437 | + $date = date('Y/m/d H:m'); |
|
| 438 | + } |
|
| 383 | 439 | $pos = 0; |
| 384 | 440 | $pieces = preg_split('/\s/',$line); |
| 385 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 386 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 441 | + if ($pieces[0] == 'METAR') { |
|
| 442 | + $pos++; |
|
| 443 | + } |
|
| 444 | + if (strlen($pieces[$pos]) != 4) { |
|
| 445 | + $pos++; |
|
| 446 | + } |
|
| 387 | 447 | $location = $pieces[$pos]; |
| 388 | 448 | if (strlen($location == 4)) { |
| 389 | 449 | $this->addMETAR($location,$line,$date); |
| 390 | 450 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 391 | - } else return array(); |
|
| 451 | + } else { |
|
| 452 | + return array(); |
|
| 453 | + } |
|
| 392 | 454 | } |
| 393 | 455 | //echo $line."\n"; |
| 394 | 456 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 26 | + if (is_array($globalFilter)) { |
|
| 27 | + $filter = array_merge($filter,$globalFilter); |
|
| 28 | + } |
|
| 27 | 29 | $filter_query_join = ''; |
| 28 | 30 | $filter_query_where = ''; |
| 29 | 31 | foreach($filters as $flt) { |
@@ -74,8 +76,11 @@ discard block |
||
| 74 | 76 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 75 | 77 | } |
| 76 | 78 | } |
| 77 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 78 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 79 | + if ($filter_query_where == '' && $where) { |
|
| 80 | + $filter_query_where = ' WHERE'; |
|
| 81 | + } elseif ($filter_query_where != '' && $and) { |
|
| 82 | + $filter_query_where .= ' AND'; |
|
| 83 | + } |
|
| 79 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 80 | 85 | return $filter_query; |
| 81 | 86 | } |
@@ -86,10 +91,17 @@ discard block |
||
| 86 | 91 | if ($over_country == '') { |
| 87 | 92 | $Spotter = new Spotter($this->db); |
| 88 | 93 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 89 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 90 | - else $country = ''; |
|
| 91 | - } else $country = $over_country; |
|
| 92 | - if ($airline_type === NULL) $airline_type =''; |
|
| 94 | + if (!empty($data_country)) { |
|
| 95 | + $country = $data_country['iso2']; |
|
| 96 | + } else { |
|
| 97 | + $country = ''; |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $country = $over_country; |
|
| 101 | + } |
|
| 102 | + if ($airline_type === NULL) { |
|
| 103 | + $airline_type =''; |
|
| 104 | + } |
|
| 93 | 105 | |
| 94 | 106 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 95 | 107 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -592,7 +604,9 @@ discard block |
||
| 592 | 604 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 593 | 605 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 594 | 606 | $translate = $Translation->ident2icao($q_item); |
| 595 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 607 | + if ($translate != $q_item) { |
|
| 608 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 609 | + } |
|
| 596 | 610 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 597 | 611 | $additional_query .= ")"; |
| 598 | 612 | } |
@@ -810,7 +824,9 @@ discard block |
||
| 810 | 824 | date_default_timezone_set($globalTimezone); |
| 811 | 825 | $datetime = new DateTime(); |
| 812 | 826 | $offset = $datetime->format('P'); |
| 813 | - } else $offset = '+00:00'; |
|
| 827 | + } else { |
|
| 828 | + $offset = '+00:00'; |
|
| 829 | + } |
|
| 814 | 830 | |
| 815 | 831 | |
| 816 | 832 | if ($date_array[1] != "") |
@@ -1084,9 +1100,13 @@ discard block |
||
| 1084 | 1100 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1085 | 1101 | } |
| 1086 | 1102 | } |
| 1087 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1103 | + if ($sincedate != '') { |
|
| 1104 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1105 | + } |
|
| 1088 | 1106 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1089 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1107 | + if ($limit) { |
|
| 1108 | + $query .= " LIMIT 0,10"; |
|
| 1109 | + } |
|
| 1090 | 1110 | |
| 1091 | 1111 | |
| 1092 | 1112 | $sth = $this->db->prepare($query); |
@@ -1130,9 +1150,13 @@ discard block |
||
| 1130 | 1150 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1131 | 1151 | } |
| 1132 | 1152 | } |
| 1133 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1153 | + if ($sincedate != '') { |
|
| 1154 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1155 | + } |
|
| 1134 | 1156 | $query .= "GROUP BY s.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1135 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1157 | + if ($limit) { |
|
| 1158 | + $query .= " LIMIT 0,10"; |
|
| 1159 | + } |
|
| 1136 | 1160 | |
| 1137 | 1161 | |
| 1138 | 1162 | $sth = $this->db->prepare($query); |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | global $globalFilterName; |
| 15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 15 | + if (isset($globalFilterName)) { |
|
| 16 | + $this->filter_name = $globalFilterName; |
|
| 17 | + } |
|
| 16 | 18 | $Connection = new Connection($dbc); |
| 17 | 19 | $this->db = $Connection->db(); |
| 18 | 20 | } |
@@ -77,7 +79,9 @@ discard block |
||
| 77 | 79 | } |
| 78 | 80 | } |
| 79 | 81 | public function getAllAirlineNames($filter_name = '') { |
| 80 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 82 | + if ($filter_name == '') { |
|
| 83 | + $filter_name = $this->filter_name; |
|
| 84 | + } |
|
| 81 | 85 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 82 | 86 | try { |
| 83 | 87 | $sth = $this->db->prepare($query); |
@@ -89,7 +93,9 @@ discard block |
||
| 89 | 93 | return $all; |
| 90 | 94 | } |
| 91 | 95 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 92 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 96 | + if ($filter_name == '') { |
|
| 97 | + $filter_name = $this->filter_name; |
|
| 98 | + } |
|
| 93 | 99 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 94 | 100 | try { |
| 95 | 101 | $sth = $this->db->prepare($query); |
@@ -101,7 +107,9 @@ discard block |
||
| 101 | 107 | return $all; |
| 102 | 108 | } |
| 103 | 109 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 104 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 110 | + if ($filter_name == '') { |
|
| 111 | + $filter_name = $this->filter_name; |
|
| 112 | + } |
|
| 105 | 113 | $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"; |
| 106 | 114 | try { |
| 107 | 115 | $sth = $this->db->prepare($query); |
@@ -113,7 +121,9 @@ discard block |
||
| 113 | 121 | return $all; |
| 114 | 122 | } |
| 115 | 123 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 116 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 124 | + if ($filter_name == '') { |
|
| 125 | + $filter_name = $this->filter_name; |
|
| 126 | + } |
|
| 117 | 127 | $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"; |
| 118 | 128 | try { |
| 119 | 129 | $sth = $this->db->prepare($query); |
@@ -126,7 +136,9 @@ discard block |
||
| 126 | 136 | } |
| 127 | 137 | |
| 128 | 138 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 129 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 139 | + if ($filter_name == '') { |
|
| 140 | + $filter_name = $this->filter_name; |
|
| 141 | + } |
|
| 130 | 142 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 131 | 143 | try { |
| 132 | 144 | $sth = $this->db->prepare($query); |
@@ -139,7 +151,9 @@ discard block |
||
| 139 | 151 | } |
| 140 | 152 | |
| 141 | 153 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 142 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 154 | + if ($filter_name == '') { |
|
| 155 | + $filter_name = $this->filter_name; |
|
| 156 | + } |
|
| 143 | 157 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 144 | 158 | try { |
| 145 | 159 | $sth = $this->db->prepare($query); |
@@ -154,10 +168,15 @@ discard block |
||
| 154 | 168 | |
| 155 | 169 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 156 | 170 | global $globalStatsFilters; |
| 157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 171 | + if ($filter_name == '') { |
|
| 172 | + $filter_name = $this->filter_name; |
|
| 173 | + } |
|
| 158 | 174 | if ($year == '' && $month == '') { |
| 159 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 160 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 175 | + if ($limit) { |
|
| 176 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 177 | + } else { |
|
| 178 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 179 | + } |
|
| 161 | 180 | try { |
| 162 | 181 | $sth = $this->db->prepare($query); |
| 163 | 182 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -165,7 +184,9 @@ discard block |
||
| 165 | 184 | echo "error : ".$e->getMessage(); |
| 166 | 185 | } |
| 167 | 186 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 168 | - } else $all = array(); |
|
| 187 | + } else { |
|
| 188 | + $all = array(); |
|
| 189 | + } |
|
| 169 | 190 | if (empty($all)) { |
| 170 | 191 | $filters = array('airlines' => array($stats_airline)); |
| 171 | 192 | if ($filter_name != '') { |
@@ -178,10 +199,15 @@ discard block |
||
| 178 | 199 | } |
| 179 | 200 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 180 | 201 | global $globalStatsFilters; |
| 181 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 202 | + if ($filter_name == '') { |
|
| 203 | + $filter_name = $this->filter_name; |
|
| 204 | + } |
|
| 182 | 205 | if ($year == '' && $month == '') { |
| 183 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 184 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 206 | + if ($limit) { |
|
| 207 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 208 | + } else { |
|
| 209 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 210 | + } |
|
| 185 | 211 | try { |
| 186 | 212 | $sth = $this->db->prepare($query); |
| 187 | 213 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -189,7 +215,9 @@ discard block |
||
| 189 | 215 | echo "error : ".$e->getMessage(); |
| 190 | 216 | } |
| 191 | 217 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 192 | - } else $all = array(); |
|
| 218 | + } else { |
|
| 219 | + $all = array(); |
|
| 220 | + } |
|
| 193 | 221 | if (empty($all)) { |
| 194 | 222 | $Spotter = new Spotter($this->db); |
| 195 | 223 | $filters = array(); |
@@ -202,10 +230,15 @@ discard block |
||
| 202 | 230 | } |
| 203 | 231 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 204 | 232 | global $globalStatsFilters; |
| 205 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 233 | + if ($filter_name == '') { |
|
| 234 | + $filter_name = $this->filter_name; |
|
| 235 | + } |
|
| 206 | 236 | if ($year == '' && $month == '') { |
| 207 | - 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"; |
|
| 208 | - 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"; |
|
| 237 | + if ($limit) { |
|
| 238 | + $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"; |
|
| 239 | + } else { |
|
| 240 | + $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"; |
|
| 241 | + } |
|
| 209 | 242 | try { |
| 210 | 243 | $sth = $this->db->prepare($query); |
| 211 | 244 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -213,7 +246,9 @@ discard block |
||
| 213 | 246 | echo "error : ".$e->getMessage(); |
| 214 | 247 | } |
| 215 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 216 | - } else $all = array(); |
|
| 249 | + } else { |
|
| 250 | + $all = array(); |
|
| 251 | + } |
|
| 217 | 252 | if (empty($all)) { |
| 218 | 253 | $filters = array('airlines' => array($stats_airline)); |
| 219 | 254 | if ($filter_name != '') { |
@@ -227,10 +262,15 @@ discard block |
||
| 227 | 262 | |
| 228 | 263 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 229 | 264 | global $globalStatsFilters; |
| 230 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 265 | + if ($filter_name == '') { |
|
| 266 | + $filter_name = $this->filter_name; |
|
| 267 | + } |
|
| 231 | 268 | if ($year == '' && $month == '') { |
| 232 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 233 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 269 | + if ($limit) { |
|
| 270 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 271 | + } else { |
|
| 272 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 273 | + } |
|
| 234 | 274 | try { |
| 235 | 275 | $sth = $this->db->prepare($query); |
| 236 | 276 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -238,7 +278,9 @@ discard block |
||
| 238 | 278 | echo "error : ".$e->getMessage(); |
| 239 | 279 | } |
| 240 | 280 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 241 | - } else $all = array(); |
|
| 281 | + } else { |
|
| 282 | + $all = array(); |
|
| 283 | + } |
|
| 242 | 284 | if (empty($all)) { |
| 243 | 285 | $filters = array('airlines' => array($stats_airline)); |
| 244 | 286 | if ($filter_name != '') { |
@@ -251,9 +293,14 @@ discard block |
||
| 251 | 293 | } |
| 252 | 294 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 253 | 295 | global $globalStatsFilters; |
| 254 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 255 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 256 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 296 | + if ($filter_name == '') { |
|
| 297 | + $filter_name = $this->filter_name; |
|
| 298 | + } |
|
| 299 | + if ($limit) { |
|
| 300 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 301 | + } else { |
|
| 302 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 303 | + } |
|
| 257 | 304 | try { |
| 258 | 305 | $sth = $this->db->prepare($query); |
| 259 | 306 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -274,10 +321,15 @@ discard block |
||
| 274 | 321 | |
| 275 | 322 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 276 | 323 | global $globalStatsFilters; |
| 277 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 324 | + if ($filter_name == '') { |
|
| 325 | + $filter_name = $this->filter_name; |
|
| 326 | + } |
|
| 278 | 327 | if ($year == '' && $month == '') { |
| 279 | - 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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 280 | - 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 ORDER BY airline_count DESC"; |
|
| 328 | + if ($limit) { |
|
| 329 | + $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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 330 | + } else { |
|
| 331 | + $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 ORDER BY airline_count DESC"; |
|
| 332 | + } |
|
| 281 | 333 | try { |
| 282 | 334 | $sth = $this->db->prepare($query); |
| 283 | 335 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -285,7 +337,9 @@ discard block |
||
| 285 | 337 | echo "error : ".$e->getMessage(); |
| 286 | 338 | } |
| 287 | 339 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 288 | - } else $all = array(); |
|
| 340 | + } else { |
|
| 341 | + $all = array(); |
|
| 342 | + } |
|
| 289 | 343 | if (empty($all)) { |
| 290 | 344 | $Spotter = new Spotter($this->db); |
| 291 | 345 | $filters = array(); |
@@ -299,10 +353,15 @@ discard block |
||
| 299 | 353 | } |
| 300 | 354 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 301 | 355 | global $globalStatsFilters; |
| 302 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 356 | + if ($filter_name == '') { |
|
| 357 | + $filter_name = $this->filter_name; |
|
| 358 | + } |
|
| 303 | 359 | if ($year == '' && $month == '') { |
| 304 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 305 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 360 | + if ($limit) { |
|
| 361 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 362 | + } else { |
|
| 363 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 364 | + } |
|
| 306 | 365 | try { |
| 307 | 366 | $sth = $this->db->prepare($query); |
| 308 | 367 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -310,7 +369,9 @@ discard block |
||
| 310 | 369 | echo "error : ".$e->getMessage(); |
| 311 | 370 | } |
| 312 | 371 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 313 | - } else $all = array(); |
|
| 372 | + } else { |
|
| 373 | + $all = array(); |
|
| 374 | + } |
|
| 314 | 375 | if (empty($all)) { |
| 315 | 376 | $filters = array('airlines' => array($stats_airline)); |
| 316 | 377 | if ($filter_name != '') { |
@@ -323,10 +384,15 @@ discard block |
||
| 323 | 384 | } |
| 324 | 385 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 325 | 386 | global $globalStatsFilters; |
| 326 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 387 | + if ($filter_name == '') { |
|
| 388 | + $filter_name = $this->filter_name; |
|
| 389 | + } |
|
| 327 | 390 | if ($year == '' && $month == '') { |
| 328 | - 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"; |
|
| 329 | - 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"; |
|
| 391 | + if ($limit) { |
|
| 392 | + $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"; |
|
| 393 | + } else { |
|
| 394 | + $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"; |
|
| 395 | + } |
|
| 330 | 396 | try { |
| 331 | 397 | $sth = $this->db->prepare($query); |
| 332 | 398 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -334,7 +400,9 @@ discard block |
||
| 334 | 400 | echo "error : ".$e->getMessage(); |
| 335 | 401 | } |
| 336 | 402 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 337 | - } else $all = array(); |
|
| 403 | + } else { |
|
| 404 | + $all = array(); |
|
| 405 | + } |
|
| 338 | 406 | if (empty($all)) { |
| 339 | 407 | $filters = array('airlines' => array($stats_airline)); |
| 340 | 408 | if ($filter_name != '') { |
@@ -347,11 +415,16 @@ discard block |
||
| 347 | 415 | } |
| 348 | 416 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 349 | 417 | $Connection = new Connection(); |
| 350 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 418 | + if ($filter_name == '') { |
|
| 419 | + $filter_name = $this->filter_name; |
|
| 420 | + } |
|
| 351 | 421 | if ($Connection->tableExists('countries')) { |
| 352 | 422 | if ($year == '' && $month == '') { |
| 353 | - 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"; |
|
| 354 | - 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"; |
|
| 423 | + if ($limit) { |
|
| 424 | + $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"; |
|
| 425 | + } else { |
|
| 426 | + $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"; |
|
| 427 | + } |
|
| 355 | 428 | try { |
| 356 | 429 | $sth = $this->db->prepare($query); |
| 357 | 430 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -366,17 +439,24 @@ discard block |
||
| 366 | 439 | } |
| 367 | 440 | */ |
| 368 | 441 | return $all; |
| 369 | - } else return array(); |
|
| 442 | + } else { |
|
| 443 | + return array(); |
|
| 444 | + } |
|
| 370 | 445 | } else { |
| 371 | 446 | return array(); |
| 372 | 447 | } |
| 373 | 448 | } |
| 374 | 449 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 375 | 450 | global $globalStatsFilters; |
| 376 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 451 | + if ($filter_name == '') { |
|
| 452 | + $filter_name = $this->filter_name; |
|
| 453 | + } |
|
| 377 | 454 | if ($year == '' && $month == '') { |
| 378 | - 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"; |
|
| 379 | - 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"; |
|
| 455 | + if ($limit) { |
|
| 456 | + $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"; |
|
| 457 | + } else { |
|
| 458 | + $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"; |
|
| 459 | + } |
|
| 380 | 460 | try { |
| 381 | 461 | $sth = $this->db->prepare($query); |
| 382 | 462 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -384,7 +464,9 @@ discard block |
||
| 384 | 464 | echo "error : ".$e->getMessage(); |
| 385 | 465 | } |
| 386 | 466 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 387 | - } else $all = array(); |
|
| 467 | + } else { |
|
| 468 | + $all = array(); |
|
| 469 | + } |
|
| 388 | 470 | if (empty($all)) { |
| 389 | 471 | $filters = array('airlines' => array($stats_airline)); |
| 390 | 472 | if ($filter_name != '') { |
@@ -398,10 +480,15 @@ discard block |
||
| 398 | 480 | |
| 399 | 481 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 400 | 482 | global $globalStatsFilters; |
| 401 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 483 | + if ($filter_name == '') { |
|
| 484 | + $filter_name = $this->filter_name; |
|
| 485 | + } |
|
| 402 | 486 | if ($year == '' && $month == '') { |
| 403 | - 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"; |
|
| 404 | - 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"; |
|
| 487 | + if ($limit) { |
|
| 488 | + $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"; |
|
| 489 | + } else { |
|
| 490 | + $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"; |
|
| 491 | + } |
|
| 405 | 492 | try { |
| 406 | 493 | $sth = $this->db->prepare($query); |
| 407 | 494 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -409,7 +496,9 @@ discard block |
||
| 409 | 496 | echo "error : ".$e->getMessage(); |
| 410 | 497 | } |
| 411 | 498 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 412 | - } else $all = array(); |
|
| 499 | + } else { |
|
| 500 | + $all = array(); |
|
| 501 | + } |
|
| 413 | 502 | if (empty($all)) { |
| 414 | 503 | $filters = array('airlines' => array($stats_airline)); |
| 415 | 504 | if ($filter_name != '') { |
@@ -422,10 +511,15 @@ discard block |
||
| 422 | 511 | } |
| 423 | 512 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 424 | 513 | global $globalStatsFilters; |
| 425 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 514 | + if ($filter_name == '') { |
|
| 515 | + $filter_name = $this->filter_name; |
|
| 516 | + } |
|
| 426 | 517 | if ($year == '' && $month == '') { |
| 427 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
|
| 428 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 518 | + if ($limit) { |
|
| 519 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE 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"; |
|
| 520 | + } else { |
|
| 521 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 522 | + } |
|
| 429 | 523 | try { |
| 430 | 524 | $sth = $this->db->prepare($query); |
| 431 | 525 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -433,7 +527,9 @@ discard block |
||
| 433 | 527 | echo "error : ".$e->getMessage(); |
| 434 | 528 | } |
| 435 | 529 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 436 | - } else $all = array(); |
|
| 530 | + } else { |
|
| 531 | + $all = array(); |
|
| 532 | + } |
|
| 437 | 533 | if (empty($all)) { |
| 438 | 534 | $filters = array('airlines' => array($stats_airline)); |
| 439 | 535 | if ($filter_name != '') { |
@@ -452,7 +548,9 @@ discard block |
||
| 452 | 548 | $icao = $value['airport_departure_icao']; |
| 453 | 549 | if (isset($all[$icao])) { |
| 454 | 550 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 455 | - } else $all[$icao] = $value; |
|
| 551 | + } else { |
|
| 552 | + $all[$icao] = $value; |
|
| 553 | + } |
|
| 456 | 554 | } |
| 457 | 555 | $count = array(); |
| 458 | 556 | foreach ($all as $key => $row) { |
@@ -464,10 +562,15 @@ discard block |
||
| 464 | 562 | } |
| 465 | 563 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 466 | 564 | global $globalStatsFilters; |
| 467 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 565 | + if ($filter_name == '') { |
|
| 566 | + $filter_name = $this->filter_name; |
|
| 567 | + } |
|
| 468 | 568 | if ($year == '' && $month == '') { |
| 469 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE 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"; |
|
| 470 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 569 | + if ($limit) { |
|
| 570 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE 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"; |
|
| 571 | + } else { |
|
| 572 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 573 | + } |
|
| 471 | 574 | try { |
| 472 | 575 | $sth = $this->db->prepare($query); |
| 473 | 576 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -475,7 +578,9 @@ discard block |
||
| 475 | 578 | echo "error : ".$e->getMessage(); |
| 476 | 579 | } |
| 477 | 580 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 478 | - } else $all = array(); |
|
| 581 | + } else { |
|
| 582 | + $all = array(); |
|
| 583 | + } |
|
| 479 | 584 | if (empty($all)) { |
| 480 | 585 | $filters = array('airlines' => array($stats_airline)); |
| 481 | 586 | if ($filter_name != '') { |
@@ -494,7 +599,9 @@ discard block |
||
| 494 | 599 | $icao = $value['airport_arrival_icao']; |
| 495 | 600 | if (isset($all[$icao])) { |
| 496 | 601 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 497 | - } else $all[$icao] = $value; |
|
| 602 | + } else { |
|
| 603 | + $all[$icao] = $value; |
|
| 604 | + } |
|
| 498 | 605 | } |
| 499 | 606 | $count = array(); |
| 500 | 607 | foreach ($all as $key => $row) { |
@@ -507,13 +614,21 @@ discard block |
||
| 507 | 614 | } |
| 508 | 615 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 509 | 616 | global $globalDBdriver, $globalStatsFilters; |
| 510 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 617 | + if ($filter_name == '') { |
|
| 618 | + $filter_name = $this->filter_name; |
|
| 619 | + } |
|
| 511 | 620 | if ($globalDBdriver == 'mysql') { |
| 512 | - 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"; |
|
| 513 | - 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"; |
|
| 621 | + if ($limit) { |
|
| 622 | + $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"; |
|
| 623 | + } else { |
|
| 624 | + $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"; |
|
| 625 | + } |
|
| 514 | 626 | } else { |
| 515 | - 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"; |
|
| 516 | - 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"; |
|
| 627 | + if ($limit) { |
|
| 628 | + $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"; |
|
| 629 | + } else { |
|
| 630 | + $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"; |
|
| 631 | + } |
|
| 517 | 632 | } |
| 518 | 633 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 519 | 634 | try { |
@@ -537,7 +652,9 @@ discard block |
||
| 537 | 652 | |
| 538 | 653 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 539 | 654 | global $globalStatsFilters; |
| 540 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 655 | + if ($filter_name == '') { |
|
| 656 | + $filter_name = $this->filter_name; |
|
| 657 | + } |
|
| 541 | 658 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 542 | 659 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 543 | 660 | try { |
@@ -559,7 +676,9 @@ discard block |
||
| 559 | 676 | } |
| 560 | 677 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 561 | 678 | global $globalDBdriver, $globalStatsFilters; |
| 562 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 679 | + if ($filter_name == '') { |
|
| 680 | + $filter_name = $this->filter_name; |
|
| 681 | + } |
|
| 563 | 682 | if ($globalDBdriver == 'mysql') { |
| 564 | 683 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 565 | 684 | } else { |
@@ -585,7 +704,9 @@ discard block |
||
| 585 | 704 | } |
| 586 | 705 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 587 | 706 | global $globalStatsFilters; |
| 588 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 707 | + if ($filter_name == '') { |
|
| 708 | + $filter_name = $this->filter_name; |
|
| 709 | + } |
|
| 589 | 710 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 590 | 711 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 591 | 712 | try { |
@@ -607,7 +728,9 @@ discard block |
||
| 607 | 728 | } |
| 608 | 729 | public function countAllDatesByAirlines($filter_name = '') { |
| 609 | 730 | global $globalStatsFilters; |
| 610 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 731 | + if ($filter_name == '') { |
|
| 732 | + $filter_name = $this->filter_name; |
|
| 733 | + } |
|
| 611 | 734 | $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"; |
| 612 | 735 | $query_data = array('filter_name' => $filter_name); |
| 613 | 736 | try { |
@@ -629,7 +752,9 @@ discard block |
||
| 629 | 752 | } |
| 630 | 753 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 631 | 754 | global $globalStatsFilters; |
| 632 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 755 | + if ($filter_name == '') { |
|
| 756 | + $filter_name = $this->filter_name; |
|
| 757 | + } |
|
| 633 | 758 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 634 | 759 | try { |
| 635 | 760 | $sth = $this->db->prepare($query); |
@@ -652,7 +777,9 @@ discard block |
||
| 652 | 777 | } |
| 653 | 778 | public function countAllMilitaryMonths($filter_name = '') { |
| 654 | 779 | global $globalStatsFilters; |
| 655 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 780 | + if ($filter_name == '') { |
|
| 781 | + $filter_name = $this->filter_name; |
|
| 782 | + } |
|
| 656 | 783 | $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"; |
| 657 | 784 | try { |
| 658 | 785 | $sth = $this->db->prepare($query); |
@@ -673,9 +800,14 @@ discard block |
||
| 673 | 800 | } |
| 674 | 801 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 675 | 802 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 676 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 677 | - 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"; |
|
| 678 | - 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"; |
|
| 803 | + if ($filter_name == '') { |
|
| 804 | + $filter_name = $this->filter_name; |
|
| 805 | + } |
|
| 806 | + if ($limit) { |
|
| 807 | + $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"; |
|
| 808 | + } else { |
|
| 809 | + $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"; |
|
| 810 | + } |
|
| 679 | 811 | if ($orderby == 'hour') { |
| 680 | 812 | /* |
| 681 | 813 | if ($globalDBdriver == 'mysql') { |
@@ -684,7 +816,9 @@ discard block |
||
| 684 | 816 | */ |
| 685 | 817 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 686 | 818 | } |
| 687 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 819 | + if ($orderby == 'count') { |
|
| 820 | + $query .= " ORDER BY hour_count DESC"; |
|
| 821 | + } |
|
| 688 | 822 | try { |
| 689 | 823 | $sth = $this->db->prepare($query); |
| 690 | 824 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -705,8 +839,12 @@ discard block |
||
| 705 | 839 | |
| 706 | 840 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 707 | 841 | global $globalStatsFilters; |
| 708 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 709 | - if ($year == '') $year = date('Y'); |
|
| 842 | + if ($filter_name == '') { |
|
| 843 | + $filter_name = $this->filter_name; |
|
| 844 | + } |
|
| 845 | + if ($year == '') { |
|
| 846 | + $year = date('Y'); |
|
| 847 | + } |
|
| 710 | 848 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 711 | 849 | if (empty($all)) { |
| 712 | 850 | $filters = array('airlines' => array($stats_airline)); |
@@ -720,8 +858,12 @@ discard block |
||
| 720 | 858 | } |
| 721 | 859 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 722 | 860 | global $globalStatsFilters; |
| 723 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 724 | - if ($year == '') $year = date('Y'); |
|
| 861 | + if ($filter_name == '') { |
|
| 862 | + $filter_name = $this->filter_name; |
|
| 863 | + } |
|
| 864 | + if ($year == '') { |
|
| 865 | + $year = date('Y'); |
|
| 866 | + } |
|
| 725 | 867 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 726 | 868 | if (empty($all)) { |
| 727 | 869 | $filters = array(); |
@@ -735,8 +877,12 @@ discard block |
||
| 735 | 877 | } |
| 736 | 878 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 737 | 879 | global $globalStatsFilters; |
| 738 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 739 | - if ($year == '') $year = date('Y'); |
|
| 880 | + if ($filter_name == '') { |
|
| 881 | + $filter_name = $this->filter_name; |
|
| 882 | + } |
|
| 883 | + if ($year == '') { |
|
| 884 | + $year = date('Y'); |
|
| 885 | + } |
|
| 740 | 886 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 741 | 887 | if (empty($all)) { |
| 742 | 888 | $filters = array('airlines' => array($stats_airline)); |
@@ -750,8 +896,12 @@ discard block |
||
| 750 | 896 | } |
| 751 | 897 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 752 | 898 | global $globalStatsFilters; |
| 753 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 754 | - if ($year == '') $year = date('Y'); |
|
| 899 | + if ($filter_name == '') { |
|
| 900 | + $filter_name = $this->filter_name; |
|
| 901 | + } |
|
| 902 | + if ($year == '') { |
|
| 903 | + $year = date('Y'); |
|
| 904 | + } |
|
| 755 | 905 | $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
| 756 | 906 | if (empty($all)) { |
| 757 | 907 | $filters = array('airlines' => array($stats_airline)); |
@@ -765,7 +915,9 @@ discard block |
||
| 765 | 915 | } |
| 766 | 916 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 767 | 917 | global $globalStatsFilters; |
| 768 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 918 | + if ($filter_name == '') { |
|
| 919 | + $filter_name = $this->filter_name; |
|
| 920 | + } |
|
| 769 | 921 | if ($year == '' && $month == '') { |
| 770 | 922 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 771 | 923 | try { |
@@ -776,7 +928,9 @@ discard block |
||
| 776 | 928 | } |
| 777 | 929 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 778 | 930 | $all = $result[0]['nb_airline']; |
| 779 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 931 | + } else { |
|
| 932 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 933 | + } |
|
| 780 | 934 | if (empty($all)) { |
| 781 | 935 | $filters = array(); |
| 782 | 936 | if ($filter_name != '') { |
@@ -789,8 +943,12 @@ discard block |
||
| 789 | 943 | } |
| 790 | 944 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 791 | 945 | global $globalStatsFilters; |
| 792 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 793 | - if ($year == '') $year = date('Y'); |
|
| 946 | + if ($filter_name == '') { |
|
| 947 | + $filter_name = $this->filter_name; |
|
| 948 | + } |
|
| 949 | + if ($year == '') { |
|
| 950 | + $year = date('Y'); |
|
| 951 | + } |
|
| 794 | 952 | /* |
| 795 | 953 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
| 796 | 954 | try { |
@@ -815,8 +973,12 @@ discard block |
||
| 815 | 973 | } |
| 816 | 974 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 817 | 975 | global $globalStatsFilters; |
| 818 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 819 | - if ($year == '') $year = date('Y'); |
|
| 976 | + if ($filter_name == '') { |
|
| 977 | + $filter_name = $this->filter_name; |
|
| 978 | + } |
|
| 979 | + if ($year == '') { |
|
| 980 | + $year = date('Y'); |
|
| 981 | + } |
|
| 820 | 982 | $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
| 821 | 983 | if (empty($all)) { |
| 822 | 984 | $filters = array('airlines' => array($stats_airline)); |
@@ -830,7 +992,9 @@ discard block |
||
| 830 | 992 | } |
| 831 | 993 | |
| 832 | 994 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 833 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 995 | + if ($filter_name == '') { |
|
| 996 | + $filter_name = $this->filter_name; |
|
| 997 | + } |
|
| 834 | 998 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 835 | 999 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 836 | 1000 | try { |
@@ -843,7 +1007,9 @@ discard block |
||
| 843 | 1007 | return $all; |
| 844 | 1008 | } |
| 845 | 1009 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 846 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1010 | + if ($filter_name == '') { |
|
| 1011 | + $filter_name = $this->filter_name; |
|
| 1012 | + } |
|
| 847 | 1013 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 848 | 1014 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 849 | 1015 | try { |
@@ -856,7 +1022,9 @@ discard block |
||
| 856 | 1022 | return $all; |
| 857 | 1023 | } |
| 858 | 1024 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 859 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1025 | + if ($filter_name == '') { |
|
| 1026 | + $filter_name = $this->filter_name; |
|
| 1027 | + } |
|
| 860 | 1028 | global $globalArchiveMonths, $globalDBdriver; |
| 861 | 1029 | if ($globalDBdriver == 'mysql') { |
| 862 | 1030 | if ($month == '') { |
@@ -886,7 +1054,9 @@ discard block |
||
| 886 | 1054 | } |
| 887 | 1055 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 888 | 1056 | global $globalArchiveMonths, $globalDBdriver; |
| 889 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1057 | + if ($filter_name == '') { |
|
| 1058 | + $filter_name = $this->filter_name; |
|
| 1059 | + } |
|
| 890 | 1060 | if ($globalDBdriver == 'mysql') { |
| 891 | 1061 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 892 | 1062 | } else { |
@@ -904,7 +1074,9 @@ discard block |
||
| 904 | 1074 | } |
| 905 | 1075 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 906 | 1076 | global $globalArchiveMonths, $globalDBdriver; |
| 907 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1077 | + if ($filter_name == '') { |
|
| 1078 | + $filter_name = $this->filter_name; |
|
| 1079 | + } |
|
| 908 | 1080 | if ($globalDBdriver == 'mysql') { |
| 909 | 1081 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 910 | 1082 | } else { |
@@ -921,7 +1093,9 @@ discard block |
||
| 921 | 1093 | } |
| 922 | 1094 | public function getStatsAirlineTotal($filter_name = '') { |
| 923 | 1095 | global $globalArchiveMonths, $globalDBdriver; |
| 924 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1096 | + if ($filter_name == '') { |
|
| 1097 | + $filter_name = $this->filter_name; |
|
| 1098 | + } |
|
| 925 | 1099 | if ($globalDBdriver == 'mysql') { |
| 926 | 1100 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 927 | 1101 | } else { |
@@ -938,7 +1112,9 @@ discard block |
||
| 938 | 1112 | } |
| 939 | 1113 | public function getStatsOwnerTotal($filter_name = '') { |
| 940 | 1114 | global $globalArchiveMonths, $globalDBdriver; |
| 941 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1115 | + if ($filter_name == '') { |
|
| 1116 | + $filter_name = $this->filter_name; |
|
| 1117 | + } |
|
| 942 | 1118 | if ($globalDBdriver == 'mysql') { |
| 943 | 1119 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 944 | 1120 | } else { |
@@ -955,7 +1131,9 @@ discard block |
||
| 955 | 1131 | } |
| 956 | 1132 | public function getStatsPilotTotal($filter_name = '') { |
| 957 | 1133 | global $globalArchiveMonths, $globalDBdriver; |
| 958 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1134 | + if ($filter_name == '') { |
|
| 1135 | + $filter_name = $this->filter_name; |
|
| 1136 | + } |
|
| 959 | 1137 | if ($globalDBdriver == 'mysql') { |
| 960 | 1138 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 961 | 1139 | } else { |
@@ -973,7 +1151,9 @@ discard block |
||
| 973 | 1151 | |
| 974 | 1152 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 975 | 1153 | global $globalDBdriver; |
| 976 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1154 | + if ($filter_name == '') { |
|
| 1155 | + $filter_name = $this->filter_name; |
|
| 1156 | + } |
|
| 977 | 1157 | if ($globalDBdriver == 'mysql') { |
| 978 | 1158 | $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"; |
| 979 | 1159 | } else { |
@@ -989,7 +1169,9 @@ discard block |
||
| 989 | 1169 | } |
| 990 | 1170 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 991 | 1171 | global $globalDBdriver; |
| 992 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1172 | + if ($filter_name == '') { |
|
| 1173 | + $filter_name = $this->filter_name; |
|
| 1174 | + } |
|
| 993 | 1175 | if ($globalDBdriver == 'mysql') { |
| 994 | 1176 | $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"; |
| 995 | 1177 | } else { |
@@ -1375,10 +1557,14 @@ discard block |
||
| 1375 | 1557 | $Connection = new Connection(); |
| 1376 | 1558 | date_default_timezone_set('UTC'); |
| 1377 | 1559 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1378 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 1560 | + if ($globalDebug) { |
|
| 1561 | + echo 'Update stats !'."\n"; |
|
| 1562 | + } |
|
| 1379 | 1563 | if (isset($last_update[0]['value'])) { |
| 1380 | 1564 | $last_update_day = $last_update[0]['value']; |
| 1381 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 1565 | + } else { |
|
| 1566 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 1567 | + } |
|
| 1382 | 1568 | $reset = false; |
| 1383 | 1569 | if ($globalStatsResetYear) { |
| 1384 | 1570 | $reset = true; |
@@ -1386,42 +1572,60 @@ discard block |
||
| 1386 | 1572 | } |
| 1387 | 1573 | $Spotter = new Spotter($this->db); |
| 1388 | 1574 | |
| 1389 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 1575 | + if ($globalDebug) { |
|
| 1576 | + echo 'Count all aircraft types...'."\n"; |
|
| 1577 | + } |
|
| 1390 | 1578 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 1391 | 1579 | foreach ($alldata as $number) { |
| 1392 | 1580 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 1393 | 1581 | } |
| 1394 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 1582 | + if ($globalDebug) { |
|
| 1583 | + echo 'Count all airlines...'."\n"; |
|
| 1584 | + } |
|
| 1395 | 1585 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 1396 | 1586 | foreach ($alldata as $number) { |
| 1397 | 1587 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 1398 | 1588 | } |
| 1399 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 1589 | + if ($globalDebug) { |
|
| 1590 | + echo 'Count all registrations...'."\n"; |
|
| 1591 | + } |
|
| 1400 | 1592 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 1401 | 1593 | foreach ($alldata as $number) { |
| 1402 | 1594 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 1403 | 1595 | } |
| 1404 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 1596 | + if ($globalDebug) { |
|
| 1597 | + echo 'Count all callsigns...'."\n"; |
|
| 1598 | + } |
|
| 1405 | 1599 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 1406 | 1600 | foreach ($alldata as $number) { |
| 1407 | 1601 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1408 | 1602 | } |
| 1409 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 1603 | + if ($globalDebug) { |
|
| 1604 | + echo 'Count all owners...'."\n"; |
|
| 1605 | + } |
|
| 1410 | 1606 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 1411 | 1607 | foreach ($alldata as $number) { |
| 1412 | 1608 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 1413 | 1609 | } |
| 1414 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 1610 | + if ($globalDebug) { |
|
| 1611 | + echo 'Count all pilots...'."\n"; |
|
| 1612 | + } |
|
| 1415 | 1613 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 1416 | 1614 | foreach ($alldata as $number) { |
| 1417 | 1615 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 1418 | 1616 | } |
| 1419 | 1617 | |
| 1420 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 1618 | + if ($globalDebug) { |
|
| 1619 | + echo 'Count all departure airports...'."\n"; |
|
| 1620 | + } |
|
| 1421 | 1621 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 1422 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 1622 | + if ($globalDebug) { |
|
| 1623 | + echo 'Count all detected departure airports...'."\n"; |
|
| 1624 | + } |
|
| 1423 | 1625 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 1424 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 1626 | + if ($globalDebug) { |
|
| 1627 | + echo 'Order departure airports...'."\n"; |
|
| 1628 | + } |
|
| 1425 | 1629 | $alldata = array(); |
| 1426 | 1630 | |
| 1427 | 1631 | foreach ($pall as $value) { |
@@ -1432,7 +1636,9 @@ discard block |
||
| 1432 | 1636 | $icao = $value['airport_departure_icao']; |
| 1433 | 1637 | if (isset($alldata[$icao])) { |
| 1434 | 1638 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1435 | - } else $alldata[$icao] = $value; |
|
| 1639 | + } else { |
|
| 1640 | + $alldata[$icao] = $value; |
|
| 1641 | + } |
|
| 1436 | 1642 | } |
| 1437 | 1643 | $count = array(); |
| 1438 | 1644 | foreach ($alldata as $key => $row) { |
@@ -1442,11 +1648,17 @@ discard block |
||
| 1442 | 1648 | foreach ($alldata as $number) { |
| 1443 | 1649 | 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); |
| 1444 | 1650 | } |
| 1445 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 1651 | + if ($globalDebug) { |
|
| 1652 | + echo 'Count all arrival airports...'."\n"; |
|
| 1653 | + } |
|
| 1446 | 1654 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 1447 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 1655 | + if ($globalDebug) { |
|
| 1656 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 1657 | + } |
|
| 1448 | 1658 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 1449 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 1659 | + if ($globalDebug) { |
|
| 1660 | + echo 'Order arrival airports...'."\n"; |
|
| 1661 | + } |
|
| 1450 | 1662 | $alldata = array(); |
| 1451 | 1663 | foreach ($pall as $value) { |
| 1452 | 1664 | $icao = $value['airport_arrival_icao']; |
@@ -1456,7 +1668,9 @@ discard block |
||
| 1456 | 1668 | $icao = $value['airport_arrival_icao']; |
| 1457 | 1669 | if (isset($alldata[$icao])) { |
| 1458 | 1670 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1459 | - } else $alldata[$icao] = $value; |
|
| 1671 | + } else { |
|
| 1672 | + $alldata[$icao] = $value; |
|
| 1673 | + } |
|
| 1460 | 1674 | } |
| 1461 | 1675 | $count = array(); |
| 1462 | 1676 | foreach ($alldata as $key => $row) { |
@@ -1467,7 +1681,9 @@ discard block |
||
| 1467 | 1681 | 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); |
| 1468 | 1682 | } |
| 1469 | 1683 | if ($Connection->tableExists('countries')) { |
| 1470 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 1684 | + if ($globalDebug) { |
|
| 1685 | + echo 'Count all flights by countries...'."\n"; |
|
| 1686 | + } |
|
| 1471 | 1687 | $SpotterArchive = new SpotterArchive(); |
| 1472 | 1688 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 1473 | 1689 | foreach ($alldata as $number) { |
@@ -1479,46 +1695,66 @@ discard block |
||
| 1479 | 1695 | // Add by month using getstat if month finish... |
| 1480 | 1696 | |
| 1481 | 1697 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 1482 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 1698 | + if ($globalDebug) { |
|
| 1699 | + echo 'Count all flights by months...'."\n"; |
|
| 1700 | + } |
|
| 1483 | 1701 | $Spotter = new Spotter($this->db); |
| 1484 | 1702 | $alldata = $Spotter->countAllMonths(); |
| 1485 | 1703 | $lastyear = false; |
| 1486 | 1704 | foreach ($alldata as $number) { |
| 1487 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1705 | + if ($number['year_name'] != date('Y')) { |
|
| 1706 | + $lastyear = true; |
|
| 1707 | + } |
|
| 1488 | 1708 | $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']))); |
| 1489 | 1709 | } |
| 1490 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 1710 | + if ($globalDebug) { |
|
| 1711 | + echo 'Count all military flights by months...'."\n"; |
|
| 1712 | + } |
|
| 1491 | 1713 | $alldata = $Spotter->countAllMilitaryMonths(); |
| 1492 | 1714 | foreach ($alldata as $number) { |
| 1493 | 1715 | $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']))); |
| 1494 | 1716 | } |
| 1495 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 1717 | + if ($globalDebug) { |
|
| 1718 | + echo 'Count all owners by months...'."\n"; |
|
| 1719 | + } |
|
| 1496 | 1720 | $alldata = $Spotter->countAllMonthsOwners(); |
| 1497 | 1721 | foreach ($alldata as $number) { |
| 1498 | 1722 | $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']))); |
| 1499 | 1723 | } |
| 1500 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 1724 | + if ($globalDebug) { |
|
| 1725 | + echo 'Count all pilots by months...'."\n"; |
|
| 1726 | + } |
|
| 1501 | 1727 | $alldata = $Spotter->countAllMonthsPilots(); |
| 1502 | 1728 | foreach ($alldata as $number) { |
| 1503 | 1729 | $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']))); |
| 1504 | 1730 | } |
| 1505 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 1731 | + if ($globalDebug) { |
|
| 1732 | + echo 'Count all airlines by months...'."\n"; |
|
| 1733 | + } |
|
| 1506 | 1734 | $alldata = $Spotter->countAllMonthsAirlines(); |
| 1507 | 1735 | foreach ($alldata as $number) { |
| 1508 | 1736 | $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']))); |
| 1509 | 1737 | } |
| 1510 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 1738 | + if ($globalDebug) { |
|
| 1739 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 1740 | + } |
|
| 1511 | 1741 | $alldata = $Spotter->countAllMonthsAircrafts(); |
| 1512 | 1742 | foreach ($alldata as $number) { |
| 1513 | 1743 | $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']))); |
| 1514 | 1744 | } |
| 1515 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 1745 | + if ($globalDebug) { |
|
| 1746 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 1747 | + } |
|
| 1516 | 1748 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
| 1517 | 1749 | foreach ($alldata as $number) { |
| 1518 | 1750 | $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']))); |
| 1519 | 1751 | } |
| 1520 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 1521 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 1752 | + if ($globalDebug) { |
|
| 1753 | + echo 'Airports data...'."\n"; |
|
| 1754 | + } |
|
| 1755 | + if ($globalDebug) { |
|
| 1756 | + echo '...Departure'."\n"; |
|
| 1757 | + } |
|
| 1522 | 1758 | $this->deleteStatAirport('daily'); |
| 1523 | 1759 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1524 | 1760 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1639,44 +1875,62 @@ discard block |
||
| 1639 | 1875 | // Count by airlines |
| 1640 | 1876 | echo '--- Stats by airlines ---'."\n"; |
| 1641 | 1877 | if ($Connection->tableExists('countries')) { |
| 1642 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1878 | + if ($globalDebug) { |
|
| 1879 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1880 | + } |
|
| 1643 | 1881 | $SpotterArchive = new SpotterArchive(); |
| 1644 | 1882 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 1645 | 1883 | foreach ($alldata as $number) { |
| 1646 | 1884 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 1647 | 1885 | } |
| 1648 | 1886 | } |
| 1649 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1889 | + } |
|
| 1650 | 1890 | $Spotter = new Spotter($this->db); |
| 1651 | 1891 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 1652 | 1892 | foreach ($alldata as $number) { |
| 1653 | 1893 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 1654 | 1894 | } |
| 1655 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1895 | + if ($globalDebug) { |
|
| 1896 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1897 | + } |
|
| 1656 | 1898 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 1657 | 1899 | foreach ($alldata as $number) { |
| 1658 | 1900 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 1659 | 1901 | } |
| 1660 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 1902 | + if ($globalDebug) { |
|
| 1903 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 1904 | + } |
|
| 1661 | 1905 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 1662 | 1906 | foreach ($alldata as $number) { |
| 1663 | 1907 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1664 | 1908 | } |
| 1665 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 1909 | + if ($globalDebug) { |
|
| 1910 | + echo 'Count all owners by airlines...'."\n"; |
|
| 1911 | + } |
|
| 1666 | 1912 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 1667 | 1913 | foreach ($alldata as $number) { |
| 1668 | 1914 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 1669 | 1915 | } |
| 1670 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 1916 | + if ($globalDebug) { |
|
| 1917 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 1918 | + } |
|
| 1671 | 1919 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 1672 | 1920 | foreach ($alldata as $number) { |
| 1673 | 1921 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 1674 | 1922 | } |
| 1675 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 1923 | + if ($globalDebug) { |
|
| 1924 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 1925 | + } |
|
| 1676 | 1926 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1677 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 1929 | + } |
|
| 1678 | 1930 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1679 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 1931 | + if ($globalDebug) { |
|
| 1932 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 1933 | + } |
|
| 1680 | 1934 | //$alldata = array(); |
| 1681 | 1935 | foreach ($dall as $value) { |
| 1682 | 1936 | $icao = $value['airport_departure_icao']; |
@@ -1697,11 +1951,17 @@ discard block |
||
| 1697 | 1951 | foreach ($alldata as $number) { |
| 1698 | 1952 | 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); |
| 1699 | 1953 | } |
| 1700 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 1954 | + if ($globalDebug) { |
|
| 1955 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 1956 | + } |
|
| 1701 | 1957 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1702 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 1958 | + if ($globalDebug) { |
|
| 1959 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 1960 | + } |
|
| 1703 | 1961 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1704 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 1962 | + if ($globalDebug) { |
|
| 1963 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 1964 | + } |
|
| 1705 | 1965 | //$alldata = array(); |
| 1706 | 1966 | foreach ($dall as $value) { |
| 1707 | 1967 | $icao = $value['airport_arrival_icao']; |
@@ -1720,37 +1980,53 @@ discard block |
||
| 1720 | 1980 | } |
| 1721 | 1981 | $alldata = $pall; |
| 1722 | 1982 | foreach ($alldata as $number) { |
| 1723 | - 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); |
|
| 1983 | + if ($number['airline_icao'] != '') { |
|
| 1984 | + 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); |
|
| 1985 | + } |
|
| 1986 | + } |
|
| 1987 | + if ($globalDebug) { |
|
| 1988 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 1724 | 1989 | } |
| 1725 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 1726 | 1990 | $Spotter = new Spotter($this->db); |
| 1727 | 1991 | $alldata = $Spotter->countAllMonthsByAirlines(); |
| 1728 | 1992 | $lastyear = false; |
| 1729 | 1993 | foreach ($alldata as $number) { |
| 1730 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1994 | + if ($number['year_name'] != date('Y')) { |
|
| 1995 | + $lastyear = true; |
|
| 1996 | + } |
|
| 1731 | 1997 | $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']); |
| 1732 | 1998 | } |
| 1733 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 1999 | + if ($globalDebug) { |
|
| 2000 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2001 | + } |
|
| 1734 | 2002 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
| 1735 | 2003 | foreach ($alldata as $number) { |
| 1736 | 2004 | $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']); |
| 1737 | 2005 | } |
| 1738 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2006 | + if ($globalDebug) { |
|
| 2007 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2008 | + } |
|
| 1739 | 2009 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
| 1740 | 2010 | foreach ($alldata as $number) { |
| 1741 | 2011 | $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']); |
| 1742 | 2012 | } |
| 1743 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2013 | + if ($globalDebug) { |
|
| 2014 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2015 | + } |
|
| 1744 | 2016 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
| 1745 | 2017 | foreach ($alldata as $number) { |
| 1746 | 2018 | $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']); |
| 1747 | 2019 | } |
| 1748 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2020 | + if ($globalDebug) { |
|
| 2021 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2022 | + } |
|
| 1749 | 2023 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
| 1750 | 2024 | foreach ($alldata as $number) { |
| 1751 | 2025 | $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']); |
| 1752 | 2026 | } |
| 1753 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2027 | + if ($globalDebug) { |
|
| 2028 | + echo '...Departure'."\n"; |
|
| 2029 | + } |
|
| 1754 | 2030 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 1755 | 2031 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 1756 | 2032 | foreach ($dall as $value) { |
@@ -1773,7 +2049,9 @@ discard block |
||
| 1773 | 2049 | foreach ($alldata as $number) { |
| 1774 | 2050 | $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']); |
| 1775 | 2051 | } |
| 1776 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2052 | + if ($globalDebug) { |
|
| 2053 | + echo '...Arrival'."\n"; |
|
| 2054 | + } |
|
| 1777 | 2055 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 1778 | 2056 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 1779 | 2057 | foreach ($dall as $value) { |
@@ -1797,13 +2075,19 @@ discard block |
||
| 1797 | 2075 | $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']); |
| 1798 | 2076 | } |
| 1799 | 2077 | |
| 1800 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 1801 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2078 | + if ($globalDebug) { |
|
| 2079 | + echo 'Flights data...'."\n"; |
|
| 2080 | + } |
|
| 2081 | + if ($globalDebug) { |
|
| 2082 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2083 | + } |
|
| 1802 | 2084 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
| 1803 | 2085 | foreach ($alldata as $number) { |
| 1804 | 2086 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 1805 | 2087 | } |
| 1806 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2088 | + if ($globalDebug) { |
|
| 2089 | + echo '-> countAllDates...'."\n"; |
|
| 2090 | + } |
|
| 1807 | 2091 | //$previousdata = $this->countAllDatesByAirlines(); |
| 1808 | 2092 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
| 1809 | 2093 | $values = array(); |
@@ -1816,7 +2100,9 @@ discard block |
||
| 1816 | 2100 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 1817 | 2101 | } |
| 1818 | 2102 | |
| 1819 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2103 | + if ($globalDebug) { |
|
| 2104 | + echo '-> countAllHours...'."\n"; |
|
| 2105 | + } |
|
| 1820 | 2106 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
| 1821 | 2107 | foreach ($alldata as $number) { |
| 1822 | 2108 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1824,7 +2110,9 @@ discard block |
||
| 1824 | 2110 | |
| 1825 | 2111 | |
| 1826 | 2112 | // Stats by filters |
| 1827 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2113 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2114 | + $globalStatsFilters = array(); |
|
| 2115 | + } |
|
| 1828 | 2116 | foreach ($globalStatsFilters as $name => $filter) { |
| 1829 | 2117 | //$filter_name = $filter['name']; |
| 1830 | 2118 | $filter_name = $name; |
@@ -1832,11 +2120,15 @@ discard block |
||
| 1832 | 2120 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 1833 | 2121 | if (isset($last_update[0]['value'])) { |
| 1834 | 2122 | $last_update_day = $last_update[0]['value']; |
| 1835 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 2123 | + } else { |
|
| 2124 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 2125 | + } |
|
| 1836 | 2126 | $reset = false; |
| 1837 | 2127 | |
| 1838 | 2128 | // Count by filter |
| 1839 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2129 | + if ($globalDebug) { |
|
| 2130 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2131 | + } |
|
| 1840 | 2132 | $Spotter = new Spotter($this->db); |
| 1841 | 2133 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 1842 | 2134 | foreach ($alldata as $number) { |
@@ -1873,7 +2165,9 @@ discard block |
||
| 1873 | 2165 | $icao = $value['airport_departure_icao']; |
| 1874 | 2166 | if (isset($alldata[$icao])) { |
| 1875 | 2167 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1876 | - } else $alldata[$icao] = $value; |
|
| 2168 | + } else { |
|
| 2169 | + $alldata[$icao] = $value; |
|
| 2170 | + } |
|
| 1877 | 2171 | } |
| 1878 | 2172 | $count = array(); |
| 1879 | 2173 | foreach ($alldata as $key => $row) { |
@@ -1894,7 +2188,9 @@ discard block |
||
| 1894 | 2188 | $icao = $value['airport_arrival_icao']; |
| 1895 | 2189 | if (isset($alldata[$icao])) { |
| 1896 | 2190 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1897 | - } else $alldata[$icao] = $value; |
|
| 2191 | + } else { |
|
| 2192 | + $alldata[$icao] = $value; |
|
| 2193 | + } |
|
| 1898 | 2194 | } |
| 1899 | 2195 | $count = array(); |
| 1900 | 2196 | foreach ($alldata as $key => $row) { |
@@ -1908,7 +2204,9 @@ discard block |
||
| 1908 | 2204 | $alldata = $Spotter->countAllMonths($filter); |
| 1909 | 2205 | $lastyear = false; |
| 1910 | 2206 | foreach ($alldata as $number) { |
| 1911 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2207 | + if ($number['year_name'] != date('Y')) { |
|
| 2208 | + $lastyear = true; |
|
| 2209 | + } |
|
| 1912 | 2210 | $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); |
| 1913 | 2211 | } |
| 1914 | 2212 | $alldata = $Spotter->countAllMonthsOwners($filter); |