Completed
Push — master ( b8bf1c...02faf6 )
by Yannick
10:43
created
statistics.php 2 patches
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $Stats = new Stats();
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == '' && isset($globalFilter)) {
12 12
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 13
 }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	$title = _("Statistics");
23 23
 }
24 24
 
25
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
25
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
26
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
27 27
 
28 28
 require_once('header.php');
29 29
 
@@ -44,36 +44,36 @@  discard block
 block discarded – undo
44 44
 		date_default_timezone_set('UTC');
45 45
 		$lastupdate = strtotime($last_update[0]['value']);
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
47
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
48 48
 	}
49 49
     ?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
53
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
54
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
55
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
53
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
54
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
55
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
57 57
 	<?php
58 58
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
60
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
61
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
62 62
         <?php
63 63
     	    } else {
64 64
     	?>
65
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
65
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
66
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
67 67
     	<?php
68 68
     	    }
69 69
     	?>
70
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
70
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
72 72
         <?php
73 73
     		if ($airline_icao == '') {
74 74
     	?>
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
76
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
 	<?php
78 78
 		}
79 79
 	?>
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
82 82
 			if ($airline_icao == '' || $airline_icao == 'all') {
83 83
 	?>
84
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
85
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
84
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
85
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
86 86
 	<?php
87 87
 			}
88 88
 		}
89 89
 	?>
90 90
     </p>
91
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
92 92
     <div class="specific-stats">
93 93
         <div class="row column">
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
97
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
98 98
 		    if (count($aircraft_array) == 0) print _("No data available");
99 99
 		    else {
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108 108
                             $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
109
+                          foreach ($aircraft_array as $aircraft_item)
110 110
                                     {
111 111
                                             $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112 112
                                     }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
             	    ?>
144 144
                 </div>
145 145
             </div>
146
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
146
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149 149
     if ($airline_icao == '' || $airline_icao == 'all') {
150
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
150
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
151 151
 	if (count($airline_array) > 0) {
152 152
             print '<div class="col-md-6">';
153 153
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161 161
 	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
162
+	    foreach ($airline_array as $airline_item)
163 163
 	    {
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165 165
 	    }
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 ?>
191 191
         </div>
192
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
192
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
193 193
 <?php
194 194
     }
195 195
 ?>
196 196
         <div class="row column">
197 197
 <?php
198
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
198
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
199 199
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
200 200
 	if (empty($flightover_array)) {
201 201
 	    print '<div class="col-md-12">';
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 ?>
206 206
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
207 207
 <?php
208
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
208
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
209 209
 	if (count($pilot_array) == 0) print _("No data available");
210 210
 	else {
211 211
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                         var data = google.visualization.arrayToDataTable([
217 217
                             ["'._("Pilots").'", "'._("# of times").'"], ';
218 218
 	    $pilot_data = '';
219
-	    foreach($pilot_array as $pilot_item)
219
+	    foreach ($pilot_array as $pilot_item)
220 220
 	    {
221 221
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
222 222
 	    }
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 ?>
245 245
             </div>
246 246
         
247
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
247
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
248 248
 <?php
249 249
     } else {
250 250
 ?>
251 251
             <div class="col-md-6">
252 252
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
253 253
 <?php
254
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
254
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
255 255
 	if (count($owner_array) == 0) print _("No data available");
256 256
 	else {
257 257
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                         var data = google.visualization.arrayToDataTable([
263 263
                             ["'._("Owner").'", "'._("# of times").'"], ';
264 264
                             $owner_data = '';
265
-	    foreach($owner_array as $owner_item)
265
+	    foreach ($owner_array as $owner_item)
266 266
 	    {
267 267
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
268 268
 	    }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 </div>
291 291
             </div>
292 292
         
293
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
293
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
294 294
 <?php
295 295
     }
296 296
     if (!empty($flightover_array)) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                         var data = google.visualization.arrayToDataTable([
310 310
                             ["'._("Country").'", "'._("# of times").'"], ';
311 311
                             $flightover_data = '';
312
-	    foreach($flightover_array as $flightover_item)
312
+	    foreach ($flightover_array as $flightover_item)
313 313
 	    {
314 314
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
315 315
 	    }
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
     }
343 343
 ?>
344 344
         </div>
345
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
345
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
346 346
 
347 347
     	
348 348
         </div>
349 349
         <div class="row column">
350 350
             <div class="col-md-6">
351 351
 <?php
352
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
352
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
353 353
     if (count($airport_airport_array) > 0) {
354 354
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
355 355
 	print '<div id="chart3" class="chart" width="100%"></div>
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                 var data = google.visualization.arrayToDataTable([ 
365 365
                     ["'._("Airport").'", "'._("# of times").'"],';
366 366
                     $airport_data = '';
367
-	foreach($airport_airport_array as $airport_item)
367
+	foreach ($airport_airport_array as $airport_item)
368 368
 	{
369 369
 	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
370 370
 	    $name = str_replace("'", "", $name);
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
     }
392 392
 ?>
393 393
             </div>
394
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
394
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
395 395
 
396 396
             <div class="col-md-6">
397 397
 <?php
398
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
398
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
399 399
     if (count($airport_airport_array2) > 0) {
400 400
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
401 401
 	print '<div id="chart4" class="chart" width="100%"></div>
@@ -410,10 +410,10 @@  discard block
 block discarded – undo
410 410
                 var data = google.visualization.arrayToDataTable([ 
411 411
                     ["'._("Airport").'", "'._("# of times").'"],';
412 412
 	$airport_data2 = '';
413
-	foreach($airport_airport_array2 as $airport_item2)
413
+	foreach ($airport_airport_array2 as $airport_item2)
414 414
 	{
415 415
 	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
416
-	    $name2 = str_replace(array("'",'"'), '', $name2);
416
+	    $name2 = str_replace(array("'", '"'), '', $name2);
417 417
 	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
418 418
 	}
419 419
 	$airport_data2 = substr($airport_data2, 0, -1);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 ?>
438 438
             </div>
439 439
         </div>
440
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
440
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
441 441
 <?php
442 442
     if ($year == '' && $month == '') {
443 443
 ?>
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
             <div class="col-md-6">
446 446
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
447 447
                 <?php
448
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
448
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
449 449
 		    if (count($year_array) == 0) print _("No data available");
450 450
 		    else {
451 451
                   print '<div id="chart8" class="chart" width="100%"></div>
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
                         var data = google.visualization.arrayToDataTable([
457 457
                             ["'._("Month").'", "'._("# of Flights").'"], ';
458 458
                             $year_data = '';
459
-                          foreach($year_array as $year_item)
459
+                          foreach ($year_array as $year_item)
460 460
                                     {
461
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
461
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
462 462
                                     }
463 463
                                     $year_data = substr($year_data, 0, -1);
464 464
                                     print $year_data;
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
                     <a href="<?php print $globalURL; ?>/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
487 487
                 </div>
488 488
             </div>
489
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
489
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
490 490
             <div class="col-md-6">
491 491
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
492 492
                 <?php
493
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
493
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
494 494
 		    if (count($month_array) == 0) print _("No data available");
495 495
 		    else {
496 496
                   print '<div id="chart9" class="chart" width="100%"></div>
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
                         var data = google.visualization.arrayToDataTable([
502 502
                             ["'._("Day").'", "'._("# of Flights").'"], ';
503 503
                             $month_data = '';
504
-                          foreach($month_array as $month_item)
504
+                          foreach ($month_array as $month_item)
505 505
                                     {
506
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
506
+                                        $month_data .= '[ "'.date('F j, Y', strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
507 507
                                     }
508 508
                                     $month_data = substr($month_data, 0, -1);
509 509
                                     print $month_data;
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
                     <a href="<?php print $globalURL; ?>/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
532 532
                 </div>
533 533
             </div>
534
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
534
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
535 535
 
536 536
             <div class="col-md-6">
537 537
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
538 538
                 <?php
539
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
539
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
540 540
 		    if (empty($date_array)) print _("No data available");
541 541
 		    else {
542 542
                   print '<div id="chart5" class="chart" width="100%"></div>
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
                             ["'._("Date").'", "'._("# of Flights").'"], ';
549 549
                             $date_data = '';
550 550
                         
551
-                          foreach($date_array as $date_item)
551
+                          foreach ($date_array as $date_item)
552 552
                                     {
553 553
                                         $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
554 554
                                     }
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
                     <a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
579 579
                 </div>
580 580
             </div>
581
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
581
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
582 582
             <div class="col-md-6">
583 583
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
584 584
                 <?php
585
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
585
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
586 586
 		    if (empty($hour_array)) print _("No data available");
587 587
 		    else {
588 588
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
                         var data = google.visualization.arrayToDataTable([
595 595
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
596 596
                             $hour_data = '';
597
-                          foreach($hour_array as $hour_item)
597
+                          foreach ($hour_array as $hour_item)
598 598
                                     {
599 599
                                         $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
600 600
                                     }
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                     <a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
625 625
                 </div>
626 626
             </div>
627
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
627
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
628 628
         </div>
629 629
 <?php
630 630
     }
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
                         var data = google.visualization.arrayToDataTable([
651 651
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
652 652
                             $year_data = '';
653
-                          foreach($year_array as $year_item)
653
+                          foreach ($year_array as $year_item)
654 654
                                     {
655 655
                                         $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
656 656
                                     }
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
681 681
                 </div>
682 682
             </div>
683
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
683
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
684 684
 
685 685
         <div class="row column">
686 686
             <div class="col-md-6">
@@ -699,9 +699,9 @@  discard block
 block discarded – undo
699 699
                         var data = google.visualization.arrayToDataTable([
700 700
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
701 701
                             $year_data = '';
702
-                          foreach($year_array as $year_item)
702
+                          foreach ($year_array as $year_item)
703 703
                                     {
704
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
704
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
705 705
                                     }
706 706
                                     $year_data = substr($year_data, 0, -1);
707 707
                                     print $year_data;
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
730 730
                 </div>
731 731
             </div>
732
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
732
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
733 733
 <br/>
734 734
 <?php
735 735
     }
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
         	<?php
743 743
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
744 744
         	    if ($year == '' && $month == '') {
745
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
745
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
746 746
 		    } else {
747
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
747
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
748 748
         	    }
749 749
         	    if (!empty($polar)) {
750 750
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         		    unset($polar_data);
753 753
 	        	    $Spotter = new Spotter();
754 754
         		    $data = json_decode($eachpolar['source_data']);
755
-        		    foreach($data as $value => $key) {
755
+        		    foreach ($data as $value => $key) {
756 756
         			$direction = $Spotter->parseDirection(($value*22.5));
757 757
         			$distance = $key;
758 758
         			$unit = 'km';
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         	?>
773 773
             <div class="col-md-6">
774 774
                 <h4><?php print $eachpolar['source_name']; ?></h4>
775
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
775
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
776 776
         	<script>
777 777
         	    (function() {
778 778
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 		      color: color,
797 797
 		      unit: '<?php echo $unit; ?>'
798 798
 		    };
799
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
799
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
800 800
 		    })();
801 801
 		</script>
802 802
             </div>
@@ -810,22 +810,22 @@  discard block
 block discarded – undo
810 810
         	<?php
811 811
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
812 812
         	    if ($year == '' && $month == '') {
813
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
813
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
814 814
         	    } else {
815
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
815
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
816 816
         	    }
817 817
         	    if (!empty($msg)) {
818 818
             		print '<h2>'._("Messages received").'</h2>';
819 819
         		foreach ($msg as $eachmsg) {
820 820
         		    //$eachmsg = $msg[0];
821 821
         		    $data = $eachmsg['source_data'];
822
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
822
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
823 823
         		    else $max = 500;
824 824
         	?>
825
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
825
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
826 826
         	<script>
827 827
 		      var g = new JustGage({
828
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
828
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
829 829
 			    value: <?php echo $data; ?>,
830 830
 			    min: 0,
831 831
 			    max: <?php print $max; ?>,
@@ -847,15 +847,15 @@  discard block
 block discarded – undo
847 847
             <?php
848 848
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
849 849
 		if ($year == '' && $month == '') {
850
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
850
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
851 851
 		} else {
852
-			$hist = $Stats->getStatsSource('hist',$year,$month);
852
+			$hist = $Stats->getStatsSource('hist', $year, $month);
853 853
 		}
854 854
 		foreach ($hist as $hists) {
855 855
 			$hist_data = '';
856 856
 			$source = $hists['source_name'];
857 857
 			$hist_array = json_decode($hists['source_data']);
858
-			foreach($hist_array as $distance => $nb)
858
+			foreach ($hist_array as $distance => $nb)
859 859
 			{
860 860
 				$unit = 'km';
861 861
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
 			$hist_data = substr($hist_data, 0, -1);
874 874
             ?>
875 875
             <div class="col-md-6">
876
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
876
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
877 877
                 <?php
878
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
878
+                  print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div>
879 879
                     <script> 
880 880
                         google.load("visualization", "1", {packages:["corechart"]});
881
-                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
882
-                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
881
+                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ', '_', strtolower($source)).');
882
+                      function drawCharthist_'.str_replace(' ', '_', strtolower($source)).'() {
883 883
                         var data = google.visualization.arrayToDataTable([
884 884
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
885 885
                             print $hist_data;
@@ -894,16 +894,16 @@  discard block
 block discarded – undo
894 894
                             colors: ["#1a3151"]
895 895
                         };
896 896
 
897
-                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
897
+                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ', '_', strtolower($source)).'"));
898 898
                         chart.draw(data, options);
899 899
                       }
900 900
                       $(window).resize(function(){
901
-                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
901
+                              drawCharthist_'.str_replace(' ', '_', strtolower($source)).'();
902 902
                             });
903 903
                   </script>';
904 904
         	?>
905 905
     	    </div>
906
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
906
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
907 907
         	<?php
908 908
                   }
909 909
                 ?>
Please login to merge, or discard this patch.
Braces   +56 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
require/class.METAR.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			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
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$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);
108
-				$result['wind']['gust'] = (float)$matches[3];
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);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//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');
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');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,30 +331,30 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345 345
     			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
347
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
346
+	    		while (($line = fgets($handle, 4096)) !== false) {
347
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
348 348
 					$date = $line;
349 349
     				} elseif ($line != '') {
350 350
     				    //$this->parse($line);
351 351
     				    if ($date == '') $date = date('Y/m/d H:m');
352 352
         			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
353
+        			    $pieces = preg_split('/\s/', $line);
354 354
         			    if ($pieces[0] == 'METAR') $pos++;
355 355
         			    if (strlen($pieces[$pos]) != 4) $pos++;
356 356
 		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
357
+        	        	    echo $this->addMETAR($location, $line, $date);
358 358
     				}
359 359
     			}
360 360
     			fclose($handle);
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
     		if ($globalMETARurl == '') return array();
369 369
     		date_default_timezone_set("UTC");
370 370
     		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
371
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
372 372
     		$cycle = $Common->getData($url);
373 373
     		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
+    		foreach (explode("\n", $cycle) as $line) {
375
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
376 376
     				//echo "date : ".$line."\n";
377 377
     				$date = $line;
378 378
     			} 
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
     			    //echo $line;
382 382
     			    if ($date == '') $date = date('Y/m/d H:m');
383 383
     			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
384
+    			    $pieces = preg_split('/\s/', $line);
385 385
     			    if ($pieces[0] == 'METAR') $pos++;
386 386
     			    if (strlen($pieces[$pos]) != 4) $pos++;
387 387
 	        	    $location = $pieces[$pos];
388 388
 	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
389
+	        		$this->addMETAR($location, $line, $date);
390 390
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391 391
 	        	    } else return array();
392 392
     			}
Please login to merge, or discard this patch.
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     		}
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 2 patches
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
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)) $filter = array_merge($filter, $globalFilter);
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29
-	foreach($filters as $flt) {
29
+	foreach ($filters as $flt) {
30 30
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32 32
 		    if (isset($flt['source'])) {
33
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
33
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
34 34
 		    } else {
35
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
35
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
36 36
 		    }
37 37
 		}
38 38
 	    }
39 39
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
41
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
43
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45 45
 	    }
46 46
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
48
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
49 49
 		}
50 50
 	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53 53
 	    if ($filter['airlines'][0] != '') {
54
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
54
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
55 55
 	    }
56 56
 	}
57 57
 	
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
62
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
65
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68 68
 	    $filter_query_where = " WHERE ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71 71
 	    if ($filter_query_where == '') {
72
-		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
72
+		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
73 73
 	    } else {
74
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 	    }
76 76
 	}
77 77
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
 	// Spotter_archive
84
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
84
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
85 85
 		require_once(dirname(__FILE__).'/class.Spotter.php');
86 86
 		if ($over_country == '') {
87 87
 			$Spotter = new Spotter($this->db);
88
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
88
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
89 89
 			if (!empty($data_country)) $country = $data_country['iso2'];
90 90
 			else $country = '';
91 91
 		} else $country = $over_country;
92
-		if ($airline_type === NULL) $airline_type ='';
92
+		if ($airline_type === NULL) $airline_type = '';
93 93
 	
94 94
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
95 95
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
96 96
 
97 97
 		// Route is not added in spotter_archive
98
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
98
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
99 99
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
100 100
 
101
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
101
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			return "error : ".$e->getMessage();
107 107
 		}
108 108
 		return "success";
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
124 124
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
125
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126 126
 
127
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
127
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
128 128
 
129 129
                 return $spotter_array;
130 130
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
144 144
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
145 145
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
146
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
146
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
147 147
 
148 148
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
149 149
                   /*
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 }
157 157
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
158 158
                 */
159
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
159
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
160 160
 
161 161
                 return $spotter_array;
162 162
         }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         {
172 172
                 date_default_timezone_set('UTC');
173 173
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
174
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
174
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
175 175
 
176 176
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
177 177
 
178 178
                 try {
179 179
                         $sth = $this->db->prepare($query);
180 180
                         $sth->execute(array(':id' => $id));
181
-                } catch(PDOException $e) {
181
+                } catch (PDOException $e) {
182 182
                         echo $e->getMessage();
183 183
                         die;
184 184
                 }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
         {
198 198
                 date_default_timezone_set('UTC');
199 199
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
200
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
200
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
201 201
 
202 202
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
203 203
 
204 204
                 try {
205 205
                         $sth = $this->db->prepare($query);
206 206
                         $sth->execute(array(':id' => $id));
207
-                } catch(PDOException $e) {
207
+                } catch (PDOException $e) {
208 208
                         echo $e->getMessage();
209 209
                         die;
210 210
                 }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
                 date_default_timezone_set('UTC');
227 227
 
228 228
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
229
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
229
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
230 230
 
231 231
                 try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute(array(':ident' => $ident));
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo $e->getMessage();
236 236
                         die;
237 237
                 }
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
                 date_default_timezone_set('UTC');
253 253
 
254 254
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
255
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
255
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
256 256
 
257 257
                 try {
258 258
                         $sth = $this->db->prepare($query);
259 259
                         $sth->execute(array(':id' => $id));
260
-                } catch(PDOException $e) {
260
+                } catch (PDOException $e) {
261 261
                         echo $e->getMessage();
262 262
                         die;
263 263
                 }
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
                 date_default_timezone_set('UTC');
279 279
 
280 280
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
281
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
281
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
282 282
 
283 283
                 try {
284 284
                         $sth = $this->db->prepare($query);
285 285
                         $sth->execute(array(':id' => $id));
286
-                } catch(PDOException $e) {
286
+                } catch (PDOException $e) {
287 287
                         echo $e->getMessage();
288 288
                         die;
289 289
                 }
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
                 date_default_timezone_set('UTC');
306 306
 
307 307
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
308
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
308
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
309 309
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
310 310
 
311 311
                 try {
312 312
                         $sth = $this->db->prepare($query);
313 313
                         $sth->execute(array(':ident' => $ident));
314
-                } catch(PDOException $e) {
314
+                } catch (PDOException $e) {
315 315
                         echo $e->getMessage();
316 316
                         die;
317 317
                 }
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         * @return Array the spotter information
329 329
         *
330 330
         */
331
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
331
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
332 332
         {
333 333
     		$Spotter = new Spotter($this->db);
334 334
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
335
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
335
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
336 336
 
337
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
337
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
338 338
 
339 339
                 return $spotter_array;
340 340
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                 try {
348 348
                         $sth = $this->db->prepare($query);
349 349
                         $sth->execute();
350
-                } catch(PDOException $e) {
350
+                } catch (PDOException $e) {
351 351
                         echo $e->getMessage();
352 352
                         die;
353 353
                 }
@@ -359,24 +359,24 @@  discard block
 block discarded – undo
359 359
         * @return Array the spotter information
360 360
         *
361 361
         */
362
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
362
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
363 363
         {
364 364
                 global $globalDBdriver, $globalLiveInterval;
365 365
                 date_default_timezone_set('UTC');
366 366
 
367 367
                 $filter_query = '';
368 368
                 if (isset($filter['source']) && !empty($filter['source'])) {
369
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
370 370
                 }
371 371
                 // Use spotter_output also ?
372 372
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
373
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
373
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
374 374
                 }
375 375
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
376 376
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
377 377
                 }
378 378
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
379
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
380 380
                 }
381 381
 
382 382
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
396 396
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
397 397
 */
398
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
398
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399 399
 				    FROM spotter_archive 
400 400
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
401 401
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
402 402
                         	    '.$filter_query.' ORDER BY flightaware_id';
403 403
                 } else {
404 404
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
405
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
405
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406 406
                         	    FROM spotter_archive 
407 407
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
408 408
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
                 try {
413 413
                         $sth = $this->db->prepare($query);
414 414
                         $sth->execute();
415
-                } catch(PDOException $e) {
415
+                } catch (PDOException $e) {
416 416
                         echo $e->getMessage();
417 417
                         die;
418 418
                 }
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
         * @return Array the spotter information
428 428
         *
429 429
         */
430
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
430
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
431 431
         {
432 432
                 global $globalDBdriver, $globalLiveInterval;
433 433
                 date_default_timezone_set('UTC');
434 434
 
435 435
                 $filter_query = '';
436 436
                 if (isset($filter['source']) && !empty($filter['source'])) {
437
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
438 438
                 }
439 439
                 // Should use spotter_output also ?
440 440
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
441
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
441
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
442 442
                 }
443 443
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
444 444
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
445 445
                 }
446 446
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
447
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
448 448
                 }
449 449
 
450 450
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                     		    FROM spotter_archive 
455 455
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
456 456
 			*/
457
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
457
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
458 458
 				    FROM spotter_archive_output 
459 459
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
460 460
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
470 470
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
471 471
                         */
472
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
472
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
473 473
                         	    FROM spotter_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 try {
482 482
                         $sth = $this->db->prepare($query);
483 483
                         $sth->execute();
484
-                } catch(PDOException $e) {
484
+                } catch (PDOException $e) {
485 485
                         echo $e->getMessage();
486 486
                         die;
487 487
                 }
@@ -496,23 +496,23 @@  discard block
 block discarded – undo
496 496
         * @return Array the spotter information
497 497
         *
498 498
         */
499
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
499
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
500 500
         {
501 501
                 global $globalDBdriver, $globalLiveInterval;
502 502
                 date_default_timezone_set('UTC');
503 503
 
504 504
                 $filter_query = '';
505 505
                 if (isset($filter['source']) && !empty($filter['source'])) {
506
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
507 507
                 }
508 508
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
509
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
509
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
510 510
                 }
511 511
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
512 512
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
513 513
                 }
514 514
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
515
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
516 516
                 }
517 517
 
518 518
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute();
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo $e->getMessage();
532 532
                         die;
533 533
                 }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     * @return Array the spotter information
548 548
     *
549 549
     */
550
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
550
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
551 551
     {
552 552
 	global $globalTimezone, $globalDBdriver;
553 553
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	        
570 570
 		$q_array = explode(" ", $q);
571 571
 		
572
-		foreach ($q_array as $q_item){
572
+		foreach ($q_array as $q_item) {
573 573
 		    $additional_query .= " AND (";
574 574
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
575 575
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	
602 602
 	if ($registration != "")
603 603
 	{
604
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
605 605
 	    if (!is_string($registration))
606 606
 	    {
607 607
 		return false;
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	
613 613
 	if ($aircraft_icao != "")
614 614
 	{
615
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
616 616
 	    if (!is_string($aircraft_icao))
617 617
 	    {
618 618
 		return false;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	
624 624
 	if ($aircraft_manufacturer != "")
625 625
 	{
626
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
627 627
 	    if (!is_string($aircraft_manufacturer))
628 628
 	    {
629 629
 		return false;
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($airline_icao != "")
646 646
 	{
647
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($airline_icao))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($airline_country != "")
657 657
 	{
658
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($airline_country))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($airline_type != "")
668 668
 	{
669
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($airline_type))
671 671
 	    {
672 672
 		return false;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	
689 689
 	if ($airport != "")
690 690
 	{
691
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
692 692
 	    if (!is_string($airport))
693 693
 	    {
694 694
 		return false;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	
700 700
 	if ($airport_country != "")
701 701
 	{
702
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
703 703
 	    if (!is_string($airport_country))
704 704
 	    {
705 705
 		return false;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     
711 711
 	if ($callsign != "")
712 712
 	{
713
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
714 714
 	    if (!is_string($callsign))
715 715
 	    {
716 716
 		return false;
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		$translate = $Translation->ident2icao($callsign);
719 719
 		if ($translate != $callsign) {
720 720
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
721
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
721
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
722 722
 		} else {
723 723
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
724 724
 		}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 	if ($owner != "")
729 729
 	{
730
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
731 731
 	    if (!is_string($owner))
732 732
 	    {
733 733
 		return false;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
 	if ($pilot_name != "")
740 740
 	{
741
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
742 742
 	    if (!is_string($pilot_name))
743 743
 	    {
744 744
 		return false;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	
750 750
 	if ($pilot_id != "")
751 751
 	{
752
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
753 753
 	    if (!is_string($pilot_id))
754 754
 	    {
755 755
 		return false;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	if ($departure_airport_route != "")
762 762
 	{
763
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
764 764
 	    if (!is_string($departure_airport_route))
765 765
 	    {
766 766
 		return false;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	
772 772
 	if ($arrival_airport_route != "")
773 773
 	{
774
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
775 775
 	    if (!is_string($arrival_airport_route))
776 776
 	    {
777 777
 		return false;
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	{
785 785
 	    $altitude_array = explode(",", $altitude);
786 786
 	    
787
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789 789
 	    
790 790
 
791 791
 	    if ($altitude_array[1] != "")
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	{
804 804
 	    $date_array = explode(",", $date_posted);
805 805
 	    
806
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
807
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
806
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
807
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
808 808
 	    
809 809
 	    if ($globalTimezone != '') {
810 810
 		date_default_timezone_set($globalTimezone);
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 	    $limit_array = explode(",", $limit);
838 838
 	    
839
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
840
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
839
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
841 841
 	    
842 842
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
843 843
 	    {
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	
849 849
 
850 850
 	if ($origLat != "" && $origLon != "" && $dist != "") {
851
-		$dist = number_format($dist*0.621371,2,'.','');
852
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
851
+		$dist = number_format($dist*0.621371, 2, '.', '');
852
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
853 853
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
854 854
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
855 855
 	} else {
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
867 867
 		}
868 868
 
869
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
869
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
870 870
 		    WHERE spotter_archive_output.ident <> '' 
871 871
 		    ".$additional_query."
872 872
 		    ".$filter_query.$orderby_query;
873 873
 	}
874
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
874
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
875 875
 
876 876
 	return $spotter_array;
877 877
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                 try {
889 889
                         $sth = $this->db->prepare($query);
890 890
                         $sth->execute();
891
-                } catch(PDOException $e) {
891
+                } catch (PDOException $e) {
892 892
                         return "error";
893 893
                 }
894 894
 	}
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	{
926 926
 	    $limit_array = explode(",", $limit);
927 927
 	    
928
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
928
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
930 930
 	    
931 931
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932 932
 	    {
@@ -983,8 +983,8 @@  discard block
 block discarded – undo
983 983
 	{
984 984
 	    $limit_array = explode(",", $limit);
985 985
 	    
986
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
986
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
987
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
988 988
 	    
989 989
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990 990
 	    {
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	{
1036 1036
 	    $limit_array = explode(",", $limit);
1037 1037
 	    
1038
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1039
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1038
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1039
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1040 1040
 	    
1041 1041
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1042 1042
 	    {
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
     * @return Array the airline country list
1067 1067
     *
1068 1068
     */
1069
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1069
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1070 1070
     {
1071 1071
 	global $globalDBdriver;
1072 1072
 	/*
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 	$flight_array = array();
1096 1096
 	$temp_array = array();
1097 1097
         
1098
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1098
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1099 1099
 	{
1100 1100
 	    $temp_array['flight_count'] = $row['nb'];
1101 1101
 	    $temp_array['flight_country'] = $row['name'];
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
     * @return Array the airline country list
1113 1113
     *
1114 1114
     */
1115
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1115
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1116 1116
     {
1117 1117
 	global $globalDBdriver;
1118 1118
 	/*
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	$flight_array = array();
1142 1142
 	$temp_array = array();
1143 1143
         
1144
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1144
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1145 1145
 	{
1146 1146
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1147 1147
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1159,14 +1159,14 @@  discard block
 block discarded – undo
1159 1159
     * @return Array the spotter information
1160 1160
     *
1161 1161
     */
1162
-    public function getDateArchiveSpotterDataById($id,$date)
1162
+    public function getDateArchiveSpotterDataById($id, $date)
1163 1163
     {
1164 1164
 	$Spotter = new Spotter($this->db);
1165 1165
 	date_default_timezone_set('UTC');
1166 1166
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1167
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1168
-	$date = date('c',$date);
1169
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1167
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1168
+	$date = date('c', $date);
1169
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1170 1170
 	return $spotter_array;
1171 1171
     }
1172 1172
 
@@ -1176,14 +1176,14 @@  discard block
 block discarded – undo
1176 1176
     * @return Array the spotter information
1177 1177
     *
1178 1178
     */
1179
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1179
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1180 1180
     {
1181 1181
 	$Spotter = new Spotter($this->db);
1182 1182
 	date_default_timezone_set('UTC');
1183 1183
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1184
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1185
-	$date = date('c',$date);
1186
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1184
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1185
+	$date = date('c', $date);
1186
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1187 1187
 	return $spotter_array;
1188 1188
     }
1189 1189
 
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
     * @return Array the spotter information
1194 1194
     *
1195 1195
     */
1196
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1196
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1197 1197
     {
1198 1198
 	global $global_query;
1199 1199
 	$Spotter = new Spotter();
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 	$query_values = array();
1202 1202
 	$limit_query = '';
1203 1203
 	$additional_query = '';
1204
-	$filter_query = $this->getFilter($filters,true,true);
1204
+	$filter_query = $this->getFilter($filters, true, true);
1205 1205
 	
1206 1206
 	if ($airport != "")
1207 1207
 	{
@@ -1218,8 +1218,8 @@  discard block
 block discarded – undo
1218 1218
 	{
1219 1219
 	    $limit_array = explode(",", $limit);
1220 1220
 	    
1221
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1222
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1221
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1222
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1223 1223
 	    
1224 1224
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1225 1225
 	    {
Please login to merge, or discard this patch.
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
require/class.Stats.php 2 patches
Spacing   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $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 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $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 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
                 return $all;
126 126
         }
127 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $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 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 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";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 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";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 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";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 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";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			try {
282 282
 				$sth = $this->db->prepare($query);
283 283
 				$sth->execute(array(':filter_name' => $filter_name));
284
-			} catch(PDOException $e) {
284
+			} catch (PDOException $e) {
285 285
 				echo "error : ".$e->getMessage();
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	                $Spotter = new Spotter($this->db);
291 291
             		$filters = array();
292 292
             		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
293
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
296
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
297 297
                 }
298 298
                 return $all;
299 299
 	}
300
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
300
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
301 301
 		global $globalStatsFilters;
302 302
 		if ($filter_name == '') $filter_name = $this->filter_name;
303 303
 		if ($year == '' && $month == '') {
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 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";
306 306
 			try {
307 307
 				$sth = $this->db->prepare($query);
308
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-			} catch(PDOException $e) {
308
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+			} catch (PDOException $e) {
310 310
 				echo "error : ".$e->getMessage();
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
                 if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
317
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
318 318
 			}
319 319
 	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
320
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
321 321
                 }
322 322
                 return $all;
323 323
 	}
324
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
324
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
325 325
 		global $globalStatsFilters;
326 326
 		if ($filter_name == '') $filter_name = $this->filter_name;
327 327
 		if ($year == '' && $month == '') {
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 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";
330 330
 			 try {
331 331
 				$sth = $this->db->prepare($query);
332
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
333
-			} catch(PDOException $e) {
332
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
333
+			} catch (PDOException $e) {
334 334
 				echo "error : ".$e->getMessage();
335 335
 			}
336 336
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		if (empty($all)) {
339 339
 			$filters = array('airlines' => array($stats_airline));
340 340
 			if ($filter_name != '') {
341
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
341
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
342 342
 			}
343 343
 			$Spotter = new Spotter($this->db);
344
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
344
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
345 345
 		}
346 346
 		return $all;
347 347
 	}
348
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
348
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		$Connection = new Connection();
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($Connection->tableExists('countries')) {
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 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";
355 355
 				 try {
356 356
 					$sth = $this->db->prepare($query);
357
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
358
-				} catch(PDOException $e) {
357
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
358
+				} catch (PDOException $e) {
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			return array();
372 372
 		}
373 373
 	}
374
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
374
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
375 375
 		global $globalStatsFilters;
376 376
 		if ($filter_name == '') $filter_name = $this->filter_name;
377 377
 		if ($year == '' && $month == '') {
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 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";
380 380
 			try {
381 381
 				$sth = $this->db->prepare($query);
382
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
383
-			} catch(PDOException $e) {
382
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
383
+			} catch (PDOException $e) {
384 384
 				echo "error : ".$e->getMessage();
385 385
 			}
386 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 		if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
 			if ($filter_name != '') {
391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
 			$Spotter = new Spotter($this->db);
394
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
394
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
395 395
 		}
396 396
 		return $all;
397 397
 	}
398 398
 
399
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
399
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
400 400
 		global $globalStatsFilters;
401 401
 		if ($filter_name == '') $filter_name = $this->filter_name;
402 402
 		if ($year == '' && $month == '') {
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 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";
405 405
 			try {
406 406
 				$sth = $this->db->prepare($query);
407
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
408
-			} catch(PDOException $e) {
407
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
408
+			} catch (PDOException $e) {
409 409
 				echo "error : ".$e->getMessage();
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                 if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
416
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
417 417
 			}
418 418
             		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
419
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
420 420
                 }
421 421
                 return $all;
422 422
 	}
423
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
424 424
 		global $globalStatsFilters;
425 425
 		if ($filter_name == '') $filter_name = $this->filter_name;
426 426
 		if ($year == '' && $month == '') {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 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";
429 429
 			try {
430 430
 				$sth = $this->db->prepare($query);
431
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
432
-			} catch(PDOException $e) {
431
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
432
+			} catch (PDOException $e) {
433 433
 				echo "error : ".$e->getMessage();
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
                 if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
             		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
443
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
444
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
445 445
         		$all = array();
446 446
         		foreach ($pall as $value) {
447 447
         			$icao = $value['airport_departure_icao'];
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
         		foreach ($all as $key => $row) {
459 459
         			$count[$key] = $row['airport_departure_icao_count'];
460 460
         		}
461
-        		array_multisort($count,SORT_DESC,$all);
461
+        		array_multisort($count, SORT_DESC, $all);
462 462
                 }
463 463
                 return $all;
464 464
 	}
465
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
465
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
466 466
 		global $globalStatsFilters;
467 467
 		if ($filter_name == '') $filter_name = $this->filter_name;
468 468
 		if ($year == '' && $month == '') {
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 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";
471 471
 			try {
472 472
 				$sth = $this->db->prepare($query);
473
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
474
-			} catch(PDOException $e) {
473
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
474
+			} catch (PDOException $e) {
475 475
 				echo "error : ".$e->getMessage();
476 476
 			}
477 477
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 		if (empty($all)) {
480 480
 			$filters = array('airlines' => array($stats_airline));
481 481
 			if ($filter_name != '') {
482
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
482
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
483 483
 			}
484 484
 			$Spotter = new Spotter($this->db);
485
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
485
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
486
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
487 487
         		$all = array();
488 488
         		foreach ($pall as $value) {
489 489
         			$icao = $value['airport_arrival_icao'];
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
         		foreach ($all as $key => $row) {
501 501
         			$count[$key] = $row['airport_arrival_icao_count'];
502 502
         		}
503
-        		array_multisort($count,SORT_DESC,$all);
503
+        		array_multisort($count, SORT_DESC, $all);
504 504
                 }
505 505
  
506 506
                 return $all;
507 507
 	}
508
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
508
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
510 510
 		if ($filter_name == '') $filter_name = $this->filter_name;
511 511
 		if ($globalDBdriver == 'mysql') {
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 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 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";
517 517
 		}
518
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
519 519
                  try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute($query_data);
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo "error : ".$e->getMessage();
524 524
                 }
525 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526 526
                 if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
530 530
 			}
531 531
             		$Spotter = new Spotter($this->db);
532 532
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
                 return $all;
536 536
 	}
537 537
 	
538
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
538
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
539 539
 		global $globalStatsFilters;
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLastMonth($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
560
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		if ($globalDBdriver == 'mysql') {
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		} else {
566 566
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
567 567
 		}
568
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
568
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
569 569
                  try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute($query_data);
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo "error : ".$e->getMessage();
574 574
                 }
575 575
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576 576
                 if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
             		$Spotter = new Spotter($this->db);
582 582
             		$all = $Spotter->countAllDatesLast7Days($filters);
583 583
                 }
584 584
                 return $all;
585 585
 	}
586
-	public function countAllDates($stats_airline = '',$filter_name = '') {
586
+	public function countAllDates($stats_airline = '', $filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
590
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
591 591
                  try {
592 592
                         $sth = $this->db->prepare($query);
593 593
                         $sth->execute($query_data);
594
-                } catch(PDOException $e) {
594
+                } catch (PDOException $e) {
595 595
                         echo "error : ".$e->getMessage();
596 596
                 }
597 597
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598 598
                 if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
602 602
 			}
603 603
             		$Spotter = new Spotter($this->db);
604 604
             		$all = $Spotter->countAllDates($filters);
@@ -613,28 +613,28 @@  discard block
 block discarded – undo
613 613
                  try {
614 614
                         $sth = $this->db->prepare($query);
615 615
                         $sth->execute($query_data);
616
-                } catch(PDOException $e) {
616
+                } catch (PDOException $e) {
617 617
                         echo "error : ".$e->getMessage();
618 618
                 }
619 619
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620 620
                 if (empty($all)) {
621 621
             		$filters = array();
622 622
             		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
623
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
624 624
 			}
625 625
             		$Spotter = new Spotter($this->db);
626 626
             		$all = $Spotter->countAllDatesByAirlines($filters);
627 627
                 }
628 628
                 return $all;
629 629
 	}
630
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
630
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633 633
 	    	$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 634
                  try {
635 635
                         $sth = $this->db->prepare($query);
636 636
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
637
+                } catch (PDOException $e) {
638 638
                         echo "error : ".$e->getMessage();
639 639
                 }
640 640
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                 if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
646 646
 			}
647 647
             		$Spotter = new Spotter($this->db);
648 648
             		$all = $Spotter->countAllMonths($filters);
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
                  try {
658 658
                         $sth = $this->db->prepare($query);
659 659
                         $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
660
+                } catch (PDOException $e) {
661 661
                         echo "error : ".$e->getMessage();
662 662
                 }
663 663
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664 664
                 if (empty($all)) {
665 665
             		$filters = array();
666 666
             		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
667
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
668 668
 			}
669 669
             		$Spotter = new Spotter($this->db);
670 670
             		$all = $Spotter->countAllMilitaryMonths($filters);
671 671
                 }
672 672
                 return $all;
673 673
 	}
674
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
674
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676 676
 		if ($filter_name == '') $filter_name = $this->filter_name;
677 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";
@@ -688,82 +688,82 @@  discard block
 block discarded – undo
688 688
                  try {
689 689
                         $sth = $this->db->prepare($query);
690 690
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
691
+                } catch (PDOException $e) {
692 692
                         echo "error : ".$e->getMessage();
693 693
                 }
694 694
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695 695
                 if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
699 699
 			}
700 700
             		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
701
+            		$all = $Spotter->countAllHours($orderby, $filters);
702 702
                 }
703 703
                 return $all;
704 704
 	}
705 705
 	
706
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
706
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
707 707
 		global $globalStatsFilters;
708 708
 		if ($filter_name == '') $filter_name = $this->filter_name;
709 709
 		if ($year == '') $year = date('Y');
710
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
710
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
711 711
 		if (empty($all)) {
712 712
 			$filters = array('airlines' => array($stats_airline));
713 713
 			if ($filter_name != '') {
714
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
714
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
715 715
 			}
716 716
 			$Spotter = new Spotter($this->db);
717
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
717
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
718 718
 		}
719 719
 		return $all;
720 720
 	}
721
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
721
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
722 722
 		global $globalStatsFilters;
723 723
 		if ($filter_name == '') $filter_name = $this->filter_name;
724 724
 		if ($year == '') $year = date('Y');
725
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
725
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
726 726
 		if (empty($all)) {
727 727
 		        $filters = array();
728 728
             		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
729
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
732
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
733 733
 		}
734 734
 		return $all;
735 735
 	}
736
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
736
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
737 737
 		global $globalStatsFilters;
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739 739
 		if ($year == '') $year = date('Y');
740
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
740
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
741 741
 		if (empty($all)) {
742 742
 			$filters = array('airlines' => array($stats_airline));
743 743
 			if ($filter_name != '') {
744
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
744
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
745 745
 			}
746 746
 			$Spotter = new Spotter($this->db);
747
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
747
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
748 748
 		}
749 749
 		return $all;
750 750
 	}
751
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
751
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
752 752
 		global $globalStatsFilters;
753 753
 		if ($filter_name == '') $filter_name = $this->filter_name;
754 754
 		if ($year == '') $year = date('Y');
755
-		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
755
+		$all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
756 756
 		if (empty($all)) {
757 757
 			$filters = array('airlines' => array($stats_airline));
758 758
 			if ($filter_name != '') {
759
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
759
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
760 760
 			}
761 761
 			$Spotter = new Spotter($this->db);
762
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
762
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
763 763
 		}
764 764
 		return $all;
765 765
 	}
766
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
766
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
767 767
 		global $globalStatsFilters;
768 768
 		if ($filter_name == '') $filter_name = $this->filter_name;
769 769
 		if ($year == '' && $month == '') {
@@ -771,23 +771,23 @@  discard block
 block discarded – undo
771 771
 			try {
772 772
 				$sth = $this->db->prepare($query);
773 773
 				$sth->execute(array(':filter_name' => $filter_name));
774
-			} catch(PDOException $e) {
774
+			} catch (PDOException $e) {
775 775
 				echo "error : ".$e->getMessage();
776 776
 			}
777 777
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
778 778
 			$all = $result[0]['nb_airline'];
779
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
779
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
780 780
 		if (empty($all)) {
781 781
             		$filters = array();
782 782
             		if ($filter_name != '') {
783
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
783
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
784 784
 			}
785 785
 			$Spotter = new Spotter($this->db);
786
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
786
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
787 787
 		}
788 788
 		return $all;
789 789
 	}
790
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
790
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
791 791
 		global $globalStatsFilters;
792 792
 		if ($filter_name == '') $filter_name = $this->filter_name;
793 793
 		if ($year == '') $year = date('Y');
@@ -802,83 +802,83 @@  discard block
 block discarded – undo
802 802
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
803 803
                 $all = $result[0]['nb_owner'];
804 804
                 */
805
-		$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
805
+		$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
806 806
 		if (empty($all)) {
807 807
 			$filters = array('airlines' => array($stats_airline));
808 808
 			if ($filter_name != '') {
809
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
809
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
810 810
 			}
811 811
 			$Spotter = new Spotter($this->db);
812
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
812
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
813 813
 		}
814 814
 		return $all;
815 815
 	}
816
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
816
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
817 817
 		global $globalStatsFilters;
818 818
 		if ($filter_name == '') $filter_name = $this->filter_name;
819 819
 		if ($year == '') $year = date('Y');
820
-		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
820
+		$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
821 821
 		if (empty($all)) {
822 822
 			$filters = array('airlines' => array($stats_airline));
823 823
 			if ($filter_name != '') {
824
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
824
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
825 825
 			}
826 826
 			$Spotter = new Spotter($this->db);
827
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
827
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
828 828
 		}
829 829
 		return $all;
830 830
 	}
831 831
 
832
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
832
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
833 833
 		if ($filter_name == '') $filter_name = $this->filter_name;
834 834
 		$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
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
835
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836 836
                  try {
837 837
                         $sth = $this->db->prepare($query);
838 838
                         $sth->execute($query_values);
839
-                } catch(PDOException $e) {
839
+                } catch (PDOException $e) {
840 840
                         echo "error : ".$e->getMessage();
841 841
                 }
842 842
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
843 843
                 return $all;
844 844
 	}
845
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
845
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
846 846
 		if ($filter_name == '') $filter_name = $this->filter_name;
847 847
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
848
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
849 849
                  try {
850 850
                         $sth = $this->db->prepare($query);
851 851
                         $sth->execute($query_values);
852
-                } catch(PDOException $e) {
852
+                } catch (PDOException $e) {
853 853
                         echo "error : ".$e->getMessage();
854 854
                 }
855 855
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
856 856
                 return $all;
857 857
         }
858
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
858
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
859 859
 		if ($filter_name == '') $filter_name = $this->filter_name;
860 860
     		global $globalArchiveMonths, $globalDBdriver;
861 861
     		if ($globalDBdriver == 'mysql') {
862 862
     			if ($month == '') {
863 863
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
864
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
864
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
865 865
 			} else {
866 866
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
867
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
867
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
868 868
 			}
869 869
 		} else {
870 870
 			if ($month == '') {
871 871
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
872
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
873 873
 			} else {
874 874
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
875
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
875
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
876 876
 			}
877 877
                 }
878 878
                  try {
879 879
                         $sth = $this->db->prepare($query);
880 880
                         $sth->execute($query_values);
881
-                } catch(PDOException $e) {
881
+                } catch (PDOException $e) {
882 882
                         echo "error : ".$e->getMessage();
883 883
                 }
884 884
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
                  try {
897 897
                         $sth = $this->db->prepare($query);
898 898
                         $sth->execute($query_values);
899
-                } catch(PDOException $e) {
899
+                } catch (PDOException $e) {
900 900
                         echo "error : ".$e->getMessage();
901 901
                 }
902 902
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
                  try {
914 914
                         $sth = $this->db->prepare($query);
915 915
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
-                } catch(PDOException $e) {
916
+                } catch (PDOException $e) {
917 917
                         echo "error : ".$e->getMessage();
918 918
                 }
919 919
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                  try {
931 931
                         $sth = $this->db->prepare($query);
932 932
                         $sth->execute(array(':filter_name' => $filter_name));
933
-                } catch(PDOException $e) {
933
+                } catch (PDOException $e) {
934 934
                         echo "error : ".$e->getMessage();
935 935
                 }
936 936
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                  try {
948 948
                         $sth = $this->db->prepare($query);
949 949
                         $sth->execute(array(':filter_name' => $filter_name));
950
-                } catch(PDOException $e) {
950
+                } catch (PDOException $e) {
951 951
                         echo "error : ".$e->getMessage();
952 952
                 }
953 953
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
                  try {
965 965
                         $sth = $this->db->prepare($query);
966 966
                         $sth->execute(array(':filter_name' => $filter_name));
967
-                } catch(PDOException $e) {
967
+                } catch (PDOException $e) {
968 968
                         echo "error : ".$e->getMessage();
969 969
                 }
970 970
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
971 971
                 return $all[0]['total'];
972 972
         }
973 973
 
974
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
974
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
975 975
 		global $globalDBdriver;
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
 		if ($globalDBdriver == 'mysql') {
@@ -979,15 +979,15 @@  discard block
 block discarded – undo
979 979
                 } else {
980 980
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
981 981
 		}
982
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
982
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
983 983
                  try {
984 984
                         $sth = $this->db->prepare($query);
985 985
                         $sth->execute($query_values);
986
-                } catch(PDOException $e) {
986
+                } catch (PDOException $e) {
987 987
                         return "error : ".$e->getMessage();
988 988
                 }
989 989
         }
990
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
990
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
991 991
 		global $globalDBdriver;
992 992
 		if ($filter_name == '') $filter_name = $this->filter_name;
993 993
 		if ($globalDBdriver == 'mysql') {
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
997 997
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
998 998
                 }
999
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
999
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1000 1000
                  try {
1001 1001
                         $sth = $this->db->prepare($query);
1002 1002
                         $sth->execute($query_values);
1003
-                } catch(PDOException $e) {
1003
+                } catch (PDOException $e) {
1004 1004
                         return "error : ".$e->getMessage();
1005 1005
                 }
1006 1006
         }
@@ -1024,75 +1024,75 @@  discard block
 block discarded – undo
1024 1024
         }
1025 1025
         */
1026 1026
 
1027
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1027
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1028 1028
 		global $globalDBdriver;
1029 1029
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1030 1030
 		$query_values = array();
1031 1031
 		if ($globalDBdriver == 'mysql') {
1032 1032
 			if ($year != '') {
1033 1033
 				$query .= ' AND YEAR(stats_date) = :year';
1034
-				$query_values = array_merge($query_values,array(':year' => $year));
1034
+				$query_values = array_merge($query_values, array(':year' => $year));
1035 1035
 			}
1036 1036
 			if ($month != '') {
1037 1037
 				$query .= ' AND MONTH(stats_date) = :month';
1038
-				$query_values = array_merge($query_values,array(':month' => $month));
1038
+				$query_values = array_merge($query_values, array(':month' => $month));
1039 1039
 			}
1040 1040
 			if ($day != '') {
1041 1041
 				$query .= ' AND DAY(stats_date) = :day';
1042
-				$query_values = array_merge($query_values,array(':day' => $day));
1042
+				$query_values = array_merge($query_values, array(':day' => $day));
1043 1043
 			}
1044 1044
 		} else {
1045 1045
 			if ($year != '') {
1046 1046
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1047
-				$query_values = array_merge($query_values,array(':year' => $year));
1047
+				$query_values = array_merge($query_values, array(':year' => $year));
1048 1048
 			}
1049 1049
 			if ($month != '') {
1050 1050
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1051
-				$query_values = array_merge($query_values,array(':month' => $month));
1051
+				$query_values = array_merge($query_values, array(':month' => $month));
1052 1052
 			}
1053 1053
 			if ($day != '') {
1054 1054
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1055
-				$query_values = array_merge($query_values,array(':day' => $day));
1055
+				$query_values = array_merge($query_values, array(':day' => $day));
1056 1056
 			}
1057 1057
 		}
1058 1058
 		$query .= " ORDER BY source_name";
1059
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1059
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1060 1060
 		try {
1061 1061
 			$sth = $this->db->prepare($query);
1062 1062
 			$sth->execute($query_values);
1063
-		} catch(PDOException $e) {
1063
+		} catch (PDOException $e) {
1064 1064
 			echo "error : ".$e->getMessage();
1065 1065
 		}
1066 1066
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1067 1067
 		return $all;
1068 1068
 	}
1069 1069
 
1070
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1070
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1071 1071
 		global $globalDBdriver;
1072 1072
 		if ($globalDBdriver == 'mysql') {
1073 1073
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1074 1074
 		} else {
1075 1075
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1076 1076
                 }
1077
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1077
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1078 1078
                  try {
1079 1079
                         $sth = $this->db->prepare($query);
1080 1080
                         $sth->execute($query_values);
1081
-                } catch(PDOException $e) {
1081
+                } catch (PDOException $e) {
1082 1082
                         return "error : ".$e->getMessage();
1083 1083
                 }
1084 1084
         }
1085
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1085
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1086 1086
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1087
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1088 1088
                  try {
1089 1089
                         $sth = $this->db->prepare($query);
1090 1090
                         $sth->execute($query_values);
1091
-                } catch(PDOException $e) {
1091
+                } catch (PDOException $e) {
1092 1092
                         return "error : ".$e->getMessage();
1093 1093
                 }
1094 1094
         }
1095
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1095
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1096 1096
 		global $globalDBdriver;
1097 1097
 		if ($globalDBdriver == 'mysql') {
1098 1098
 			if ($reset) {
@@ -1107,15 +1107,15 @@  discard block
 block discarded – undo
1107 1107
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1108 1108
 			}
1109 1109
 		}
1110
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1110
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111 1111
                  try {
1112 1112
                         $sth = $this->db->prepare($query);
1113 1113
                         $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1114
+                } catch (PDOException $e) {
1115 1115
                         return "error : ".$e->getMessage();
1116 1116
                 }
1117 1117
         }
1118
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1118
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
1121 1121
 			if ($reset) {
@@ -1130,15 +1130,15 @@  discard block
 block discarded – undo
1130 1130
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1133
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1134 1134
                  try {
1135 1135
                         $sth = $this->db->prepare($query);
1136 1136
                         $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1137
+                } catch (PDOException $e) {
1138 1138
                         return "error : ".$e->getMessage();
1139 1139
                 }
1140 1140
         }
1141
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1141
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
1144 1144
 			if ($reset) {
@@ -1153,15 +1153,15 @@  discard block
 block discarded – undo
1153 1153
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1156
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1157 1157
                  try {
1158 1158
                         $sth = $this->db->prepare($query);
1159 1159
                         $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1160
+                } catch (PDOException $e) {
1161 1161
                         return "error : ".$e->getMessage();
1162 1162
                 }
1163 1163
         }
1164
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1164
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
1167 1167
 			if ($reset) {
@@ -1176,15 +1176,15 @@  discard block
 block discarded – undo
1176 1176
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1179
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1180 1180
                  try {
1181 1181
                         $sth = $this->db->prepare($query);
1182 1182
                         $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1183
+                } catch (PDOException $e) {
1184 1184
                         return "error : ".$e->getMessage();
1185 1185
                 }
1186 1186
         }
1187
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1187
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
1190 1190
 			if ($reset) {
@@ -1199,15 +1199,15 @@  discard block
 block discarded – undo
1199 1199
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1202
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1203 1203
                  try {
1204 1204
                         $sth = $this->db->prepare($query);
1205 1205
                         $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1206
+                } catch (PDOException $e) {
1207 1207
                         return "error : ".$e->getMessage();
1208 1208
                 }
1209 1209
         }
1210
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1210
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
1213 1213
 			if ($reset) {
@@ -1222,15 +1222,15 @@  discard block
 block discarded – undo
1222 1222
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1225
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1226 1226
                  try {
1227 1227
                         $sth = $this->db->prepare($query);
1228 1228
                         $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1229
+                } catch (PDOException $e) {
1230 1230
                         return "error : ".$e->getMessage();
1231 1231
                 }
1232 1232
         }
1233
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1233
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
1236 1236
 			if ($reset) {
@@ -1245,15 +1245,15 @@  discard block
 block discarded – undo
1245 1245
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1248
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1249 1249
                  try {
1250 1250
                         $sth = $this->db->prepare($query);
1251 1251
                         $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1252
+                } catch (PDOException $e) {
1253 1253
                         return "error : ".$e->getMessage();
1254 1254
                 }
1255 1255
         }
1256
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1256
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($airport_icao != '') {
1259 1259
 			if ($globalDBdriver == 'mysql') {
@@ -1269,16 +1269,16 @@  discard block
 block discarded – undo
1269 1269
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1270 1270
 				}
1271 1271
 			}
1272
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1272
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1273 1273
 			try {
1274 1274
 				$sth = $this->db->prepare($query);
1275 1275
 				$sth->execute($query_values);
1276
-			} catch(PDOException $e) {
1276
+			} catch (PDOException $e) {
1277 1277
 				return "error : ".$e->getMessage();
1278 1278
 			}
1279 1279
                 }
1280 1280
         }
1281
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1281
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1282 1282
 		global $globalDBdriver;
1283 1283
 		if ($airport_icao != '') {
1284 1284
 			if ($globalDBdriver == 'mysql') {
@@ -1286,16 +1286,16 @@  discard block
 block discarded – undo
1286 1286
 			} else {
1287 1287
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1288 1288
 			}
1289
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1289
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1290 1290
 			 try {
1291 1291
 				$sth = $this->db->prepare($query);
1292 1292
 				$sth->execute($query_values);
1293
-			} catch(PDOException $e) {
1293
+			} catch (PDOException $e) {
1294 1294
 				return "error : ".$e->getMessage();
1295 1295
 			}
1296 1296
                 }
1297 1297
         }
1298
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1298
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1299 1299
 		global $globalDBdriver;
1300 1300
 		if ($airport_icao != '') {
1301 1301
 			if ($globalDBdriver == 'mysql') {
@@ -1311,16 +1311,16 @@  discard block
 block discarded – undo
1311 1311
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1312 1312
 				}
1313 1313
 			}
1314
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1314
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1315 1315
 			 try {
1316 1316
                     		$sth = $this->db->prepare($query);
1317 1317
 	                        $sth->execute($query_values);
1318
-    		        } catch(PDOException $e) {
1318
+    		        } catch (PDOException $e) {
1319 1319
             		        return "error : ".$e->getMessage();
1320 1320
 	                }
1321 1321
 	        }
1322 1322
         }
1323
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1323
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1324 1324
 		global $globalDBdriver;
1325 1325
 		if ($airport_icao != '') {
1326 1326
 			if ($globalDBdriver == 'mysql') {
@@ -1328,11 +1328,11 @@  discard block
 block discarded – undo
1328 1328
 			} else {
1329 1329
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1330 1330
 			}
1331
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1331
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1332 1332
 			try {
1333 1333
 				$sth = $this->db->prepare($query);
1334 1334
 				$sth->execute($query_values);
1335
-			} catch(PDOException $e) {
1335
+			} catch (PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338 1338
                 }
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
                  try {
1345 1345
                         $sth = $this->db->prepare($query);
1346 1346
                         $sth->execute($query_values);
1347
-                } catch(PDOException $e) {
1347
+                } catch (PDOException $e) {
1348 1348
                         return "error : ".$e->getMessage();
1349 1349
                 }
1350 1350
         }
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                  try {
1355 1355
                         $sth = $this->db->prepare($query);
1356 1356
                         $sth->execute($query_values);
1357
-                } catch(PDOException $e) {
1357
+                } catch (PDOException $e) {
1358 1358
                         return "error : ".$e->getMessage();
1359 1359
                 }
1360 1360
         }
@@ -1364,13 +1364,13 @@  discard block
 block discarded – undo
1364 1364
                  try {
1365 1365
                         $sth = $this->db->prepare($query);
1366 1366
                         $sth->execute($query_values);
1367
-                } catch(PDOException $e) {
1367
+                } catch (PDOException $e) {
1368 1368
                         return "error : ".$e->getMessage();
1369 1369
                 }
1370 1370
         }
1371 1371
         
1372 1372
         public function addOldStats() {
1373
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1373
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1374 1374
     		$Common = new Common();
1375 1375
     		$Connection = new Connection();
1376 1376
     		date_default_timezone_set('UTC');
@@ -1387,40 +1387,40 @@  discard block
 block discarded – undo
1387 1387
 			$Spotter = new Spotter($this->db);
1388 1388
 
1389 1389
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1390
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1390
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1391 1391
 			foreach ($alldata as $number) {
1392
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1392
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1393 1393
 			}
1394 1394
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1395
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1395
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1396 1396
 			foreach ($alldata as $number) {
1397
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1397
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1398 1398
 			}
1399 1399
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1400
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1400
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1401 1401
 			foreach ($alldata as $number) {
1402
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1402
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1403 1403
 			}
1404 1404
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1405
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1405
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1406 1406
 			foreach ($alldata as $number) {
1407
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1407
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1408 1408
 			}
1409 1409
 			if ($globalDebug) echo 'Count all owners...'."\n";
1410
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1410
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1411 1411
 			foreach ($alldata as $number) {
1412
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1412
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1413 1413
 			}
1414 1414
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1415
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1415
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1416 1416
 			foreach ($alldata as $number) {
1417
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1417
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1418 1418
 			}
1419 1419
 			
1420 1420
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1421
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1421
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1422 1422
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1423
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1423
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1424 1424
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1425 1425
 	        	$alldata = array();
1426 1426
 	        	
@@ -1438,14 +1438,14 @@  discard block
 block discarded – undo
1438 1438
     			foreach ($alldata as $key => $row) {
1439 1439
     				$count[$key] = $row['airport_departure_icao_count'];
1440 1440
         		}
1441
-			array_multisort($count,SORT_DESC,$alldata);
1441
+			array_multisort($count, SORT_DESC, $alldata);
1442 1442
 			foreach ($alldata as $number) {
1443
-				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);
1443
+				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 1444
 			}
1445 1445
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1446
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1446
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1447 1447
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1448
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1448
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1449 1449
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1450 1450
 	        	$alldata = array();
1451 1451
     			foreach ($pall as $value) {
@@ -1462,16 +1462,16 @@  discard block
 block discarded – undo
1462 1462
         		foreach ($alldata as $key => $row) {
1463 1463
         			$count[$key] = $row['airport_arrival_icao_count'];
1464 1464
 	        	}
1465
-    			array_multisort($count,SORT_DESC,$alldata);
1465
+    			array_multisort($count, SORT_DESC, $alldata);
1466 1466
                         foreach ($alldata as $number) {
1467
-				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);
1467
+				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 1468
 			}
1469 1469
 			if ($Connection->tableExists('countries')) {
1470 1470
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1471 1471
 				$SpotterArchive = new SpotterArchive();
1472
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1472
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1473 1473
 				foreach ($alldata as $number) {
1474
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1474
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1475 1475
 				}
1476 1476
 			}
1477 1477
 			
@@ -1485,37 +1485,37 @@  discard block
 block discarded – undo
1485 1485
 			$lastyear = false;
1486 1486
 			foreach ($alldata as $number) {
1487 1487
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1488
-				$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'])));
1488
+				$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 1489
 			}
1490 1490
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1491 1491
 			$alldata = $Spotter->countAllMilitaryMonths();
1492 1492
 			foreach ($alldata as $number) {
1493
-				$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'])));
1493
+				$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 1494
 			}
1495 1495
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1496 1496
 			$alldata = $Spotter->countAllMonthsOwners();
1497 1497
 			foreach ($alldata as $number) {
1498
-				$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'])));
1498
+				$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 1499
 			}
1500 1500
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1501 1501
 			$alldata = $Spotter->countAllMonthsPilots();
1502 1502
 			foreach ($alldata as $number) {
1503
-				$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'])));
1503
+				$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 1504
 			}
1505 1505
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1506 1506
 			$alldata = $Spotter->countAllMonthsAirlines();
1507 1507
 			foreach ($alldata as $number) {
1508
-				$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'])));
1508
+				$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 1509
 			}
1510 1510
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1511 1511
 			$alldata = $Spotter->countAllMonthsAircrafts();
1512 1512
 			foreach ($alldata as $number) {
1513
-				$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'])));
1513
+				$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 1514
 			}
1515 1515
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1516 1516
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1517 1517
 			foreach ($alldata as $number) {
1518
-				$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'])));
1518
+				$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 1519
 			}
1520 1520
 			if ($globalDebug) echo 'Airports data...'."\n";
1521 1521
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
     			}
1561 1561
     			$alldata = $pall;
1562 1562
 			foreach ($alldata as $number) {
1563
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1563
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1564 1564
 			}
1565 1565
 			echo '...Arrival'."\n";
1566 1566
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
     			}
1603 1603
     			$alldata = $pall;
1604 1604
 			foreach ($alldata as $number) {
1605
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1605
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1606 1606
 			}
1607 1607
 
1608 1608
 			echo 'Flights data...'."\n";
@@ -1610,28 +1610,28 @@  discard block
 block discarded – undo
1610 1610
 			echo '-> countAllDatesLastMonth...'."\n";
1611 1611
 			$alldata = $Spotter->countAllDatesLastMonth();
1612 1612
 			foreach ($alldata as $number) {
1613
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1613
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1614 1614
 			}
1615 1615
 			echo '-> countAllDates...'."\n";
1616 1616
 			$previousdata = $this->countAllDates();
1617 1617
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1618 1618
 			$this->deleteStatFlight('date');
1619
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1619
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1620 1620
 			$values = array();
1621 1621
 			foreach ($alldata as $cnt) {
1622 1622
 				$values[] = $cnt['date_count'];
1623 1623
 			}
1624
-			array_multisort($values,SORT_DESC,$alldata);
1625
-			array_splice($alldata,11);
1624
+			array_multisort($values, SORT_DESC, $alldata);
1625
+			array_splice($alldata, 11);
1626 1626
 			foreach ($alldata as $number) {
1627
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1627
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1628 1628
 			}
1629 1629
 			
1630 1630
 			$this->deleteStatFlight('hour');
1631 1631
 			echo '-> countAllHours...'."\n";
1632 1632
 			$alldata = $Spotter->countAllHours('hour');
1633 1633
 			foreach ($alldata as $number) {
1634
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1634
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1635 1635
 			}
1636 1636
 
1637 1637
 
@@ -1641,41 +1641,41 @@  discard block
 block discarded – undo
1641 1641
 			if ($Connection->tableExists('countries')) {
1642 1642
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1643 1643
 				$SpotterArchive = new SpotterArchive();
1644
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1644
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1645 1645
 				foreach ($alldata as $number) {
1646
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1646
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1647 1647
 				}
1648 1648
 			}
1649 1649
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1650 1650
 			$Spotter = new Spotter($this->db);
1651
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1651
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1652 1652
 			foreach ($alldata as $number) {
1653
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1653
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1654 1654
 			}
1655 1655
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1656
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1656
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1657 1657
 			foreach ($alldata as $number) {
1658
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1658
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1659 1659
 			}
1660 1660
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1661
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1661
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1662 1662
 			foreach ($alldata as $number) {
1663
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1663
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1664 1664
 			}
1665 1665
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1666
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1666
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1667 1667
 			foreach ($alldata as $number) {
1668
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1668
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1669 1669
 			}
1670 1670
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1671
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1671
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1672 1672
 			foreach ($alldata as $number) {
1673
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1673
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1674 1674
 			}
1675 1675
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1676
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1676
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1677 1677
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1678
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1678
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1679 1679
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1680 1680
 	        	//$alldata = array();
1681 1681
     			foreach ($dall as $value) {
@@ -1695,12 +1695,12 @@  discard block
 block discarded – undo
1695 1695
     			}
1696 1696
     			$alldata = $pall;
1697 1697
 			foreach ($alldata as $number) {
1698
-				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);
1698
+				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 1699
 			}
1700 1700
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1701
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1701
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1702 1702
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1703
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1703
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1704 1704
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1705 1705
 	        	//$alldata = array();
1706 1706
     			foreach ($dall as $value) {
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
     			}
1721 1721
     			$alldata = $pall;
1722 1722
                         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);
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);
1724 1724
 			}
1725 1725
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1726 1726
 			$Spotter = new Spotter($this->db);
@@ -1728,27 +1728,27 @@  discard block
 block discarded – undo
1728 1728
 			$lastyear = false;
1729 1729
 			foreach ($alldata as $number) {
1730 1730
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1731
-				$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']);
1731
+				$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 1732
 			}
1733 1733
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1734 1734
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1735 1735
 			foreach ($alldata as $number) {
1736
-				$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']);
1736
+				$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 1737
 			}
1738 1738
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1739 1739
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1740 1740
 			foreach ($alldata as $number) {
1741
-				$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']);
1741
+				$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 1742
 			}
1743 1743
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1744 1744
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1745 1745
 			foreach ($alldata as $number) {
1746
-				$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']);
1746
+				$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 1747
 			}
1748 1748
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1749 1749
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1750 1750
 			foreach ($alldata as $number) {
1751
-				$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']);
1751
+				$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 1752
 			}
1753 1753
 			if ($globalDebug) echo '...Departure'."\n";
1754 1754
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
     			}
1772 1772
     			$alldata = $pall;
1773 1773
 			foreach ($alldata as $number) {
1774
-				$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']);
1774
+				$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 1775
 			}
1776 1776
 			if ($globalDebug) echo '...Arrival'."\n";
1777 1777
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1794,32 +1794,32 @@  discard block
 block discarded – undo
1794 1794
     			}
1795 1795
     			$alldata = $pall;
1796 1796
 			foreach ($alldata as $number) {
1797
-				$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']);
1797
+				$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 1798
 			}
1799 1799
 
1800 1800
 			if ($globalDebug) echo 'Flights data...'."\n";
1801 1801
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1802 1802
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1803 1803
 			foreach ($alldata as $number) {
1804
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1804
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1805 1805
 			}
1806 1806
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1807 1807
 			//$previousdata = $this->countAllDatesByAirlines();
1808
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1808
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1809 1809
 			$values = array();
1810 1810
 			foreach ($alldata as $cnt) {
1811 1811
 				$values[] = $cnt['date_count'];
1812 1812
 			}
1813
-			array_multisort($values,SORT_DESC,$alldata);
1814
-			array_splice($alldata,11);
1813
+			array_multisort($values, SORT_DESC, $alldata);
1814
+			array_splice($alldata, 11);
1815 1815
 			foreach ($alldata as $number) {
1816
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1816
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1817 1817
 			}
1818 1818
 			
1819 1819
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1820 1820
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1821 1821
 			foreach ($alldata as $number) {
1822
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1822
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1823 1823
 			}
1824 1824
 			
1825 1825
 
@@ -1838,32 +1838,32 @@  discard block
 block discarded – undo
1838 1838
 				// Count by filter
1839 1839
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1840 1840
 				$Spotter = new Spotter($this->db);
1841
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1841
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1842 1842
 				foreach ($alldata as $number) {
1843
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1843
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1844 1844
 				}
1845
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1845
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1846 1846
 				foreach ($alldata as $number) {
1847
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1847
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1848 1848
 				}
1849
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1849
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1850 1850
 				foreach ($alldata as $number) {
1851
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1851
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1852 1852
 				}
1853
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1853
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1854 1854
 				foreach ($alldata as $number) {
1855
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1855
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1856 1856
 				}
1857
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1857
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1858 1858
 				foreach ($alldata as $number) {
1859
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1859
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1860 1860
 				}
1861
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1861
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1862 1862
 				foreach ($alldata as $number) {
1863
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1863
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1864 1864
 				}
1865
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1866
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1865
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1866
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1867 1867
 		        	$alldata = array();
1868 1868
 	    			foreach ($pall as $value) {
1869 1869
 		        		$icao = $value['airport_departure_icao'];
@@ -1879,12 +1879,12 @@  discard block
 block discarded – undo
1879 1879
     				foreach ($alldata as $key => $row) {
1880 1880
     					$count[$key] = $row['airport_departure_icao_count'];
1881 1881
     				}
1882
-				array_multisort($count,SORT_DESC,$alldata);
1882
+				array_multisort($count, SORT_DESC, $alldata);
1883 1883
 				foreach ($alldata as $number) {
1884
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1884
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
1885 1885
 				}
1886
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1887
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1886
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1887
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1888 1888
 				$alldata = array();
1889 1889
     				foreach ($pall as $value) {
1890 1890
 		        		$icao = $value['airport_arrival_icao'];
@@ -1900,40 +1900,40 @@  discard block
 block discarded – undo
1900 1900
         			foreach ($alldata as $key => $row) {
1901 1901
     					$count[$key] = $row['airport_arrival_icao_count'];
1902 1902
 		        	}
1903
-        			array_multisort($count,SORT_DESC,$alldata);
1903
+        			array_multisort($count, SORT_DESC, $alldata);
1904 1904
 				foreach ($alldata as $number) {
1905
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1905
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
1906 1906
 				}
1907 1907
 				$Spotter = new Spotter($this->db);
1908 1908
 				$alldata = $Spotter->countAllMonths($filter);
1909 1909
 				$lastyear = false;
1910 1910
 				foreach ($alldata as $number) {
1911 1911
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1912
-					$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);
1912
+					$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 1913
 				}
1914 1914
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1915 1915
 				foreach ($alldata as $number) {
1916
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1916
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1917 1917
 				}
1918 1918
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1919 1919
 				foreach ($alldata as $number) {
1920
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1920
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1921 1921
 				}
1922 1922
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1923 1923
 				foreach ($alldata as $number) {
1924
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1924
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1925 1925
 				}
1926 1926
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1927 1927
 				foreach ($alldata as $number) {
1928
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1928
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1929 1929
 				}
1930 1930
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1931 1931
 				foreach ($alldata as $number) {
1932
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1932
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1933 1933
 				}
1934 1934
 				echo '...Departure'."\n";
1935
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1936
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1935
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1936
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1937 1937
 				foreach ($dall as $value) {
1938 1938
     					$icao = $value['departure_airport_icao'];
1939 1939
     					$ddate = $value['date'];
@@ -1951,11 +1951,11 @@  discard block
 block discarded – undo
1951 1951
     				}
1952 1952
 	    			$alldata = $pall;
1953 1953
 				foreach ($alldata as $number) {
1954
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1954
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
1955 1955
 				}
1956 1956
 				echo '...Arrival'."\n";
1957
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1958
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1957
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1958
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1959 1959
 				foreach ($dall as $value) {
1960 1960
 					$icao = $value['arrival_airport_icao'];
1961 1961
 					$ddate = $value['date'];
@@ -1973,40 +1973,40 @@  discard block
 block discarded – undo
1973 1973
     				}
1974 1974
     				$alldata = $pall;
1975 1975
 				foreach ($alldata as $number) {
1976
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1976
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
1977 1977
 				}
1978 1978
     
1979 1979
 				echo 'Flights data...'."\n";
1980 1980
 				echo '-> countAllDatesLastMonth...'."\n";
1981 1981
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1982 1982
 				foreach ($alldata as $number) {
1983
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1983
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1984 1984
 				}
1985 1985
 				echo '-> countAllDates...'."\n";
1986
-				$previousdata = $this->countAllDates('',$filter_name);
1987
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1986
+				$previousdata = $this->countAllDates('', $filter_name);
1987
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1988 1988
 				$values = array();
1989 1989
 				foreach ($alldata as $cnt) {
1990 1990
 					$values[] = $cnt['date_count'];
1991 1991
 				}
1992
-				array_multisort($values,SORT_DESC,$alldata);
1993
-				array_splice($alldata,11);
1992
+				array_multisort($values, SORT_DESC, $alldata);
1993
+				array_splice($alldata, 11);
1994 1994
 				foreach ($alldata as $number) {
1995
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1995
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1996 1996
 				}
1997 1997
 				
1998 1998
 				echo '-> countAllHours...'."\n";
1999
-				$alldata = $Spotter->countAllHours('hour',$filter);
1999
+				$alldata = $Spotter->countAllHours('hour', $filter);
2000 2000
 				foreach ($alldata as $number) {
2001
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2001
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2002 2002
 				}
2003 2003
 				echo 'Insert last stats update date...'."\n";
2004 2004
 				date_default_timezone_set('UTC');
2005
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2005
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2006 2006
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2007
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2007
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2008 2008
 						$this->deleteOldStats($filter_name);
2009
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2009
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2010 2010
 					}
2011 2011
 				}
2012 2012
 
@@ -2019,16 +2019,16 @@  discard block
 block discarded – undo
2019 2019
 				// SUM all previous month to put as year
2020 2020
 				$previous_year = date('Y');
2021 2021
 				$previous_year--;
2022
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2023
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2024
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2025
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2022
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2023
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2024
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2025
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2026 2026
 				$allairlines = $this->getAllAirlineNames();
2027 2027
 				foreach ($allairlines as $data) {
2028
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2029
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2030
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2031
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2028
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2029
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2030
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2031
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2032 2032
 				}
2033 2033
 				
2034 2034
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 						try {
2038 2038
 							$sth = $this->db->prepare($query);
2039 2039
 							$sth->execute();
2040
-						} catch(PDOException $e) {
2040
+						} catch (PDOException $e) {
2041 2041
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2042 2042
 						}
2043 2043
 					}
@@ -2046,15 +2046,15 @@  discard block
 block discarded – undo
2046 2046
 					try {
2047 2047
 						$sth = $this->db->prepare($query);
2048 2048
 						$sth->execute();
2049
-					} catch(PDOException $e) {
2049
+					} catch (PDOException $e) {
2050 2050
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2051 2051
 					}
2052 2052
 				}
2053 2053
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2054 2054
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2055
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2055
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2056 2056
 						$this->deleteOldStats();
2057
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2057
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2058 2058
 						$lastyearupdate = true;
2059 2059
 					}
2060 2060
 				}
@@ -2076,7 +2076,7 @@  discard block
 block discarded – undo
2076 2076
 					try {
2077 2077
 						$sth = $this->db->prepare($query);
2078 2078
 						$sth->execute();
2079
-					} catch(PDOException $e) {
2079
+					} catch (PDOException $e) {
2080 2080
 						return "error : ".$e->getMessage();
2081 2081
 					}
2082 2082
 				}
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
 				try {
2091 2091
 					$sth = $this->db->prepare($query);
2092 2092
 					$sth->execute();
2093
-				} catch(PDOException $e) {
2093
+				} catch (PDOException $e) {
2094 2094
 					return "error : ".$e->getMessage();
2095 2095
 				}
2096 2096
 			}
2097 2097
 			if (!isset($lastyearupdate)) {
2098 2098
 				echo 'Insert last stats update date...'."\n";
2099 2099
 				date_default_timezone_set('UTC');
2100
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2100
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2101 2101
 			}
2102 2102
 			if ($globalStatsResetYear) {
2103 2103
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +455 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.