Completed
Push — master ( 2c41c0...302f5a )
by Yannick
27:18
created
statistics.php 2 patches
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 }
24 24
 
25 25
 if (!isset($filter_name)) $filter_name = '';
26
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
26
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
27 27
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28 28
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29 29
 }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33 33
 	if (isset($airline_info[0]['name'])) {
34 34
 		$airline_name = $airline_info[0]['name'];
35
-	} elseif (strpos($airline_icao,'alliance_') !== FALSE) {
35
+	} elseif (strpos($airline_icao, 'alliance_') !== FALSE) {
36 36
 		$alliance_name = $airline_icao;
37 37
 	}
38 38
 }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	$title = _("Statistics");
43 43
 }
44 44
 
45
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
45
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 
48 48
 require_once('header.php');
49 49
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	date_default_timezone_set('UTC');
75 75
 	$lastupdate = strtotime($last_update[0]['value']);
76 76
 	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
77
-	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
77
+	print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
78 78
 }
79 79
 
80 80
 ?>
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
 <?php
87 87
 if ($type == 'aircraft') {
88 88
 ?>
89
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
90
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
90
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
93 93
 <?php
94 94
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
95 95
 ?>
96
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
97
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
97
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
98 98
 <?php
99 99
 	}
100 100
 	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
101 101
 ?>
102
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
103
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
102
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
103
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
104 104
 <?php
105 105
 	}
106 106
 ?>
107
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
107
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
109 109
 <?php
110 110
 	if ($airline_icao == '') {
111 111
 ?>
112
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
113
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
112
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
113
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
114 114
 <?php
115 115
 	}
116 116
 ?>
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
119 119
 		if ($airline_icao == '' || $airline_icao == 'all') {
120 120
 ?>
121
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
122
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
121
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
122
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
123 123
 <?php
124 124
 		}
125 125
 	}
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
 <?php
128 128
 } elseif ($type == 'marine') {
129 129
 ?>
130
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
131
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
132
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
133
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
131
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
132
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name, $year, $month)); ?></span> <?php echo _("Types"); ?></span>
133
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
134 134
 <?php
135 135
 } elseif ($type == 'tracker') {
136 136
 ?>
137
-	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
138
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
139
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
140
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137
+	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
138
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
139
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
140
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
141 141
 <?php
142 142
 }
143 143
 ?>
144 144
     </p>
145
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
145
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
146 146
     <div class="specific-stats">
147 147
 <?php
148 148
 if ($type == 'aircraft') {
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
             <div class="col-md-6">
152 152
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
153 153
 <?php
154
-	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
154
+	$aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
155 155
 	if (count($aircraft_array) == 0) {
156 156
 		print _("No data available");
157 157
 	} else {
158 158
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 159
 		$aircraft_data = '';
160
-		foreach($aircraft_array as $aircraft_item) {
160
+		foreach ($aircraft_array as $aircraft_item) {
161 161
 			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162 162
 			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
163 163
 		}
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
 ?>
187 187
                 </div>
188 188
             </div>
189
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
189
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
190 190
 <?php
191 191
 	if ($airline_icao == '' || $airline_icao == 'all') {
192
-		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
192
+		$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
193 193
 		if (count($airline_array) > 0) {
194 194
 			print '<div class="col-md-6">';
195 195
 			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
196 196
 			print '<div id="chart2" class="chart" width="100%"></div><script>';
197 197
 			$airline_data = '';
198
-			foreach($airline_array as $airline_item) {
198
+			foreach ($airline_array as $airline_item) {
199 199
 				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
200 200
 			}
201 201
 			$airline_data = substr($airline_data, 0, -1);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 ?>
222 222
         </div>
223
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
223
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
224 224
 <?php
225 225
 	}
226 226
 }
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
             <div class="col-md-6">
233 233
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 234
 <?php
235
-	$marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
235
+	$marine_array = $Stats->countAllMarineTypes(true, $filter_name, $year, $month);
236 236
 	if (count($marine_array) == 0) print _("No data available");
237 237
 	else {
238 238
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 239
 		$marine_data = '';
240
-		foreach($marine_array as $marine_item) {
240
+		foreach ($marine_array as $marine_item) {
241 241
 			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
242 242
 		}
243 243
 		$marine_data = substr($marine_data, 0, -1);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             	    ?>
267 267
                 </div>
268 268
             </div>
269
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
269
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
270 270
 <!--	</div>-->
271 271
 <?php
272 272
 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
             <div class="col-md-6">
277 277
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 278
 <?php
279
-	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
279
+	$tracker_array = $Tracker->countAllTrackerTypes(true, 0, '', array(), $year, $month);
280 280
 	if (count($tracker_array) == 0) print _("No data available");
281 281
 	else {
282 282
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 283
 		$tracker_data = '';
284
-		foreach($tracker_array as $tracker_item) {
284
+		foreach ($tracker_array as $tracker_item) {
285 285
 			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
286 286
 		}
287 287
 		$tracker_data = substr($tracker_data, 0, -1);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             	    ?>
312 312
                 </div>
313 313
             </div>
314
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
314
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
315 315
 <!--	</div>-->
316 316
 <?php
317 317
 }
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		else {
327 327
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 328
 			$owner_data = '';
329
-			foreach($owner_array as $owner_item) {
329
+			foreach ($owner_array as $owner_item) {
330 330
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
331 331
 			}
332 332
 			$owner_data = substr($owner_data, 0, -1);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                 </div>
347 347
                 -->
348 348
             </div>
349
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
349
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
350 350
             <div class="col-md-6">
351 351
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 352
 <?php
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		else {
356 356
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 357
 			$owner_data = '';
358
-			foreach($countries_array as $owner_item) {
358
+			foreach ($countries_array as $owner_item) {
359 359
 				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
360 360
 			}
361 361
 			$owner_data = substr($owner_data, 0, -1);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 -->
377 377
             </div>
378 378
             
379
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
379
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
380 380
 ²	</div>
381 381
         <div class="row column">
382 382
             <div class="col-md-6">
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		else {
388 388
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 389
 			$launch_site_data = '';
390
-			foreach($launch_site_array as $launch_site_item) {
390
+			foreach ($launch_site_array as $launch_site_item) {
391 391
 				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
392 392
 			}
393 393
 			$launch_site_data = substr($launch_site_data, 0, -1);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 ?>
415 415
         <div class="row column">
416 416
 <?php
417
-	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
417
+	$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
418 418
 	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
419 419
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
420 420
 		if (empty($flightover_array)) {
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 ?>
426 426
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 427
 <?php
428
-		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
428
+		$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
429 429
 		if (count($pilot_array) == 0) print _("No data available");
430 430
 		else {
431 431
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 432
 			$pilot_data = '';
433
-			foreach($pilot_array as $pilot_item) {
433
+			foreach ($pilot_array as $pilot_item) {
434 434
 				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
435 435
 			}
436 436
 			$pilot_data = substr($pilot_data, 0, -1);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 ?>
452 452
             </div>
453 453
 
454
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
454
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
455 455
 <?php
456 456
 	}
457 457
 	// else {
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
             <div class="col-md-6">
461 461
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 462
 <?php
463
-		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
463
+		$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
464 464
 		if (count($owner_array) == 0) print _("No data available");
465 465
 		else {
466 466
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 467
 			$owner_data = '';
468
-			foreach($owner_array as $owner_item) {
468
+			foreach ($owner_array as $owner_item) {
469 469
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
470 470
 			}
471 471
 			$owner_data = substr($owner_data, 0, -1);
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                 </div>
485 485
             </div>
486 486
         
487
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
487
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
488 488
 <?php
489 489
 	}
490 490
 	if (!empty($flightover_array)) {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 499
 			print 'var series = [';
500 500
 			$flightover_data = '';
501
-			foreach($flightover_array as $flightover_item) {
501
+			foreach ($flightover_array as $flightover_item) {
502 502
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
503 503
 			}
504 504
 			$flightover_data = substr($flightover_data, 0, -1);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	}
544 544
 ?>
545 545
         </div>
546
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
546
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
547 547
         </div>
548 548
 <?php
549 549
 }
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 560
 		print 'var series = [';
561 561
 		$flightover_data = '';
562
-		foreach($flightover_array as $flightover_item) {
562
+		foreach ($flightover_array as $flightover_item) {
563 563
 			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
564 564
 		}
565 565
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 617
 		print 'var series = [';
618 618
 		$flightover_data = '';
619
-		foreach($flightover_array as $flightover_item) {
619
+		foreach ($flightover_array as $flightover_item) {
620 620
 			$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
621 621
 		}
622 622
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
         <div class="row column">
667 667
             <div class="col-md-6">
668 668
 <?php
669
-	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
669
+	$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
670 670
 	if (count($airport_airport_array) > 0) {
671 671
 		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
672 672
 		print '<div id="chart3" class="chart" width="100%"></div><script>';
673 673
 		print "\n";
674 674
 		print 'var series = [';
675 675
 		$airport_data = '';
676
-		foreach($airport_airport_array as $airport_item) {
676
+		foreach ($airport_airport_array as $airport_item) {
677 677
 			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
678 678
 		}
679 679
 		$airport_data = substr($airport_data, 0, -1);
@@ -723,18 +723,18 @@  discard block
 block discarded – undo
723 723
 	}
724 724
 ?>
725 725
             </div>
726
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
726
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
727 727
 
728 728
             <div class="col-md-6">
729 729
 <?php
730
-	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
730
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
731 731
 	if (count($airport_airport_array2) > 0) {
732 732
 		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
733 733
 		print '<div id="chart4" class="chart" width="100%"></div><script>';
734 734
 		print "\n";
735 735
 		print 'var series = [';
736 736
 		$airport_data = '';
737
-		foreach($airport_airport_array2 as $airport_item)
737
+		foreach ($airport_airport_array2 as $airport_item)
738 738
 		{
739 739
 			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
740 740
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 ?>
789 789
             </div>
790 790
         </div>
791
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
791
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
792 792
 <?php 
793 793
 }
794 794
 if ($type == 'aircraft') {
@@ -800,18 +800,18 @@  discard block
 block discarded – undo
800 800
             <div class="col-md-6">
801 801
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 802
 <?php
803
-		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
+		$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
804 804
 		if (count($year_array) == 0) print _("No data available");
805 805
 		else {
806 806
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 807
 			$year_data = '';
808 808
 			$year_cnt = '';
809
-			foreach($year_array as $year_item) {
809
+			foreach ($year_array as $year_item) {
810 810
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
811 811
 				$year_cnt .= $year_item['date_count'].',';
812 812
 			}
813 813
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
814
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
814
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
815 815
 			print 'c3.generate({
816 816
 			    bindto: "#chart8",
817 817
 			    data: { x: "x",
@@ -824,22 +824,22 @@  discard block
 block discarded – undo
824 824
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
825 825
                 </div>
826 826
             </div>
827
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
827
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
828 828
             <div class="col-md-6">
829 829
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 830
 <?php
831
-		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
+		$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
832 832
 		if (count($month_array) == 0) print _("No data available");
833 833
 		else {
834 834
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 835
 			$month_data = '';
836 836
 			$month_cnt = '';
837
-			foreach($month_array as $month_item) {
837
+			foreach ($month_array as $month_item) {
838 838
 				$month_data .= '"'.$month_item['date_name'].'",';
839 839
 				$month_cnt .= $month_item['date_count'].',';
840 840
 			}
841 841
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
842
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
842
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
843 843
 			print 'c3.generate({
844 844
 			    bindto: "#chart9",
845 845
 			    data: { x: "x",
@@ -852,23 +852,23 @@  discard block
 block discarded – undo
852 852
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
853 853
                 </div>
854 854
             </div>
855
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
855
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
856 856
 
857 857
             <div class="col-md-6">
858 858
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 859
 <?php
860
-		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
+		$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
861 861
 		if (empty($date_array)) print _("No data available");
862 862
 		else {
863 863
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 864
 			$date_data = '';
865 865
 			$date_cnt = '';
866
-			foreach($date_array as $date_item) {
866
+			foreach ($date_array as $date_item) {
867 867
 				$date_data .= '"'.$date_item['date_name'].'",';
868 868
 				$date_cnt .= $date_item['date_count'].',';
869 869
 			}
870 870
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
871
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
871
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
872 872
 			print 'c3.generate({
873 873
 			    bindto: "#chart5",
874 874
 			    data: { x: "x",
@@ -881,22 +881,22 @@  discard block
 block discarded – undo
881 881
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
882 882
                 </div>
883 883
             </div>
884
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
884
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 887
 <?php
888
-		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
+		$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
889 889
 		if (empty($hour_array)) print _("No data available");
890 890
 		else {
891 891
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 892
 			$hour_data = '';
893 893
 			$hour_cnt = '';
894
-			foreach($hour_array as $hour_item) {
894
+			foreach ($hour_array as $hour_item) {
895 895
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
896 896
 				$hour_cnt .= $hour_item['hour_count'].',';
897 897
 			}
898 898
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
899
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
899
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
900 900
 			print 'c3.generate({
901 901
 			    bindto: "#chart6",
902 902
 			    data: {
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
910 910
                 </div>
911 911
             </div>
912
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
912
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
913 913
         </div>
914 914
 <?php
915 915
 	}
@@ -925,18 +925,18 @@  discard block
 block discarded – undo
925 925
             <div class="col-md-6">
926 926
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 927
 <?php
928
-		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
+		$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
929 929
 		if (count($year_array) == 0) print _("No data available");
930 930
 		else {
931 931
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 932
 			$year_data = '';
933 933
 			$year_cnt = '';
934
-			foreach($year_array as $year_item) {
934
+			foreach ($year_array as $year_item) {
935 935
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
936 936
 				$year_cnt .= $year_item['date_count'].',';
937 937
 			}
938 938
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
939
-			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
939
+			$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
940 940
 			print 'c3.generate({
941 941
 			    bindto: "#chart8",
942 942
 			    data: { x: "x",
@@ -950,22 +950,22 @@  discard block
 block discarded – undo
950 950
                 </div>
951 951
             </div>
952 952
             
953
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
953
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
954 954
             <div class="col-md-6">
955 955
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 956
 <?php
957
-		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
+		$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
958 958
 		if (count($month_array) == 0) print _("No data available");
959 959
 		else {
960 960
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 961
 			$month_data = '';
962 962
 			$month_cnt = '';
963
-			foreach($month_array as $month_item) {
963
+			foreach ($month_array as $month_item) {
964 964
 				$month_data .= '"'.$month_item['date_name'].'",';
965 965
 				$month_cnt .= $month_item['date_count'].',';
966 966
 			}
967 967
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
968
-			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
968
+			$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
969 969
 			print 'c3.generate({
970 970
 			    bindto: "#chart9",
971 971
 			    data: { x: "x",
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
979 979
                 </div>
980 980
             </div>
981
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
981
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
982 982
 
983 983
             <div class="col-md-6">
984 984
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 985
 <?php
986
-		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
+		$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
987 987
 		if (empty($date_array)) print _("No data available");
988 988
 		else {
989 989
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 990
 			$date_data = '';
991 991
 			$date_cnt = '';
992
-			foreach($date_array as $date_item) {
992
+			foreach ($date_array as $date_item) {
993 993
 				$date_data .= '"'.$date_item['date_name'].'",';
994 994
 				$date_cnt .= $date_item['date_count'].',';
995 995
 			}
996 996
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
997
-			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
997
+			$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
998 998
 			print 'c3.generate({
999 999
 			    bindto: "#chart5",
1000 1000
 			    data: { x: "x",
@@ -1007,22 +1007,22 @@  discard block
 block discarded – undo
1007 1007
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1008 1008
                 </div>
1009 1009
             </div>
1010
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1010
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1011 1011
             <div class="col-md-6">
1012 1012
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1013
 <?php
1014
-		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
+		$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
1015 1015
 		if (empty($hour_array)) print _("No data available");
1016 1016
 		else {
1017 1017
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1018
 			$hour_data = '';
1019 1019
 			$hour_cnt = '';
1020
-			foreach($hour_array as $hour_item) {
1020
+			foreach ($hour_array as $hour_item) {
1021 1021
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1022 1022
 				$hour_cnt .= $hour_item['hour_count'].',';
1023 1023
 			}
1024 1024
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1025
-			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1025
+			$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
1026 1026
 			print 'c3.generate({
1027 1027
 			    bindto: "#chart6",
1028 1028
 			    data: {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1036 1036
                 </div>
1037 1037
             </div>
1038
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1038
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1039 1039
         </div>
1040 1040
 <?php
1041 1041
 	}
@@ -1057,12 +1057,12 @@  discard block
 block discarded – undo
1057 1057
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1058
 			$year_data = '';
1059 1059
 			$year_cnt = '';
1060
-			foreach($year_array as $year_item) {
1060
+			foreach ($year_array as $year_item) {
1061 1061
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1062 1062
 				$year_cnt .= $year_item['date_count'].',';
1063 1063
 			}
1064 1064
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1065
-			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1065
+			$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
1066 1066
 			print 'c3.generate({
1067 1067
 			    bindto: "#chart8",
1068 1068
 			    data: { x: "x",
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                 </div>
1077 1077
             </div>
1078 1078
             
1079
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1079
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1080 1080
             <div class="col-md-6">
1081 1081
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1082
 <?php
@@ -1086,12 +1086,12 @@  discard block
 block discarded – undo
1086 1086
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1087
 			$month_data = '';
1088 1088
 			$month_cnt = '';
1089
-			foreach($month_array as $month_item) {
1089
+			foreach ($month_array as $month_item) {
1090 1090
 				$month_data .= '"'.$month_item['date_name'].'",';
1091 1091
 				$month_cnt .= $month_item['date_count'].',';
1092 1092
 			}
1093 1093
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
1094
-			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1094
+			$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1095 1095
 			print 'c3.generate({
1096 1096
 			    bindto: "#chart9",
1097 1097
 			    data: { x: "x",
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1105 1105
                 </div>
1106 1106
             </div>
1107
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1107
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1108 1108
 
1109 1109
             <div class="col-md-6">
1110 1110
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1115,12 +1115,12 @@  discard block
 block discarded – undo
1115 1115
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1116
 			$date_data = '';
1117 1117
 			$date_cnt = '';
1118
-			foreach($date_array as $date_item) {
1118
+			foreach ($date_array as $date_item) {
1119 1119
 				$date_data .= '"'.$date_item['date_name'].'",';
1120 1120
 				$date_cnt .= $date_item['date_count'].',';
1121 1121
 			}
1122 1122
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
1123
-			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1123
+			$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1124 1124
 			print 'c3.generate({
1125 1125
 			    bindto: "#chart5",
1126 1126
 			    data: { x: "x",
@@ -1133,22 +1133,22 @@  discard block
 block discarded – undo
1133 1133
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1134 1134
                 </div>
1135 1135
             </div>
1136
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1136
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1137 1137
             <div class="col-md-6">
1138 1138
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1139
 <?php
1140
-		$hour_array = $Tracker->countAllHours('hour',true);
1140
+		$hour_array = $Tracker->countAllHours('hour', true);
1141 1141
 		if (empty($hour_array)) print _("No data available");
1142 1142
 		else {
1143 1143
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1144
 			$hour_data = '';
1145 1145
 			$hour_cnt = '';
1146
-			foreach($hour_array as $hour_item) {
1146
+			foreach ($hour_array as $hour_item) {
1147 1147
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1148 1148
 				$hour_cnt .= $hour_item['hour_count'].',';
1149 1149
 			}
1150 1150
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1151
-			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1151
+			$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1152 1152
 			print 'c3.generate({
1153 1153
 			    bindto: "#chart6",
1154 1154
 			    data: {
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1162 1162
                 </div>
1163 1163
             </div>
1164
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1164
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1165 1165
         </div>
1166 1166
 <?php
1167 1167
 	}
@@ -1183,12 +1183,12 @@  discard block
 block discarded – undo
1183 1183
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1184
 			$year_data = '';
1185 1185
 			$year_cnt = '';
1186
-			foreach($year_array as $year_item) {
1186
+			foreach ($year_array as $year_item) {
1187 1187
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1188 1188
 				$year_cnt .= $year_item['date_count'].',';
1189 1189
 			}
1190 1190
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1191
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1191
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1192 1192
 			print 'c3.generate({
1193 1193
 			    bindto: "#chart21",
1194 1194
 			    data: { x: "x",
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
             -->
1205 1205
             </div>
1206 1206
             
1207
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1207
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1208 1208
             <div class="col-md-6">
1209 1209
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1210
 <?php
@@ -1214,12 +1214,12 @@  discard block
 block discarded – undo
1214 1214
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1215
 			$year_data = '';
1216 1216
 			$year_cnt = '';
1217
-			foreach($year_array as $year_item) {
1217
+			foreach ($year_array as $year_item) {
1218 1218
 				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1219 1219
 				$year_cnt .= $year_item['date_count'].',';
1220 1220
 			}
1221 1221
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1222
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1222
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1223 1223
 			print 'c3.generate({
1224 1224
 			    bindto: "#chart22",
1225 1225
 			    data: { x: "x",
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
             -->
1236 1236
             </div>
1237 1237
             
1238
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1238
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1239 1239
         </div>
1240 1240
 <?php
1241 1241
 	}
@@ -1257,12 +1257,12 @@  discard block
 block discarded – undo
1257 1257
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1258
 			$year_data = '';
1259 1259
 			$year_cnt = '';
1260
-			foreach($year_array as $year_item) {
1260
+			foreach ($year_array as $year_item) {
1261 1261
 				$year_data .= '"'.$year_item['year'].'-01-01",';
1262 1262
 				$year_cnt .= $year_item['count'].',';
1263 1263
 			}
1264 1264
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1265
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1265
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1266 1266
 			print 'c3.generate({
1267 1267
 			    bindto: "#chart32",
1268 1268
 			    data: { x: "x",
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1276 1276
                 </div>
1277 1277
             </div>
1278
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1278
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1279 1279
 
1280 1280
         <div class="row column">
1281 1281
             <div class="col-md-6">
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1288
 			$year_data = '';
1289 1289
 			$year_cnt = '';
1290
-			foreach($year_array as $year_item) {
1290
+			foreach ($year_array as $year_item) {
1291 1291
 				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1292 1292
 				$year_cnt .= $year_item['count'].',';
1293 1293
 			}
1294 1294
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1295
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1295
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1296 1296
 			print 'c3.generate({
1297 1297
 			    bindto: "#chart33",
1298 1298
 			    data: { x: "x",
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1306 1306
                 </div>
1307 1307
             </div>
1308
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1308
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1309 1309
 <br/>
1310 1310
 <?php
1311 1311
 	}
@@ -1319,19 +1319,19 @@  discard block
 block discarded – undo
1319 1319
 	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1320 1320
 	if ($year == '' && $month == '') {
1321 1321
 		if ($type == 'aircraft') {
1322
-			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1322
+			$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1323 1323
 		} elseif ($type == 'marine') {
1324
-			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1324
+			$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1325 1325
 		} elseif ($type == 'tracker') {
1326
-			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1326
+			$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1327 1327
 		}
1328 1328
 	} else {
1329 1329
 		if ($type == 'aircraft') {
1330
-			$polar = $Stats->getStatsSource('polar',$year,$month);
1330
+			$polar = $Stats->getStatsSource('polar', $year, $month);
1331 1331
 		} elseif ($type == 'marine') {
1332
-			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1332
+			$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1333 1333
 		} elseif ($type == 'tracker') {
1334
-			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1334
+			$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1335 1335
 		}
1336 1336
 	}
1337 1337
 	if (!empty($polar)) {
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			unset($polar_data);
1341 1341
 			$Spotter = new Spotter();
1342 1342
 			$data = json_decode($eachpolar['source_data']);
1343
-			foreach($data as $value => $key) {
1343
+			foreach ($data as $value => $key) {
1344 1344
 				$direction = $Spotter->parseDirection(($value*22.5));
1345 1345
 				$distance = $key;
1346 1346
 				$unit = 'km';
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 ?>
1361 1361
             <div class="col-md-6">
1362 1362
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1363
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1363
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1364 1364
         	<script>
1365 1365
         	    (function() {
1366 1366
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 		      color: color,
1385 1385
 		      unit: '<?php echo $unit; ?>'
1386 1386
 		    };
1387
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1387
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1388 1388
 		    })();
1389 1389
 		</script>
1390 1390
             </div>
@@ -1399,19 +1399,19 @@  discard block
 block discarded – undo
1399 1399
 	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1400 1400
 	if ($year == '' && $month == '') {
1401 1401
 		if ($type == 'aircraft') {
1402
-			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1402
+			$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1403 1403
 		} elseif ($type == 'marine') {
1404
-			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1404
+			$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1405 1405
 		} elseif ($type == 'tracker') {
1406
-			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1406
+			$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1407 1407
 		}
1408 1408
 	} else {
1409 1409
 		if ($type == 'aircraft') {
1410
-			$msg = $Stats->getStatsSource('msg',$year,$month);
1410
+			$msg = $Stats->getStatsSource('msg', $year, $month);
1411 1411
 		} elseif ($type == 'marine') {
1412
-			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1412
+			$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1413 1413
 		} elseif ($type == 'tracker') {
1414
-			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1414
+			$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1415 1415
 		}
1416 1416
 	}
1417 1417
 	if (!empty($msg)) {
@@ -1419,13 +1419,13 @@  discard block
 block discarded – undo
1419 1419
 		foreach ($msg as $eachmsg) {
1420 1420
 			//$eachmsg = $msg[0];
1421 1421
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
+			if ($data > 500) $max = (round(($data + 100)/100))*100;
1423 1423
 			else $max = 500;
1424 1424
 ?>
1425
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1426
         	<script>
1427 1427
 		      var g = new JustGage({
1428
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1428
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1429 1429
 			    value: <?php echo $data; ?>,
1430 1430
 			    min: 0,
1431 1431
 			    max: <?php print $max; ?>,
@@ -1447,19 +1447,19 @@  discard block
 block discarded – undo
1447 1447
 	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1448 1448
 	if ($year == '' && $month == '') {
1449 1449
 		if ($type == 'aircraft') {
1450
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1450
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1451 1451
 		} elseif ($type == 'marine') {
1452
-			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1452
+			$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1453 1453
 		} elseif ($type == 'tracker') {
1454
-			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1454
+			$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1455 1455
 		}
1456 1456
 	} else {
1457 1457
 		if ($type == 'aircraft') {
1458
-			$hist = $Stats->getStatsSource('hist',$year,$month);
1458
+			$hist = $Stats->getStatsSource('hist', $year, $month);
1459 1459
 		} elseif ($type == 'marine') {
1460
-			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1460
+			$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1461 1461
 		} elseif ($type == 'tracker') {
1462
-			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1462
+			$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1463 1463
 		}
1464 1464
 	}
1465 1465
 	foreach ($hist as $hists) {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 		$source = $hists['source_name'];
1470 1470
 		$hist_array = json_decode($hists['source_data']);
1471 1471
 		$unit = 'km';
1472
-		foreach($hist_array as $distance => $nb) {
1472
+		foreach ($hist_array as $distance => $nb) {
1473 1473
 			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1474 1474
 				$distance = round($distance*0.539957);
1475 1475
 				$unit = 'nm';
@@ -1489,18 +1489,18 @@  discard block
 block discarded – undo
1489 1489
 		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1490 1490
 ?>
1491 1491
             <div class="col-md-6">
1492
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1492
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1493 1493
 <?php
1494
-		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1494
+		print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1495 1495
 		print 'c3.generate({
1496
-		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1496
+		    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1497 1497
 		    data: { x: "x",
1498 1498
 		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1499 1499
 		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1500 1500
 		print '</script>';
1501 1501
 ?>
1502 1502
     	    </div>
1503
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1503
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1504 1504
 <?php
1505 1505
 	}
1506 1506
 ?>
Please login to merge, or discard this patch.
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -277,8 +302,9 @@  discard block
 block discarded – undo
277 302
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 303
 <?php
279 304
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
-	if (count($tracker_array) == 0) print _("No data available");
281
-	else {
305
+	if (count($tracker_array) == 0) {
306
+		print _("No data available");
307
+	} else {
282 308
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 309
 		$tracker_data = '';
284 310
 		foreach($tracker_array as $tracker_item) {
@@ -322,8 +348,9 @@  discard block
 block discarded – undo
322 348
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323 349
 <?php
324 350
 		$owner_array = $Satellite->countAllOwners(true);
325
-		if (count($owner_array) == 0) print _("No data available");
326
-		else {
351
+		if (count($owner_array) == 0) {
352
+			print _("No data available");
353
+		} else {
327 354
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 355
 			$owner_data = '';
329 356
 			foreach($owner_array as $owner_item) {
@@ -342,7 +369,10 @@  discard block
 block discarded – undo
342 369
 ?>
343 370
                <!--
344 371
                 <div class="more">
345
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
373
+	echo '/'.$airline_icao;
374
+}
375
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
346 376
                 </div>
347 377
                 -->
348 378
             </div>
@@ -351,8 +381,9 @@  discard block
 block discarded – undo
351 381
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 382
 <?php
353 383
 		$countries_array = $Satellite->countAllCountriesOwners(true);
354
-		if (count($countries_array) == 0) print _("No data available");
355
-		else {
384
+		if (count($countries_array) == 0) {
385
+			print _("No data available");
386
+		} else {
356 387
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 388
 			$owner_data = '';
358 389
 			foreach($countries_array as $owner_item) {
@@ -371,7 +402,10 @@  discard block
 block discarded – undo
371 402
 ?>
372 403
 	    <!--
373 404
                 <div class="more">
374
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
405
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
406
+	echo '/'.$airline_icao;
407
+}
408
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
375 409
                 </div>
376 410
                 -->
377 411
             </div>
@@ -383,8 +417,9 @@  discard block
 block discarded – undo
383 417
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384 418
 <?php
385 419
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
-		if (count($launch_site_array) == 0) print _("No data available");
387
-		else {
420
+		if (count($launch_site_array) == 0) {
421
+			print _("No data available");
422
+		} else {
388 423
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 424
 			$launch_site_data = '';
390 425
 			foreach($launch_site_array as $launch_site_item) {
@@ -403,7 +438,10 @@  discard block
 block discarded – undo
403 438
 ?>
404 439
                <!--
405 440
                 <div class="more">
406
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
441
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
442
+	echo '/'.$airline_icao;
443
+}
444
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
407 445
                 </div>
408 446
                 -->
409 447
             </div>
@@ -426,8 +464,9 @@  discard block
 block discarded – undo
426 464
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 465
 <?php
428 466
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
-		if (count($pilot_array) == 0) print _("No data available");
430
-		else {
467
+		if (count($pilot_array) == 0) {
468
+			print _("No data available");
469
+		} else {
431 470
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 471
 			$pilot_data = '';
433 472
 			foreach($pilot_array as $pilot_item) {
@@ -445,7 +484,9 @@  discard block
 block discarded – undo
445 484
 		}
446 485
 		print '<div class="more">';
447 486
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
487
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
488
+			echo '/'.$airline_icao;
489
+		}
449 490
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450 491
 		print '</div>';
451 492
 ?>
@@ -461,8 +502,9 @@  discard block
 block discarded – undo
461 502
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 503
 <?php
463 504
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
-		if (count($owner_array) == 0) print _("No data available");
465
-		else {
505
+		if (count($owner_array) == 0) {
506
+			print _("No data available");
507
+		} else {
466 508
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 509
 			$owner_data = '';
468 510
 			foreach($owner_array as $owner_item) {
@@ -480,7 +522,10 @@  discard block
 block discarded – undo
480 522
 		}
481 523
 ?>
482 524
                 <div class="more">
483
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
526
+	echo '/'.$airline_icao;
527
+}
528
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
484 529
                 </div>
485 530
             </div>
486 531
         
@@ -493,8 +538,9 @@  discard block
 block discarded – undo
493 538
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494 539
 <?php
495 540
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
-		if (count($flightover_array) == 0) print _("No data available");
497
-		else {
541
+		if (count($flightover_array) == 0) {
542
+			print _("No data available");
543
+		} else {
498 544
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 545
 			print 'var series = [';
500 546
 			$flightover_data = '';
@@ -536,7 +582,10 @@  discard block
 block discarded – undo
536 582
 		}
537 583
 ?>
538 584
                 <div class="more">
539
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
585
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
586
+	echo '/'.$airline_icao;
587
+}
588
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
540 589
                 </div>
541 590
             </div>
542 591
 <?php
@@ -554,8 +603,9 @@  discard block
 block discarded – undo
554 603
 	<div class="col-md-6">
555 604
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556 605
 <?php
557
-	if (count($flightover_array) == 0) print _("No data available");
558
-	else {
606
+	if (count($flightover_array) == 0) {
607
+		print _("No data available");
608
+	} else {
559 609
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 610
 		print 'var series = [';
561 611
 		$flightover_data = '';
@@ -611,8 +661,9 @@  discard block
 block discarded – undo
611 661
 	<div class="col-md-6">
612 662
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
613 663
 <?php
614
-	if (count($flightover_array) == 0) print _("No data available");
615
-	else {
664
+	if (count($flightover_array) == 0) {
665
+		print _("No data available");
666
+	} else {
616 667
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 668
 		print 'var series = [';
618 669
 		$flightover_data = '';
@@ -718,7 +769,9 @@  discard block
 block discarded – undo
718 769
 		});";
719 770
 		print '</script>';
720 771
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
721
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
772
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
773
+			echo '/'.$airline_icao;
774
+		}
722 775
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
723 776
 	}
724 777
 ?>
@@ -782,7 +835,9 @@  discard block
 block discarded – undo
782 835
 		});";
783 836
 		print '</script>';
784 837
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
785
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
838
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
839
+			echo '/'.$airline_icao;
840
+		}
786 841
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
787 842
 	}
788 843
 ?>
@@ -801,8 +856,9 @@  discard block
 block discarded – undo
801 856
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 857
 <?php
803 858
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
804
-		if (count($year_array) == 0) print _("No data available");
805
-		else {
859
+		if (count($year_array) == 0) {
860
+			print _("No data available");
861
+		} else {
806 862
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 863
 			$year_data = '';
808 864
 			$year_cnt = '';
@@ -821,7 +877,10 @@  discard block
 block discarded – undo
821 877
 		}
822 878
 ?>
823 879
                 <div class="more">
824
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
880
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
881
+	echo '/'.$airline_icao;
882
+}
883
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
825 884
                 </div>
826 885
             </div>
827 886
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -829,8 +888,9 @@  discard block
 block discarded – undo
829 888
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 889
 <?php
831 890
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
832
-		if (count($month_array) == 0) print _("No data available");
833
-		else {
891
+		if (count($month_array) == 0) {
892
+			print _("No data available");
893
+		} else {
834 894
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 895
 			$month_data = '';
836 896
 			$month_cnt = '';
@@ -849,7 +909,10 @@  discard block
 block discarded – undo
849 909
 		}
850 910
 ?>
851 911
                 <div class="more">
852
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
912
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
913
+	echo '/'.$airline_icao;
914
+}
915
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
853 916
                 </div>
854 917
             </div>
855 918
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -858,8 +921,9 @@  discard block
 block discarded – undo
858 921
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 922
 <?php
860 923
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
861
-		if (empty($date_array)) print _("No data available");
862
-		else {
924
+		if (empty($date_array)) {
925
+			print _("No data available");
926
+		} else {
863 927
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 928
 			$date_data = '';
865 929
 			$date_cnt = '';
@@ -878,7 +942,10 @@  discard block
 block discarded – undo
878 942
 		}
879 943
 ?>
880 944
                 <div class="more">
881
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
945
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
946
+	echo '/'.$airline_icao;
947
+}
948
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
882 949
                 </div>
883 950
             </div>
884 951
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -886,8 +953,9 @@  discard block
 block discarded – undo
886 953
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 954
 <?php
888 955
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
889
-		if (empty($hour_array)) print _("No data available");
890
-		else {
956
+		if (empty($hour_array)) {
957
+			print _("No data available");
958
+		} else {
891 959
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 960
 			$hour_data = '';
893 961
 			$hour_cnt = '';
@@ -906,7 +974,10 @@  discard block
 block discarded – undo
906 974
 		}
907 975
 ?>
908 976
                 <div class="more">
909
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
977
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
978
+	echo '/'.$airline_icao;
979
+}
980
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
910 981
                 </div>
911 982
             </div>
912 983
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -926,8 +997,9 @@  discard block
 block discarded – undo
926 997
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 998
 <?php
928 999
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
929
-		if (count($year_array) == 0) print _("No data available");
930
-		else {
1000
+		if (count($year_array) == 0) {
1001
+			print _("No data available");
1002
+		} else {
931 1003
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 1004
 			$year_data = '';
933 1005
 			$year_cnt = '';
@@ -955,8 +1027,9 @@  discard block
 block discarded – undo
955 1027
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 1028
 <?php
957 1029
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
958
-		if (count($month_array) == 0) print _("No data available");
959
-		else {
1030
+		if (count($month_array) == 0) {
1031
+			print _("No data available");
1032
+		} else {
960 1033
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 1034
 			$month_data = '';
962 1035
 			$month_cnt = '';
@@ -984,8 +1057,9 @@  discard block
 block discarded – undo
984 1057
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 1058
 <?php
986 1059
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
987
-		if (empty($date_array)) print _("No data available");
988
-		else {
1060
+		if (empty($date_array)) {
1061
+			print _("No data available");
1062
+		} else {
989 1063
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 1064
 			$date_data = '';
991 1065
 			$date_cnt = '';
@@ -1012,8 +1086,9 @@  discard block
 block discarded – undo
1012 1086
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1087
 <?php
1014 1088
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1015
-		if (empty($hour_array)) print _("No data available");
1016
-		else {
1089
+		if (empty($hour_array)) {
1090
+			print _("No data available");
1091
+		} else {
1017 1092
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1093
 			$hour_data = '';
1019 1094
 			$hour_cnt = '';
@@ -1052,8 +1127,9 @@  discard block
 block discarded – undo
1052 1127
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1053 1128
 <?php
1054 1129
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1055
-		if (count($year_array) == 0) print _("No data available");
1056
-		else {
1130
+		if (count($year_array) == 0) {
1131
+			print _("No data available");
1132
+		} else {
1057 1133
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1134
 			$year_data = '';
1059 1135
 			$year_cnt = '';
@@ -1081,8 +1157,9 @@  discard block
 block discarded – undo
1081 1157
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1158
 <?php
1083 1159
 		$month_array = $Tracker->countAllDatesLastMonth();
1084
-		if (count($month_array) == 0) print _("No data available");
1085
-		else {
1160
+		if (count($month_array) == 0) {
1161
+			print _("No data available");
1162
+		} else {
1086 1163
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1164
 			$month_data = '';
1088 1165
 			$month_cnt = '';
@@ -1110,8 +1187,9 @@  discard block
 block discarded – undo
1110 1187
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1111 1188
 <?php
1112 1189
 		$date_array = $Tracker->countAllDatesLast7Days();
1113
-		if (empty($date_array)) print _("No data available");
1114
-		else {
1190
+		if (empty($date_array)) {
1191
+			print _("No data available");
1192
+		} else {
1115 1193
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1194
 			$date_data = '';
1117 1195
 			$date_cnt = '';
@@ -1138,8 +1216,9 @@  discard block
 block discarded – undo
1138 1216
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1217
 <?php
1140 1218
 		$hour_array = $Tracker->countAllHours('hour',true);
1141
-		if (empty($hour_array)) print _("No data available");
1142
-		else {
1219
+		if (empty($hour_array)) {
1220
+			print _("No data available");
1221
+		} else {
1143 1222
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1223
 			$hour_data = '';
1145 1224
 			$hour_cnt = '';
@@ -1178,8 +1257,9 @@  discard block
 block discarded – undo
1178 1257
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1179 1258
 <?php
1180 1259
 		$year_array = $Satellite->countAllMonthsLastYear();
1181
-		if (count($year_array) == 0) print _("No data available");
1182
-		else {
1260
+		if (count($year_array) == 0) {
1261
+			print _("No data available");
1262
+		} else {
1183 1263
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1264
 			$year_data = '';
1185 1265
 			$year_cnt = '';
@@ -1209,8 +1289,9 @@  discard block
 block discarded – undo
1209 1289
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1290
 <?php
1211 1291
 		$year_array = $Satellite->countAllYears();
1212
-		if (count($year_array) == 0) print _("No data available");
1213
-		else {
1292
+		if (count($year_array) == 0) {
1293
+			print _("No data available");
1294
+		} else {
1214 1295
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1296
 			$year_data = '';
1216 1297
 			$year_cnt = '';
@@ -1252,8 +1333,9 @@  discard block
 block discarded – undo
1252 1333
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1253 1334
 <?php
1254 1335
 		$year_array = $Stats->countFatalitiesByYear();
1255
-		if (count($year_array) == 0) print _("No data available");
1256
-		else {
1336
+		if (count($year_array) == 0) {
1337
+			print _("No data available");
1338
+		} else {
1257 1339
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1340
 			$year_data = '';
1259 1341
 			$year_cnt = '';
@@ -1282,8 +1364,9 @@  discard block
 block discarded – undo
1282 1364
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1283 1365
 <?php
1284 1366
 		$year_array = $Stats->countFatalitiesLast12Months();
1285
-		if (count($year_array) == 0) print _("No data available");
1286
-		else {
1367
+		if (count($year_array) == 0) {
1368
+			print _("No data available");
1369
+		} else {
1287 1370
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1371
 			$year_data = '';
1289 1372
 			$year_cnt = '';
@@ -1354,8 +1437,11 @@  discard block
 block discarded – undo
1354 1437
 					$distance = $distance;
1355 1438
 					$unit = 'km';
1356 1439
 				}
1357
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1358
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1440
+				if (!isset($polar_data)) {
1441
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1442
+				} else {
1443
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1444
+				}
1359 1445
 			}
1360 1446
 ?>
1361 1447
             <div class="col-md-6">
@@ -1419,9 +1505,12 @@  discard block
 block discarded – undo
1419 1505
 		foreach ($msg as $eachmsg) {
1420 1506
 			//$eachmsg = $msg[0];
1421 1507
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1423
-			else $max = 500;
1424
-?>
1508
+			if ($data > 500) {
1509
+				$max = (round(($data+100)/100))*100;
1510
+			} else {
1511
+				$max = 500;
1512
+			}
1513
+			?>
1425 1514
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1515
         	<script>
1427 1516
 		      var g = new JustGage({
Please login to merge, or discard this patch.
require/class.Stats.php 2 patches
Spacing   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
22 22
 	}
23 23
 
24
-	public function addLastStatsUpdate($type,$stats_date) {
24
+	public function addLastStatsUpdate($type, $stats_date) {
25 25
 		$query = "DELETE FROM config WHERE name = :type;
26 26
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
27
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
27
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		try {
39 39
 			$sth = $this->db->prepare($query);
40 40
 			$sth->execute(array(':type' => $type));
41
-		} catch(PDOException $e) {
41
+		} catch (PDOException $e) {
42 42
 			echo "error : ".$e->getMessage();
43 43
 		}
44 44
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		try {
60 60
 			$sth = $this->db->prepare($query);
61 61
 			$sth->execute(array(':filter_name' => $filter_name));
62
-		} catch(PDOException $e) {
62
+		} catch (PDOException $e) {
63 63
 			return "error : ".$e->getMessage();
64 64
 		}
65 65
 	}
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		try {
73 73
 			$sth = $this->db->prepare($query);
74 74
 			$sth->execute();
75
-		} catch(PDOException $e) {
75
+		} catch (PDOException $e) {
76 76
 			return "error : ".$e->getMessage();
77 77
 		}
78 78
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute(array(':filter_name' => $filter_name));
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 	}
@@ -91,77 +91,77 @@  discard block
 block discarded – undo
91 91
 		 try {
92 92
 			$sth = $this->db->prepare($query);
93 93
 			$sth->execute(array(':filter_name' => $filter_name));
94
-		} catch(PDOException $e) {
94
+		} catch (PDOException $e) {
95 95
 			echo "error : ".$e->getMessage();
96 96
 		}
97 97
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
98 98
 		if (empty($all)) {
99 99
 			$filters = array();
100 100
 			if ($filter_name != '') {
101
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
101
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
102 102
 			}
103 103
 			$Spotter = new Spotter($this->db);
104
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
104
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
105 105
 		}
106 106
 		return $all;
107 107
 	}
108
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
108
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
109 109
 		if ($filter_name == '') $filter_name = $this->filter_name;
110 110
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 111
 		try {
112 112
 			$sth = $this->db->prepare($query);
113
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
114
-		} catch(PDOException $e) {
113
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
114
+		} catch (PDOException $e) {
115 115
 			echo "error : ".$e->getMessage();
116 116
 		}
117 117
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
118 118
 		return $all;
119 119
 	}
120
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
120
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
121 121
 		if ($filter_name == '') $filter_name = $this->filter_name;
122 122
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
123 123
 		try {
124 124
 			$sth = $this->db->prepare($query);
125
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
126
-		} catch(PDOException $e) {
125
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
126
+		} catch (PDOException $e) {
127 127
 			echo "error : ".$e->getMessage();
128 128
 		}
129 129
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
130 130
 		return $all;
131 131
 	}
132
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
135 135
 		try {
136 136
 			$sth = $this->db->prepare($query);
137
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-		} catch(PDOException $e) {
137
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+		} catch (PDOException $e) {
139 139
 			echo "error : ".$e->getMessage();
140 140
 		}
141 141
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
 		return $all;
143 143
 	}
144 144
 
145
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 148
 		try {
149 149
 			$sth = $this->db->prepare($query);
150
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-		} catch(PDOException $e) {
150
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+		} catch (PDOException $e) {
152 152
 			echo "error : ".$e->getMessage();
153 153
 		}
154 154
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
155 155
 		return $all;
156 156
 	}
157 157
 
158
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
158
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
159 159
 		if ($filter_name == '') $filter_name = $this->filter_name;
160 160
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 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,23 +169,23 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 
172
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
172
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
173 173
 		global $globalStatsFilters;
174 174
 		if ($filter_name == '') $filter_name = $this->filter_name;
175
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
175
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
176 176
 			$Spotter = new Spotter($this->db);
177
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
177
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
178 178
 			$alliance_airlines = array();
179 179
 			foreach ($airlines as $airline) {
180
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
180
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
181 181
 			}
182 182
 			if ($year == '' && $month == '') {
183
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
183
+				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
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);
@@ -196,29 +196,29 @@  discard block
 block discarded – undo
196 196
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
197 197
 				try {
198 198
 					$sth = $this->db->prepare($query);
199
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
200
-				} catch(PDOException $e) {
199
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
200
+				} catch (PDOException $e) {
201 201
 					echo "error : ".$e->getMessage();
202 202
 				}
203 203
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204 204
 			} else $all = array();
205 205
 		}
206 206
 		if (empty($all)) {
207
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
208
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
207
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
208
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
209 209
 			} else {
210
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
210
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
211 211
 			}
212 212
 			if ($filter_name != '') {
213
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
213
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
214 214
 			}
215 215
 			$Spotter = new Spotter($this->db);
216 216
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
217
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
217
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
218 218
 		}
219 219
 		return $all;
220 220
 	}
221
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
221
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
222 222
 		global $globalStatsFilters;
223 223
 		if ($filter_name == '') $filter_name = $this->filter_name;
224 224
 		if ($year == '' && $month == '') {
@@ -227,23 +227,23 @@  discard block
 block discarded – undo
227 227
 			try {
228 228
 				$sth = $this->db->prepare($query);
229 229
 				$sth->execute(array(':filter_name' => $filter_name));
230
-			} catch(PDOException $e) {
230
+			} catch (PDOException $e) {
231 231
 				echo "error : ".$e->getMessage();
232 232
 			}
233 233
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234 234
 		} else $all = array();
235 235
 		if (empty($all)) {
236
-			$filters = array('year' => $year,'month' => $month);
236
+			$filters = array('year' => $year, 'month' => $month);
237 237
 			if ($filter_name != '') {
238
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
238
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
239 239
 			}
240 240
 			$Marine = new Marine($this->db);
241 241
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
242
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
242
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
243 243
 		}
244 244
 		return $all;
245 245
 	}
246
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
246
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
247 247
 		global $globalStatsFilters;
248 248
 		if ($filter_name == '') $filter_name = $this->filter_name;
249 249
 		if ($year == '' && $month == '') {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			try {
253 253
 				$sth = $this->db->prepare($query);
254 254
 				$sth->execute(array(':filter_name' => $filter_name));
255
-			} catch(PDOException $e) {
255
+			} catch (PDOException $e) {
256 256
 				echo "error : ".$e->getMessage();
257 257
 			}
258 258
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -260,32 +260,32 @@  discard block
 block discarded – undo
260 260
 		if (empty($all)) {
261 261
 			$Spotter = new Spotter($this->db);
262 262
 			$filters = array();
263
-			$filters = array('year' => $year,'month' => $month);
263
+			$filters = array('year' => $year, 'month' => $month);
264 264
 			if ($filter_name != '') {
265
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
265
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
266 266
 			}
267 267
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
268
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
268
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
269 269
 		}
270 270
 		return $all;
271 271
 	}
272
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
272
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
273 273
 		global $globalStatsFilters;
274 274
 		if ($filter_name == '') $filter_name = $this->filter_name;
275
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
275
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
276 276
 			$Spotter = new Spotter($this->db);
277
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
277
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
278 278
 			$alliance_airlines = array();
279 279
 			foreach ($airlines as $airline) {
280
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
280
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
281 281
 			}
282 282
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
283
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
285 285
 				try {
286 286
 					$sth = $this->db->prepare($query);
287 287
 					$sth->execute(array(':filter_name' => $filter_name));
288
-				} catch(PDOException $e) {
288
+				} catch (PDOException $e) {
289 289
 					echo "error : ".$e->getMessage();
290 290
 				}
291 291
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -296,21 +296,21 @@  discard block
 block discarded – undo
296 296
 				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
297 297
 				try {
298 298
 					$sth = $this->db->prepare($query);
299
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
300
-				} catch(PDOException $e) {
299
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
300
+				} catch (PDOException $e) {
301 301
 					echo "error : ".$e->getMessage();
302 302
 				}
303 303
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304 304
 			} else $all = array();
305 305
 		}
306 306
 		if (empty($all)) {
307
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
308
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
307
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
308
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
309 309
 			} else {
310
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
310
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
311 311
 			}
312 312
 			if ($filter_name != '') {
313
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			$Spotter = new Spotter($this->db);
316 316
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
 		return $all;
320 320
 	}
321 321
 
322
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
322
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
323 323
 		global $globalStatsFilters;
324 324
 		if ($filter_name == '') $filter_name = $this->filter_name;
325
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
325
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
326 326
 			$Spotter = new Spotter($this->db);
327
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
327
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
328 328
 			$alliance_airlines = array();
329 329
 			foreach ($airlines as $airline) {
330
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
330
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
331 331
 			}
332 332
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
333
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
335 335
 				try {
336 336
 					$sth = $this->db->prepare($query);
337 337
 					$sth->execute(array(':filter_name' => $filter_name));
338
-				} catch(PDOException $e) {
338
+				} catch (PDOException $e) {
339 339
 					echo "error : ".$e->getMessage();
340 340
 				}
341 341
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -346,61 +346,61 @@  discard block
 block discarded – undo
346 346
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
347 347
 				try {
348 348
 					$sth = $this->db->prepare($query);
349
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
350
-				} catch(PDOException $e) {
349
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
350
+				} catch (PDOException $e) {
351 351
 					echo "error : ".$e->getMessage();
352 352
 				}
353 353
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354 354
 			} else $all = array();
355 355
 		}
356 356
 		if (empty($all)) {
357
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
358
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
357
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
358
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
359 359
 			} else {
360
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			}
362 362
 			if ($filter_name != '') {
363
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
363
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
364 364
 			}
365 365
 			$Spotter = new Spotter($this->db);
366 366
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
367
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
367
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
368 368
 		}
369 369
 		return $all;
370 370
 	}
371 371
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 372
 		global $globalStatsFilters;
373 373
 		if ($filter_name == '') $filter_name = $this->filter_name;
374
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
374
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
375 375
 			$Spotter = new Spotter($this->db);
376
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
376
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
377 377
 			$alliance_airlines = array();
378 378
 			foreach ($airlines as $airline) {
379
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
379
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
380 380
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
381
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
383 383
 			$query_values = array(':filter_name' => $filter_name);
384 384
 		} else {
385 385
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386 386
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
387
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
387
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
388 388
 		}
389 389
 		try {
390 390
 			$sth = $this->db->prepare($query);
391 391
 			$sth->execute($query_values);
392
-		} catch(PDOException $e) {
392
+		} catch (PDOException $e) {
393 393
 			echo "error : ".$e->getMessage();
394 394
 		}
395 395
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
396 396
 		if (empty($all)) {
397
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
398
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
397
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
398
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
399 399
 			} else {
400
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
400
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
401 401
 			}
402 402
 			if ($filter_name != '') {
403
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
403
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
404 404
 			}
405 405
 			$Spotter = new Spotter($this->db);
406 406
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		return $all;
410 410
 	}
411 411
 
412
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
412
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
413 413
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414 414
 		if ($filter_name == '') $filter_name = $this->filter_name;
415 415
 		if ($year == '' && $month == '') {
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			if (isset($forsource)) {
419 419
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420 420
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
421
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
421
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
422 422
 			} else {
423 423
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424 424
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			try {
428 428
 				$sth = $this->db->prepare($query);
429 429
 				$sth->execute($query_values);
430
-			} catch(PDOException $e) {
430
+			} catch (PDOException $e) {
431 431
 				echo "error : ".$e->getMessage();
432 432
 			}
433 433
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -435,32 +435,32 @@  discard block
 block discarded – undo
435 435
                 if (empty($all)) {
436 436
 	                $Spotter = new Spotter($this->db);
437 437
             		$filters = array();
438
-			$filters = array('year' => $year,'month' => $month);
438
+			$filters = array('year' => $year, 'month' => $month);
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
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
443
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
443
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
450
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
451 451
 			$Spotter = new Spotter($this->db);
452
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
452
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
453 453
 			$alliance_airlines = array();
454 454
 			foreach ($airlines as $airline) {
455
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
455
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
456 456
 			}
457 457
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
458
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
+				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
460 460
 				try {
461 461
 					$sth = $this->db->prepare($query);
462 462
 					$sth->execute(array(':filter_name' => $filter_name));
463
-				} catch(PDOException $e) {
463
+				} catch (PDOException $e) {
464 464
 					echo "error : ".$e->getMessage();
465 465
 				}
466 466
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -471,45 +471,45 @@  discard block
 block discarded – undo
471 471
 				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
472 472
 				try {
473 473
 					$sth = $this->db->prepare($query);
474
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
475
-				} catch(PDOException $e) {
474
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
475
+				} catch (PDOException $e) {
476 476
 					echo "error : ".$e->getMessage();
477 477
 				}
478 478
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479 479
 			} else $all = array();
480 480
 		}
481 481
 		if (empty($all)) {
482
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
483
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
482
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
483
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
484 484
 			} else {
485
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
485
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
486 486
 			}
487 487
 			if ($filter_name != '') {
488
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
488
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
489 489
 			}
490 490
 			$Spotter = new Spotter($this->db);
491 491
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
492
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
492
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
493 493
 		}
494 494
 		return $all;
495 495
 	}
496
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
496
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
497 497
 		global $globalStatsFilters;
498 498
 		if ($filter_name == '') $filter_name = $this->filter_name;
499
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
499
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
500 500
 			$Spotter = new Spotter($this->db);
501
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
501
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
502 502
 			$alliance_airlines = array();
503 503
 			foreach ($airlines as $airline) {
504
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
504
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
505 505
 			}
506 506
 			if ($year == '' && $month == '') {
507
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
507
+				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
+				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
509 509
 				 try {
510 510
 					$sth = $this->db->prepare($query);
511 511
 					$sth->execute(array(':filter_name' => $filter_name));
512
-				} catch(PDOException $e) {
512
+				} catch (PDOException $e) {
513 513
 					echo "error : ".$e->getMessage();
514 514
 				}
515 515
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -520,46 +520,46 @@  discard block
 block discarded – undo
520 520
 				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
521 521
 				 try {
522 522
 					$sth = $this->db->prepare($query);
523
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
524
-				} catch(PDOException $e) {
523
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
524
+				} catch (PDOException $e) {
525 525
 					echo "error : ".$e->getMessage();
526 526
 				}
527 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528 528
 			} else $all = array();
529 529
 		}
530 530
 		if (empty($all)) {
531
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
532
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
531
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
532
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
533 533
 			} else {
534
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
534
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
535 535
 			}
536 536
 			if ($filter_name != '') {
537
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
538 538
 			}
539 539
 			$Spotter = new Spotter($this->db);
540 540
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
541
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
541
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
542 542
 		}
543 543
 		return $all;
544 544
 	}
545
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
545
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
546 546
 		$Connection = new Connection($this->db);
547 547
 		if ($filter_name == '') $filter_name = $this->filter_name;
548 548
 		if ($Connection->tableExists('countries')) {
549
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
549
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
550 550
 				$Spotter = new Spotter($this->db);
551
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
551
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
552 552
 				if ($year == '' && $month == '') {
553 553
 					$alliance_airlines = array();
554 554
 					foreach ($airlines as $airline) {
555
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
555
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
556 556
 					}
557
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
557
+					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
+					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
559 559
 					 try {
560 560
 						$sth = $this->db->prepare($query);
561 561
 						$sth->execute(array(':filter_name' => $filter_name));
562
-					} catch(PDOException $e) {
562
+					} catch (PDOException $e) {
563 563
 						echo "error : ".$e->getMessage();
564 564
 					}
565 565
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
572 572
 					 try {
573 573
 						$sth = $this->db->prepare($query);
574
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
575
-					} catch(PDOException $e) {
574
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
575
+					} catch (PDOException $e) {
576 576
 						echo "error : ".$e->getMessage();
577 577
 					}
578 578
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			return $Spotter->countAllFlightOverCountries($limit);
584 584
 		} else return array();
585 585
 	}
586
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
586
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
587 587
 		$Connection = new Connection($this->db);
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		if ($Connection->tableExists('countries')) {
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 				 try {
595 595
 					$sth = $this->db->prepare($query);
596 596
 					$sth->execute(array(':filter_name' => $filter_name));
597
-				} catch(PDOException $e) {
597
+				} catch (PDOException $e) {
598 598
 					echo "error : ".$e->getMessage();
599 599
 				}
600 600
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
 			if (empty($all)) {
603 603
 				$filters = array();
604 604
 				if ($filter_name != '') {
605
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
605
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
606 606
 				}
607 607
 				$Marine = new Marine($this->db);
608
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
608
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
609 609
 			}
610 610
 			return $all;
611 611
 		} else return array();
612 612
 	}
613
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
613
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
614 614
 		global $globalStatsFilters;
615 615
 		$Connection = new Connection($this->db);
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 				 try {
623 623
 					$sth = $this->db->prepare($query);
624 624
 					$sth->execute(array(':filter_name' => $filter_name));
625
-				} catch(PDOException $e) {
625
+				} catch (PDOException $e) {
626 626
 					echo "error : ".$e->getMessage();
627 627
 				}
628 628
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 			if (empty($all)) {
632 632
 				$filters = array();
633 633
 				if ($filter_name != '') {
634
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
634
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
635 635
 				}
636 636
 				$Tracker = new Tracker($this->db);
637
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
637
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
638 638
 			}
639 639
 			return $all;
640 640
 		} else return array();
641 641
 	}
642
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
642
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
643 643
 		global $globalStatsFilters;
644 644
 		if ($filter_name == '') $filter_name = $this->filter_name;
645 645
 		if ($year == '' && $month == '') {
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
648 648
 			try {
649 649
 				$sth = $this->db->prepare($query);
650
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
651
-			} catch(PDOException $e) {
650
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
651
+			} catch (PDOException $e) {
652 652
 				echo "error : ".$e->getMessage();
653 653
 			}
654 654
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655 655
 		} else $all = array();
656 656
 		if (empty($all)) {
657
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
657
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
658 658
 			if ($filter_name != '') {
659
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
659
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
660 660
 			}
661 661
 			$Spotter = new Spotter($this->db);
662 662
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
663
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
663
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
664 664
 		}
665 665
 		return $all;
666 666
 	}
667 667
 
668
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
668
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
669 669
 		global $globalStatsFilters;
670 670
 		if ($filter_name == '') $filter_name = $this->filter_name;
671
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
671
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
672 672
 			$Spotter = new Spotter($this->db);
673
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
673
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
674 674
 			if ($year == '' && $month == '') {
675 675
 				$alliance_airlines = array();
676 676
 				foreach ($airlines as $airline) {
677
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
677
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
678 678
 				}
679
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
679
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
681 681
 				try {
682 682
 					$sth = $this->db->prepare($query);
683 683
 					$sth->execute(array(':filter_name' => $filter_name));
684
-				} catch(PDOException $e) {
684
+				} catch (PDOException $e) {
685 685
 					echo "error : ".$e->getMessage();
686 686
 				}
687 687
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -692,45 +692,45 @@  discard block
 block discarded – undo
692 692
 				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
693 693
 				try {
694 694
 					$sth = $this->db->prepare($query);
695
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
696
-				} catch(PDOException $e) {
695
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
696
+				} catch (PDOException $e) {
697 697
 					echo "error : ".$e->getMessage();
698 698
 				}
699 699
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
700 700
 			} else $all = array();
701 701
 		}
702 702
 		if (empty($all)) {
703
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
704
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
703
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
704
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
705 705
 			} else {
706
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
706
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
707 707
 			}
708 708
 			if ($filter_name != '') {
709
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
709
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
710 710
 			}
711 711
 			$Spotter = new Spotter($this->db);
712 712
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
713
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
713
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
714 714
 		}
715 715
 		return $all;
716 716
 	}
717
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
717
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
718 718
 		global $globalStatsFilters;
719 719
 		if ($filter_name == '') $filter_name = $this->filter_name;
720
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
720
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
721 721
 			$Spotter = new Spotter($this->db);
722
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
722
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
723 723
 			if ($year == '' && $month == '') {
724 724
 				$alliance_airlines = array();
725 725
 				foreach ($airlines as $airline) {
726
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
726
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
727 727
 				}
728
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
728
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
730 730
 				try {
731 731
 					$sth = $this->db->prepare($query);
732 732
 					$sth->execute(array(':filter_name' => $filter_name));
733
-				} catch(PDOException $e) {
733
+				} catch (PDOException $e) {
734 734
 					echo "error : ".$e->getMessage();
735 735
 				}
736 736
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -741,27 +741,27 @@  discard block
 block discarded – undo
741 741
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
742 742
 				try {
743 743
 					$sth = $this->db->prepare($query);
744
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
745
-				} catch(PDOException $e) {
744
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
745
+				} catch (PDOException $e) {
746 746
 					echo "error : ".$e->getMessage();
747 747
 				}
748 748
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
749 749
 			} else $all = array();
750 750
 		}
751 751
 		if (empty($all)) {
752
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
753
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
752
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
753
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
754 754
 			} else {
755
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
755
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
756 756
 			}
757 757
 			if ($filter_name != '') {
758
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
758
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
759 759
 			}
760 760
 			$Spotter = new Spotter($this->db);
761 761
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
762 762
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
763
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
764
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
763
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
764
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
765 765
 			$all = array();
766 766
 			foreach ($pall as $value) {
767 767
 				$icao = $value['airport_departure_icao'];
@@ -777,27 +777,27 @@  discard block
 block discarded – undo
777 777
 			foreach ($all as $key => $row) {
778 778
 				$count[$key] = $row['airport_departure_icao_count'];
779 779
 			}
780
-			array_multisort($count,SORT_DESC,$all);
780
+			array_multisort($count, SORT_DESC, $all);
781 781
 		}
782 782
 		return $all;
783 783
 	}
784
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
784
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
785 785
 		global $globalStatsFilters;
786 786
 		if ($filter_name == '') $filter_name = $this->filter_name;
787
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
787
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
788 788
 			$Spotter = new Spotter($this->db);
789
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
789
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
790 790
 			if ($year == '' && $month == '') {
791 791
 				$alliance_airlines = array();
792 792
 				foreach ($airlines as $airline) {
793
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
793
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
794 794
 				}
795
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
795
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
797 797
 				try {
798 798
 					$sth = $this->db->prepare($query);
799 799
 					$sth->execute(array(':filter_name' => $filter_name));
800
-				} catch(PDOException $e) {
800
+				} catch (PDOException $e) {
801 801
 					echo "error : ".$e->getMessage();
802 802
 				}
803 803
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -808,27 +808,27 @@  discard block
 block discarded – undo
808 808
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
809 809
 				try {
810 810
 					$sth = $this->db->prepare($query);
811
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
812
-				} catch(PDOException $e) {
811
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
812
+				} catch (PDOException $e) {
813 813
 					echo "error : ".$e->getMessage();
814 814
 				}
815 815
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
816 816
 			} else $all = array();
817 817
 		}
818 818
 		if (empty($all)) {
819
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
820
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
819
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
820
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
821 821
 			} else {
822
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
822
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
823 823
 			}
824 824
 			if ($filter_name != '') {
825
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
825
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
826 826
 			}
827 827
 			$Spotter = new Spotter($this->db);
828 828
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
829 829
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
830
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
831
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
830
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
831
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
832 832
 			$all = array();
833 833
 			foreach ($pall as $value) {
834 834
 				$icao = $value['airport_arrival_icao'];
@@ -844,26 +844,26 @@  discard block
 block discarded – undo
844 844
 			foreach ($all as $key => $row) {
845 845
 				$count[$key] = $row['airport_arrival_icao_count'];
846 846
 			}
847
-			array_multisort($count,SORT_DESC,$all);
847
+			array_multisort($count, SORT_DESC, $all);
848 848
 		}
849 849
 		return $all;
850 850
 	}
851
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
851
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
852 852
 		global $globalDBdriver, $globalStatsFilters;
853 853
 		if ($filter_name == '') $filter_name = $this->filter_name;
854
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
854
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
855 855
 			$Spotter = new Spotter($this->db);
856
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
856
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
857 857
 			$alliance_airlines = array();
858 858
 			foreach ($airlines as $airline) {
859
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
859
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
860 860
 			}
861 861
 			if ($globalDBdriver == 'mysql') {
862
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
864 864
 			} else {
865
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
867 867
 			}
868 868
 			$query_data = array(':filter_name' => $filter_name);
869 869
 		} else {
@@ -874,23 +874,23 @@  discard block
 block discarded – undo
874 874
 				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
875 875
 				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
876 876
 			}
877
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
877
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
878 878
 		}
879 879
 		try {
880 880
 			$sth = $this->db->prepare($query);
881 881
 			$sth->execute($query_data);
882
-		} catch(PDOException $e) {
882
+		} catch (PDOException $e) {
883 883
 			echo "error : ".$e->getMessage();
884 884
 		}
885 885
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
886 886
 		if (empty($all)) {
887
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
888
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
887
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
888
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
889 889
 			} else {
890 890
 				$filters = array('airlines' => array($stats_airline));
891 891
 			}
892 892
 			if ($filter_name != '') {
893
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
893
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
894 894
 			}
895 895
 			$Spotter = new Spotter($this->db);
896 896
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -898,57 +898,57 @@  discard block
 block discarded – undo
898 898
 		return $all;
899 899
 	}
900 900
 	
901
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
901
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
902 902
 		global $globalStatsFilters;
903 903
 		if ($filter_name == '') $filter_name = $this->filter_name;
904
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
904
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
905 905
 			$Spotter = new Spotter($this->db);
906
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
906
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
907 907
 			$alliance_airlines = array();
908 908
 			foreach ($airlines as $airline) {
909
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
909
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
910 910
 			}
911
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
911
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
912 912
 			$query_data = array(':filter_name' => $filter_name);
913 913
 		} else {
914 914
 			$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";
915
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
915
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
916 916
 		}
917 917
 		try {
918 918
 			$sth = $this->db->prepare($query);
919 919
 			$sth->execute($query_data);
920
-		} catch(PDOException $e) {
920
+		} catch (PDOException $e) {
921 921
 			echo "error : ".$e->getMessage();
922 922
 		}
923 923
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
924 924
 		if (empty($all)) {
925
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
926
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
925
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
926
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
927 927
 			} else {
928 928
 				$filters = array('airlines' => array($stats_airline));
929 929
 			}
930 930
 			if ($filter_name != '') {
931
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
931
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
932 932
 			}
933 933
 			$Spotter = new Spotter($this->db);
934 934
 			$all = $Spotter->countAllDatesLastMonth($filters);
935 935
 		}
936 936
 		return $all;
937 937
 	}
938
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
938
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
939 939
 		global $globalDBdriver, $globalStatsFilters;
940 940
 		if ($filter_name == '') $filter_name = $this->filter_name;
941
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
941
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
942 942
 			$Spotter = new Spotter($this->db);
943
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
943
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
944 944
 			$alliance_airlines = array();
945 945
 			foreach ($airlines as $airline) {
946
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
946
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
947 947
 			}
948 948
 			if ($globalDBdriver == 'mysql') {
949
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
949
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
950 950
 			} else {
951
-				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
951
+				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
952 952
 			}
953 953
 			$query_data = array(':filter_name' => $filter_name);
954 954
 		} else {
@@ -957,60 +957,60 @@  discard block
 block discarded – undo
957 957
 			} else {
958 958
 				$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";
959 959
 			}
960
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
960
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
961 961
 		}
962 962
 		try {
963 963
 			$sth = $this->db->prepare($query);
964 964
 			$sth->execute($query_data);
965
-		} catch(PDOException $e) {
965
+		} catch (PDOException $e) {
966 966
 			echo "error : ".$e->getMessage();
967 967
 		}
968 968
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
969 969
 		if (empty($all)) {
970
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
971
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
970
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
971
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
972 972
 			} else {
973 973
 				$filters = array('airlines' => array($stats_airline));
974 974
 			}
975 975
 			if ($filter_name != '') {
976
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
976
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
977 977
 			}
978 978
 			$Spotter = new Spotter($this->db);
979 979
 			$all = $Spotter->countAllDatesLast7Days($filters);
980 980
 		}
981 981
 		return $all;
982 982
 	}
983
-	public function countAllDates($stats_airline = '',$filter_name = '') {
983
+	public function countAllDates($stats_airline = '', $filter_name = '') {
984 984
 		global $globalStatsFilters;
985 985
 		if ($filter_name == '') $filter_name = $this->filter_name;
986
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
986
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
987 987
 			$Spotter = new Spotter($this->db);
988
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
988
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
989 989
 			$alliance_airlines = array();
990 990
 			foreach ($airlines as $airline) {
991
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
991
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
992 992
 			}
993
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
993
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
994 994
 			$query_data = array(':filter_name' => $filter_name);
995 995
 		} else {
996 996
 			$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 ORDER BY date_count DESC";
997
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
997
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
998 998
 		}
999 999
 		try {
1000 1000
 			$sth = $this->db->prepare($query);
1001 1001
 			$sth->execute($query_data);
1002
-		} catch(PDOException $e) {
1002
+		} catch (PDOException $e) {
1003 1003
 			echo "error : ".$e->getMessage();
1004 1004
 		}
1005 1005
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1006 1006
 		if (empty($all)) {
1007
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1008
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1007
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1008
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1009 1009
 			} else {
1010 1010
 				$filters = array('airlines' => array($stats_airline));
1011 1011
 			}
1012 1012
 			if ($filter_name != '') {
1013
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1013
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1014 1014
 			}
1015 1015
 			$Spotter = new Spotter($this->db);
1016 1016
 			$all = $Spotter->countAllDates($filters);
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 		try {
1026 1026
 			$sth = $this->db->prepare($query);
1027 1027
 			$sth->execute($query_data);
1028
-		} catch(PDOException $e) {
1028
+		} catch (PDOException $e) {
1029 1029
 			echo "error : ".$e->getMessage();
1030 1030
 		}
1031 1031
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 		try {
1048 1048
 			$sth = $this->db->prepare($query);
1049 1049
 			$sth->execute($query_data);
1050
-		} catch(PDOException $e) {
1050
+		} catch (PDOException $e) {
1051 1051
 			echo "error : ".$e->getMessage();
1052 1052
 		}
1053 1053
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1069,34 +1069,34 @@  discard block
 block discarded – undo
1069 1069
 		try {
1070 1070
 			$sth = $this->db->prepare($query);
1071 1071
 			$sth->execute($query_data);
1072
-		} catch(PDOException $e) {
1072
+		} catch (PDOException $e) {
1073 1073
 			echo "error : ".$e->getMessage();
1074 1074
 		}
1075 1075
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1076 1076
 		if (empty($all)) {
1077 1077
 			$filters = array();
1078 1078
 			if ($filter_name != '') {
1079
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1079
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1080 1080
 			}
1081 1081
 			$Spotter = new Spotter($this->db);
1082 1082
 			$all = $Spotter->countAllDatesByAirlines($filters);
1083 1083
 		}
1084 1084
 		return $all;
1085 1085
 	}
1086
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1086
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1087 1087
 		global $globalStatsFilters, $globalDBdriver;
1088 1088
 		if ($filter_name == '') $filter_name = $this->filter_name;
1089
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1089
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1090 1090
 			$Spotter = new Spotter($this->db);
1091
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1091
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1092 1092
 			$alliance_airlines = array();
1093 1093
 			foreach ($airlines as $airline) {
1094
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1094
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1095 1095
 			}
1096 1096
 			if ($globalDBdriver == 'mysql') {
1097
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1097
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1098 1098
 			} else {
1099
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1099
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1100 1100
 			}
1101 1101
 			$query_data = array(':filter_name' => $filter_name);
1102 1102
 		} else {
@@ -1110,18 +1110,18 @@  discard block
 block discarded – undo
1110 1110
 		try {
1111 1111
 			$sth = $this->db->prepare($query);
1112 1112
 			$sth->execute($query_data);
1113
-		} catch(PDOException $e) {
1113
+		} catch (PDOException $e) {
1114 1114
 			echo "error : ".$e->getMessage();
1115 1115
 		}
1116 1116
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1117 1117
 		if (empty($all)) {
1118
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1119
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1118
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1119
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1120 1120
 			} else {
1121 1121
 				$filters = array('airlines' => array($stats_airline));
1122 1122
 			}
1123 1123
 			if ($filter_name != '') {
1124
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1124
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1125 1125
 			}
1126 1126
 			$Spotter = new Spotter($this->db);
1127 1127
 			$all = $Spotter->countAllMonths($filters);
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
1140 1140
 			$sth->execute();
1141
-		} catch(PDOException $e) {
1141
+		} catch (PDOException $e) {
1142 1142
 			echo "error : ".$e->getMessage();
1143 1143
 		}
1144 1144
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$sth = $this->db->prepare($query);
1160 1160
 			$sth->execute();
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			echo "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1175,32 +1175,32 @@  discard block
 block discarded – undo
1175 1175
 		try {
1176 1176
 			$sth = $this->db->prepare($query);
1177 1177
 			$sth->execute(array(':filter_name' => $filter_name));
1178
-		} catch(PDOException $e) {
1178
+		} catch (PDOException $e) {
1179 1179
 			echo "error : ".$e->getMessage();
1180 1180
 		}
1181 1181
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1182 1182
 		if (empty($all)) {
1183 1183
 			$filters = array();
1184 1184
 			if ($filter_name != '') {
1185
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1185
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1186 1186
 			}
1187 1187
 			$Spotter = new Spotter($this->db);
1188 1188
 			$all = $Spotter->countAllMilitaryMonths($filters);
1189 1189
 		}
1190 1190
 		return $all;
1191 1191
 	}
1192
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1192
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1193 1193
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1194 1194
 		if ($filter_name == '') $filter_name = $this->filter_name;
1195
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1195
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1196 1196
 			$Spotter = new Spotter($this->db);
1197
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1197
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1198 1198
 			$alliance_airlines = array();
1199 1199
 			foreach ($airlines as $airline) {
1200
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1200
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1201 1201
 			}
1202
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1203
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1202
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1203
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1204 1204
 			$query_data = array(':filter_name' => $filter_name);
1205 1205
 		} else {
1206 1206
 			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1218,37 +1218,37 @@  discard block
 block discarded – undo
1218 1218
 		try {
1219 1219
 			$sth = $this->db->prepare($query);
1220 1220
 			$sth->execute($query_data);
1221
-		} catch(PDOException $e) {
1221
+		} catch (PDOException $e) {
1222 1222
 			echo "error : ".$e->getMessage();
1223 1223
 		}
1224 1224
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1225 1225
 		if (empty($all)) {
1226
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1227
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1226
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1227
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1228 1228
 			} else {
1229 1229
 				$filters = array('airlines' => array($stats_airline));
1230 1230
 			}
1231 1231
 			if ($filter_name != '') {
1232
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1232
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1233 1233
 			}
1234 1234
 			$Spotter = new Spotter($this->db);
1235
-			$all = $Spotter->countAllHours($orderby,$filters);
1235
+			$all = $Spotter->countAllHours($orderby, $filters);
1236 1236
 		}
1237 1237
 		return $all;
1238 1238
 	}
1239
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1239
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1240 1240
 		global $globalStatsFilters;
1241 1241
 		if ($filter_name == '') $filter_name = $this->filter_name;
1242 1242
 		if ($year == '') $year = date('Y');
1243
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1243
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1244 1244
 		if (empty($all)) {
1245
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1246
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1245
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1246
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1247 1247
 			} else {
1248
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1248
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1249 1249
 			}
1250 1250
 			if ($filter_name != '') {
1251
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1251
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1252 1252
 			}
1253 1253
 			$Spotter = new Spotter($this->db);
1254 1254
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1256,15 +1256,15 @@  discard block
 block discarded – undo
1256 1256
 		}
1257 1257
 		return $all;
1258 1258
 	}
1259
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1259
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1260 1260
 		global $globalStatsFilters;
1261 1261
 		if ($filter_name == '') $filter_name = $this->filter_name;
1262 1262
 		if ($year == '') $year = date('Y');
1263
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1263
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1264 1264
 		if (empty($all)) {
1265
-			$filters = array('year' => $year,'month' => $month);
1265
+			$filters = array('year' => $year, 'month' => $month);
1266 1266
 			if ($filter_name != '') {
1267
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1267
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1268 1268
 			}
1269 1269
 			$Marine = new Marine($this->db);
1270 1270
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1272,15 +1272,15 @@  discard block
 block discarded – undo
1272 1272
 		}
1273 1273
 		return $all;
1274 1274
 	}
1275
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1275
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1276 1276
 		global $globalStatsFilters;
1277 1277
 		if ($filter_name == '') $filter_name = $this->filter_name;
1278 1278
 		if ($year == '') $year = date('Y');
1279
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1279
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1280 1280
 		if (empty($all)) {
1281
-			$filters = array('year' => $year,'month' => $month);
1281
+			$filters = array('year' => $year, 'month' => $month);
1282 1282
 			if ($filter_name != '') {
1283
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1283
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1284 1284
 			}
1285 1285
 			$Tracker = new Tracker($this->db);
1286 1286
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1288,16 +1288,16 @@  discard block
 block discarded – undo
1288 1288
 		}
1289 1289
 		return $all;
1290 1290
 	}
1291
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1291
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1292 1292
 		global $globalStatsFilters;
1293 1293
 		if ($filter_name == '') $filter_name = $this->filter_name;
1294 1294
 		if ($year == '') $year = date('Y');
1295
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1295
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1296 1296
 		if (empty($all)) {
1297 1297
 			$filters = array();
1298
-			$filters = array('year' => $year,'month' => $month);
1298
+			$filters = array('year' => $year, 'month' => $month);
1299 1299
 			if ($filter_name != '') {
1300
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1300
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1301 1301
 			}
1302 1302
 			$Spotter = new Spotter($this->db);
1303 1303
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1305,19 +1305,19 @@  discard block
 block discarded – undo
1305 1305
 		}
1306 1306
 		return $all;
1307 1307
 	}
1308
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1308
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1309 1309
 		global $globalStatsFilters;
1310 1310
 		if ($filter_name == '') $filter_name = $this->filter_name;
1311 1311
 		if ($year == '') $year = date('Y');
1312
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1312
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1313 1313
 		if (empty($all)) {
1314
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1315
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1314
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1315
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1316 1316
 			} else {
1317
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1317
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1318 1318
 			}
1319 1319
 			if ($filter_name != '') {
1320
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1320
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1321 1321
 			}
1322 1322
 			$Spotter = new Spotter($this->db);
1323 1323
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1325,48 +1325,48 @@  discard block
 block discarded – undo
1325 1325
 		}
1326 1326
 		return $all;
1327 1327
 	}
1328
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1328
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1329 1329
 		global $globalStatsFilters;
1330 1330
 		if ($filter_name == '') $filter_name = $this->filter_name;
1331
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1331
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1332 1332
 			$Spotter = new Spotter($this->db);
1333
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1333
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1334 1334
 			if ($year == '' && $month == '') {
1335 1335
 				$alliance_airlines = array();
1336 1336
 				foreach ($airlines as $airline) {
1337
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1337
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1338 1338
 				}
1339
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1339
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1340 1340
 				try {
1341 1341
 					$sth = $this->db->prepare($query);
1342 1342
 					$sth->execute(array(':filter_name' => $filter_name));
1343
-				} catch(PDOException $e) {
1343
+				} catch (PDOException $e) {
1344 1344
 					echo "error : ".$e->getMessage();
1345 1345
 				}
1346 1346
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1347 1347
 				$all = $result[0]['nb'];
1348
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1348
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1349 1349
 		} else {
1350 1350
 			if ($year == '' && $month == '') {
1351 1351
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1352 1352
 				try {
1353 1353
 					$sth = $this->db->prepare($query);
1354
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1355
-				} catch(PDOException $e) {
1354
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1355
+				} catch (PDOException $e) {
1356 1356
 					echo "error : ".$e->getMessage();
1357 1357
 				}
1358 1358
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1359 1359
 				$all = $result[0]['nb'];
1360
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1360
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1361 1361
 		}
1362 1362
 		if (empty($all)) {
1363
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1364
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1363
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1364
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1365 1365
 			} else {
1366
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1366
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1367 1367
 			}
1368 1368
 			if ($filter_name != '') {
1369
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1369
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1370 1370
 			}
1371 1371
 			$Spotter = new Spotter($this->db);
1372 1372
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 		}
1375 1375
 		return $all;
1376 1376
 	}
1377
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1377
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1378 1378
 		global $globalStatsFilters;
1379 1379
 		if ($filter_name == '') $filter_name = $this->filter_name;
1380 1380
 		if ($year == '' && $month == '') {
@@ -1382,17 +1382,17 @@  discard block
 block discarded – undo
1382 1382
 			try {
1383 1383
 				$sth = $this->db->prepare($query);
1384 1384
 				$sth->execute(array(':filter_name' => $filter_name));
1385
-			} catch(PDOException $e) {
1385
+			} catch (PDOException $e) {
1386 1386
 				echo "error : ".$e->getMessage();
1387 1387
 			}
1388 1388
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1389 1389
 			$all = $result[0]['nb_airline'];
1390
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1390
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1391 1391
 		if (empty($all)) {
1392 1392
 			$filters = array();
1393
-			$filters = array('year' => $year,'month' => $month);
1393
+			$filters = array('year' => $year, 'month' => $month);
1394 1394
 			if ($filter_name != '') {
1395
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1395
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1396 1396
 			}
1397 1397
 			$Spotter = new Spotter($this->db);
1398 1398
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		}
1401 1401
 		return $all;
1402 1402
 	}
1403
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1403
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1404 1404
 		global $globalStatsFilters;
1405 1405
 		if ($filter_name == '') $filter_name = $this->filter_name;
1406 1406
 		$all = array();
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 			try {
1410 1410
 				$sth = $this->db->prepare($query);
1411 1411
 				$sth->execute(array(':filter_name' => $filter_name));
1412
-			} catch(PDOException $e) {
1412
+			} catch (PDOException $e) {
1413 1413
 				echo "error : ".$e->getMessage();
1414 1414
 			}
1415 1415
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1417,9 +1417,9 @@  discard block
 block discarded – undo
1417 1417
 		}
1418 1418
 		if (empty($all)) {
1419 1419
 			$filters = array();
1420
-			$filters = array('year' => $year,'month' => $month);
1420
+			$filters = array('year' => $year, 'month' => $month);
1421 1421
 			if ($filter_name != '') {
1422
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1422
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1423 1423
 			}
1424 1424
 			$Marine = new Marine($this->db);
1425 1425
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1427,29 +1427,29 @@  discard block
 block discarded – undo
1427 1427
 		}
1428 1428
 		return $all;
1429 1429
 	}
1430
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1430
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1431 1431
 		global $globalStatsFilters;
1432 1432
 		if ($filter_name == '') $filter_name = $this->filter_name;
1433
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1433
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1434 1434
 			$Spotter = new Spotter($this->db);
1435
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1435
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1436 1436
 			if ($year == '' && $month == '') {
1437 1437
 				$alliance_airlines = array();
1438 1438
 				foreach ($airlines as $airline) {
1439
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1439
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1440 1440
 				}
1441
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1441
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1442 1442
 				$query_values = array(':filter_name' => $filter_name);
1443 1443
 				try {
1444 1444
 					$sth = $this->db->prepare($query);
1445 1445
 					$sth->execute($query_values);
1446
-				} catch(PDOException $e) {
1446
+				} catch (PDOException $e) {
1447 1447
 					echo "error : ".$e->getMessage();
1448 1448
 				}
1449 1449
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1450 1450
 				$all = $result[0]['nb'];
1451 1451
 			} else {
1452
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1452
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1453 1453
 			}
1454 1454
 		} else {
1455 1455
 			if ($year == '' && $month == '') {
@@ -1458,23 +1458,23 @@  discard block
 block discarded – undo
1458 1458
 				try {
1459 1459
 					$sth = $this->db->prepare($query);
1460 1460
 					$sth->execute($query_values);
1461
-				} catch(PDOException $e) {
1461
+				} catch (PDOException $e) {
1462 1462
 					echo "error : ".$e->getMessage();
1463 1463
 				}
1464 1464
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1465 1465
 				$all = $result[0]['nb'];
1466 1466
 			} else {
1467
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1467
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1468 1468
 			}
1469 1469
 		}
1470 1470
 		if (empty($all)) {
1471
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1472
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1471
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1472
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1473 1473
 			} else {
1474
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1474
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1475 1475
 			}
1476 1476
 			if ($filter_name != '') {
1477
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1477
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1478 1478
 			}
1479 1479
 			$Spotter = new Spotter($this->db);
1480 1480
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 		}
1483 1483
 		return $all;
1484 1484
 	}
1485
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1485
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1486 1486
 		global $globalStatsFilters;
1487 1487
 		if ($filter_name == '') $filter_name = $this->filter_name;
1488 1488
 		//if ($year == '') $year = date('Y');
@@ -1492,18 +1492,18 @@  discard block
 block discarded – undo
1492 1492
 			try {
1493 1493
 				$sth = $this->db->prepare($query);
1494 1494
 				$sth->execute($query_values);
1495
-			} catch(PDOException $e) {
1495
+			} catch (PDOException $e) {
1496 1496
 				echo "error : ".$e->getMessage();
1497 1497
 			}
1498 1498
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1499 1499
 			$all = $result[0]['nb'];
1500 1500
 		} else {
1501
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1501
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1502 1502
 		}
1503 1503
 		if (empty($all)) {
1504
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1504
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1505 1505
 			if ($filter_name != '') {
1506
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1506
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1507 1507
 			}
1508 1508
 			$Spotter = new Spotter($this->db);
1509 1509
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1512,104 +1512,104 @@  discard block
 block discarded – undo
1512 1512
 		return $all;
1513 1513
 	}
1514 1514
 
1515
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1515
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1516 1516
 		if ($filter_name == '') $filter_name = $this->filter_name;
1517
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1517
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1518 1518
 			$Spotter = new Spotter($this->db);
1519
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1519
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1520 1520
 			$alliance_airlines = array();
1521 1521
 			foreach ($airlines as $airline) {
1522
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1522
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1523 1523
 			}
1524
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1525
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1524
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1525
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1526 1526
 		} else {
1527 1527
 			$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";
1528
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1528
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1529 1529
 		}
1530 1530
 		try {
1531 1531
 			$sth = $this->db->prepare($query);
1532 1532
 			$sth->execute($query_values);
1533
-		} catch(PDOException $e) {
1533
+		} catch (PDOException $e) {
1534 1534
 			echo "error : ".$e->getMessage();
1535 1535
 		}
1536 1536
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1537 1537
 		return $all;
1538 1538
 	}
1539
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1539
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1540 1540
 		if ($filter_name == '') $filter_name = $this->filter_name;
1541 1541
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1542
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1542
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1543 1543
 		try {
1544 1544
 			$sth = $this->db->prepare($query);
1545 1545
 			$sth->execute($query_values);
1546
-		} catch(PDOException $e) {
1546
+		} catch (PDOException $e) {
1547 1547
 			echo "error : ".$e->getMessage();
1548 1548
 		}
1549 1549
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1550 1550
 		return $all;
1551 1551
 	}
1552
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1552
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1553 1553
 		if ($filter_name == '') $filter_name = $this->filter_name;
1554 1554
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1555
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1555
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1556 1556
 		try {
1557 1557
 			$sth = $this->db->prepare($query);
1558 1558
 			$sth->execute($query_values);
1559
-		} catch(PDOException $e) {
1559
+		} catch (PDOException $e) {
1560 1560
 			echo "error : ".$e->getMessage();
1561 1561
 		}
1562 1562
 	}
1563
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1563
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1564 1564
 		if ($filter_name == '') $filter_name = $this->filter_name;
1565 1565
 		global $globalArchiveMonths, $globalDBdriver;
1566
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1566
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1567 1567
 			$Spotter = new Spotter($this->db);
1568
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1568
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1569 1569
 			$alliance_airlines = array();
1570 1570
 			foreach ($airlines as $airline) {
1571
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1571
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1572 1572
 			}
1573 1573
 			if ($globalDBdriver == 'mysql') {
1574 1574
 				if ($month == '') {
1575
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1575
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1576 1576
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1577 1577
 				} else {
1578
-					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1579
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1578
+					$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1579
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1580 1580
 				}
1581 1581
 			} else {
1582 1582
 				if ($month == '') {
1583
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1583
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1584 1584
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1585 1585
 				} else {
1586
-					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1587
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1586
+					$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1587
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1588 1588
 				}
1589 1589
 			}
1590 1590
 		} else {
1591 1591
 			if ($globalDBdriver == 'mysql') {
1592 1592
 				if ($month == '') {
1593 1593
 					$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";
1594
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1594
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1595 1595
 				} else {
1596 1596
 					$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";
1597
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1597
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1598 1598
 				}
1599 1599
 			} else {
1600 1600
 				if ($month == '') {
1601 1601
 					$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";
1602
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1602
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1603 1603
 				} else {
1604 1604
 					$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";
1605
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1605
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1606 1606
 				}
1607 1607
 			}
1608 1608
 		}
1609 1609
 		try {
1610 1610
 			$sth = $this->db->prepare($query);
1611 1611
 			$sth->execute($query_values);
1612
-		} catch(PDOException $e) {
1612
+		} catch (PDOException $e) {
1613 1613
 			echo "error : ".$e->getMessage();
1614 1614
 		}
1615 1615
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1618,17 +1618,17 @@  discard block
 block discarded – undo
1618 1618
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1619 1619
 		global $globalArchiveMonths, $globalDBdriver;
1620 1620
 		if ($filter_name == '') $filter_name = $this->filter_name;
1621
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1621
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1622 1622
 			$Spotter = new Spotter($this->db);
1623
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1623
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1624 1624
 			$alliance_airlines = array();
1625 1625
 			foreach ($airlines as $airline) {
1626
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1626
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1627 1627
 			}
1628 1628
 			if ($globalDBdriver == 'mysql') {
1629
-				$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1629
+				$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1630 1630
 			} else {
1631
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1631
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1632 1632
 			}
1633 1633
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1634 1634
 		} else {
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
 		try {
1643 1643
 			$sth = $this->db->prepare($query);
1644 1644
 			$sth->execute($query_values);
1645
-		} catch(PDOException $e) {
1645
+		} catch (PDOException $e) {
1646 1646
 			echo "error : ".$e->getMessage();
1647 1647
 		}
1648 1648
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1651,17 +1651,17 @@  discard block
 block discarded – undo
1651 1651
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1652 1652
 		global $globalArchiveMonths, $globalDBdriver;
1653 1653
 		if ($filter_name == '') $filter_name = $this->filter_name;
1654
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1654
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1655 1655
 			$Spotter = new Spotter($this->db);
1656
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1656
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1657 1657
 			$alliance_airlines = array();
1658 1658
 			foreach ($airlines as $airline) {
1659
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1659
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1660 1660
 			}
1661 1661
 			if ($globalDBdriver == 'mysql') {
1662
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1662
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1663 1663
 			} else {
1664
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1664
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1665 1665
 			}
1666 1666
 		} else {
1667 1667
 			if ($globalDBdriver == 'mysql') {
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 		try {
1674 1674
 			$sth = $this->db->prepare($query);
1675 1675
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1676
-		} catch(PDOException $e) {
1676
+		} catch (PDOException $e) {
1677 1677
 			echo "error : ".$e->getMessage();
1678 1678
 		}
1679 1679
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 		try {
1691 1691
 			$sth = $this->db->prepare($query);
1692 1692
 			$sth->execute(array(':filter_name' => $filter_name));
1693
-		} catch(PDOException $e) {
1693
+		} catch (PDOException $e) {
1694 1694
 			echo "error : ".$e->getMessage();
1695 1695
 		}
1696 1696
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1707,20 +1707,20 @@  discard block
 block discarded – undo
1707 1707
 		try {
1708 1708
 			$sth = $this->db->prepare($query);
1709 1709
 			$sth->execute(array(':filter_name' => $filter_name));
1710
-		} catch(PDOException $e) {
1710
+		} catch (PDOException $e) {
1711 1711
 			echo "error : ".$e->getMessage();
1712 1712
 		}
1713 1713
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1714 1714
 		return $all[0]['total'];
1715 1715
 	}
1716
-	public function getStatsOwner($owner_name,$filter_name = '') {
1716
+	public function getStatsOwner($owner_name, $filter_name = '') {
1717 1717
 		global $globalArchiveMonths, $globalDBdriver;
1718 1718
 		if ($filter_name == '') $filter_name = $this->filter_name;
1719 1719
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1720 1720
 		try {
1721 1721
 			$sth = $this->db->prepare($query);
1722
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1723
-		} catch(PDOException $e) {
1722
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1723
+		} catch (PDOException $e) {
1724 1724
 			echo "error : ".$e->getMessage();
1725 1725
 		}
1726 1726
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1738,20 +1738,20 @@  discard block
 block discarded – undo
1738 1738
 		try {
1739 1739
 			$sth = $this->db->prepare($query);
1740 1740
 			$sth->execute(array(':filter_name' => $filter_name));
1741
-		} catch(PDOException $e) {
1741
+		} catch (PDOException $e) {
1742 1742
 			echo "error : ".$e->getMessage();
1743 1743
 		}
1744 1744
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1745 1745
 		return $all[0]['total'];
1746 1746
 	}
1747
-	public function getStatsPilot($pilot,$filter_name = '') {
1747
+	public function getStatsPilot($pilot, $filter_name = '') {
1748 1748
 		global $globalArchiveMonths, $globalDBdriver;
1749 1749
 		if ($filter_name == '') $filter_name = $this->filter_name;
1750 1750
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1751 1751
 		try {
1752 1752
 			$sth = $this->db->prepare($query);
1753
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1754
-		} catch(PDOException $e) {
1753
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1754
+		} catch (PDOException $e) {
1755 1755
 			echo "error : ".$e->getMessage();
1756 1756
 		}
1757 1757
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 		else return 0;
1760 1760
 	}
1761 1761
 
1762
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1762
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1763 1763
 		global $globalDBdriver;
1764 1764
 		if ($filter_name == '') $filter_name = $this->filter_name;
1765 1765
 		if ($globalDBdriver == 'mysql') {
@@ -1767,15 +1767,15 @@  discard block
 block discarded – undo
1767 1767
 		} else {
1768 1768
 			$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);"; 
1769 1769
 		}
1770
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1770
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1771 1771
 		try {
1772 1772
 			$sth = $this->db->prepare($query);
1773 1773
 			$sth->execute($query_values);
1774
-		} catch(PDOException $e) {
1774
+		} catch (PDOException $e) {
1775 1775
 			return "error : ".$e->getMessage();
1776 1776
 		}
1777 1777
 	}
1778
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1778
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1779 1779
 		global $globalDBdriver;
1780 1780
 		if ($filter_name == '') $filter_name = $this->filter_name;
1781 1781
 		if ($globalDBdriver == 'mysql') {
@@ -1784,11 +1784,11 @@  discard block
 block discarded – undo
1784 1784
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1785 1785
 			$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);"; 
1786 1786
 		}
1787
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1787
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1788 1788
 		try {
1789 1789
 			$sth = $this->db->prepare($query);
1790 1790
 			$sth->execute($query_values);
1791
-		} catch(PDOException $e) {
1791
+		} catch (PDOException $e) {
1792 1792
 			return "error : ".$e->getMessage();
1793 1793
 		}
1794 1794
 	}
@@ -1812,95 +1812,95 @@  discard block
 block discarded – undo
1812 1812
         }
1813 1813
         */
1814 1814
 
1815
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1815
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1816 1816
 		global $globalDBdriver;
1817 1817
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1818 1818
 		$query_values = array();
1819 1819
 		if ($globalDBdriver == 'mysql') {
1820 1820
 			if ($year != '') {
1821 1821
 				$query .= ' AND YEAR(stats_date) = :year';
1822
-				$query_values = array_merge($query_values,array(':year' => $year));
1822
+				$query_values = array_merge($query_values, array(':year' => $year));
1823 1823
 			}
1824 1824
 			if ($month != '') {
1825 1825
 				$query .= ' AND MONTH(stats_date) = :month';
1826
-				$query_values = array_merge($query_values,array(':month' => $month));
1826
+				$query_values = array_merge($query_values, array(':month' => $month));
1827 1827
 			}
1828 1828
 			if ($day != '') {
1829 1829
 				$query .= ' AND DAY(stats_date) = :day';
1830
-				$query_values = array_merge($query_values,array(':day' => $day));
1830
+				$query_values = array_merge($query_values, array(':day' => $day));
1831 1831
 			}
1832 1832
 		} else {
1833 1833
 			if ($year != '') {
1834 1834
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1835
-				$query_values = array_merge($query_values,array(':year' => $year));
1835
+				$query_values = array_merge($query_values, array(':year' => $year));
1836 1836
 			}
1837 1837
 			if ($month != '') {
1838 1838
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1839
-				$query_values = array_merge($query_values,array(':month' => $month));
1839
+				$query_values = array_merge($query_values, array(':month' => $month));
1840 1840
 			}
1841 1841
 			if ($day != '') {
1842 1842
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1843
-				$query_values = array_merge($query_values,array(':day' => $day));
1843
+				$query_values = array_merge($query_values, array(':day' => $day));
1844 1844
 			}
1845 1845
 		}
1846 1846
 		$query .= " ORDER BY source_name";
1847
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1847
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1848 1848
 		try {
1849 1849
 			$sth = $this->db->prepare($query);
1850 1850
 			$sth->execute($query_values);
1851
-		} catch(PDOException $e) {
1851
+		} catch (PDOException $e) {
1852 1852
 			echo "error : ".$e->getMessage();
1853 1853
 		}
1854 1854
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1855 1855
 		return $all;
1856 1856
 	}
1857 1857
 
1858
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1858
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1859 1859
 		global $globalDBdriver;
1860 1860
 		if ($globalDBdriver == 'mysql') {
1861 1861
 			$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";
1862 1862
 		} else {
1863 1863
 			$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);"; 
1864 1864
 		}
1865
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1865
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1866 1866
 		try {
1867 1867
 			$sth = $this->db->prepare($query);
1868 1868
 			$sth->execute($query_values);
1869
-		} catch(PDOException $e) {
1869
+		} catch (PDOException $e) {
1870 1870
 			return "error : ".$e->getMessage();
1871 1871
 		}
1872 1872
 	}
1873
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1873
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1874 1874
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1875
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1875
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1876 1876
 		try {
1877 1877
 			$sth = $this->db->prepare($query);
1878 1878
 			$sth->execute($query_values);
1879
-		} catch(PDOException $e) {
1879
+		} catch (PDOException $e) {
1880 1880
 			return "error : ".$e->getMessage();
1881 1881
 		}
1882 1882
 	}
1883
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1883
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
1884 1884
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1885
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1885
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1886 1886
 		try {
1887 1887
 			$sth = $this->db->prepare($query);
1888 1888
 			$sth->execute($query_values);
1889
-		} catch(PDOException $e) {
1889
+		} catch (PDOException $e) {
1890 1890
 			return "error : ".$e->getMessage();
1891 1891
 		}
1892 1892
 	}
1893
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
1893
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
1894 1894
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1895
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1895
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1896 1896
 		try {
1897 1897
 			$sth = $this->db->prepare($query);
1898 1898
 			$sth->execute($query_values);
1899
-		} catch(PDOException $e) {
1899
+		} catch (PDOException $e) {
1900 1900
 			return "error : ".$e->getMessage();
1901 1901
 		}
1902 1902
 	}
1903
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1903
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1904 1904
 		global $globalDBdriver;
1905 1905
 		if ($globalDBdriver == 'mysql') {
1906 1906
 			if ($reset) {
@@ -1915,15 +1915,15 @@  discard block
 block discarded – undo
1915 1915
 				$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);"; 
1916 1916
 			}
1917 1917
 		}
1918
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1918
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1919 1919
 		try {
1920 1920
 			$sth = $this->db->prepare($query);
1921 1921
 			$sth->execute($query_values);
1922
-		} catch(PDOException $e) {
1922
+		} catch (PDOException $e) {
1923 1923
 			return "error : ".$e->getMessage();
1924 1924
 		}
1925 1925
 	}
1926
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1926
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1927 1927
 		global $globalDBdriver;
1928 1928
 		if ($globalDBdriver == 'mysql') {
1929 1929
 			if ($reset) {
@@ -1938,15 +1938,15 @@  discard block
 block discarded – undo
1938 1938
 				$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);"; 
1939 1939
 			}
1940 1940
 		}
1941
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1941
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1942 1942
 		try {
1943 1943
 			$sth = $this->db->prepare($query);
1944 1944
 			$sth->execute($query_values);
1945
-		} catch(PDOException $e) {
1945
+		} catch (PDOException $e) {
1946 1946
 			return "error : ".$e->getMessage();
1947 1947
 		}
1948 1948
 	}
1949
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1949
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1950 1950
 		global $globalDBdriver;
1951 1951
 		if ($globalDBdriver == 'mysql') {
1952 1952
 			if ($reset) {
@@ -1961,15 +1961,15 @@  discard block
 block discarded – undo
1961 1961
 				$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);"; 
1962 1962
 			}
1963 1963
 		}
1964
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1964
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1965 1965
 		try {
1966 1966
 			$sth = $this->db->prepare($query);
1967 1967
 			$sth->execute($query_values);
1968
-		} catch(PDOException $e) {
1968
+		} catch (PDOException $e) {
1969 1969
 			return "error : ".$e->getMessage();
1970 1970
 		}
1971 1971
 	}
1972
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1972
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1973 1973
 		global $globalDBdriver;
1974 1974
 		if ($globalDBdriver == 'mysql') {
1975 1975
 			if ($reset) {
@@ -1984,15 +1984,15 @@  discard block
 block discarded – undo
1984 1984
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1985 1985
 			}
1986 1986
 		}
1987
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1987
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1988 1988
 		try {
1989 1989
 			$sth = $this->db->prepare($query);
1990 1990
 			$sth->execute($query_values);
1991
-		} catch(PDOException $e) {
1991
+		} catch (PDOException $e) {
1992 1992
 			return "error : ".$e->getMessage();
1993 1993
 		}
1994 1994
 	}
1995
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1995
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1996 1996
 		global $globalDBdriver;
1997 1997
 		if ($globalDBdriver == 'mysql') {
1998 1998
 			if ($reset) {
@@ -2007,15 +2007,15 @@  discard block
 block discarded – undo
2007 2007
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2008 2008
 			}
2009 2009
 		}
2010
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2010
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2011 2011
 		try {
2012 2012
 			$sth = $this->db->prepare($query);
2013 2013
 			$sth->execute($query_values);
2014
-		} catch(PDOException $e) {
2014
+		} catch (PDOException $e) {
2015 2015
 			return "error : ".$e->getMessage();
2016 2016
 		}
2017 2017
 	}
2018
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2018
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2019 2019
 		global $globalDBdriver;
2020 2020
 		if ($globalDBdriver == 'mysql') {
2021 2021
 			if ($reset) {
@@ -2030,15 +2030,15 @@  discard block
 block discarded – undo
2030 2030
 				$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);"; 
2031 2031
 			}
2032 2032
 		}
2033
-		$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);
2033
+		$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);
2034 2034
 		try {
2035 2035
 			$sth = $this->db->prepare($query);
2036 2036
 			$sth->execute($query_values);
2037
-		} catch(PDOException $e) {
2037
+		} catch (PDOException $e) {
2038 2038
 			return "error : ".$e->getMessage();
2039 2039
 		}
2040 2040
 	}
2041
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2041
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2042 2042
 		global $globalDBdriver;
2043 2043
 		if ($globalDBdriver == 'mysql') {
2044 2044
 			if ($reset) {
@@ -2053,15 +2053,15 @@  discard block
 block discarded – undo
2053 2053
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2054 2054
 			}
2055 2055
 		}
2056
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2056
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2057 2057
 		try {
2058 2058
 			$sth = $this->db->prepare($query);
2059 2059
 			$sth->execute($query_values);
2060
-		} catch(PDOException $e) {
2060
+		} catch (PDOException $e) {
2061 2061
 			return "error : ".$e->getMessage();
2062 2062
 		}
2063 2063
 	}
2064
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2064
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2065 2065
 		global $globalDBdriver;
2066 2066
 		if ($globalDBdriver == 'mysql') {
2067 2067
 			if ($reset) {
@@ -2076,15 +2076,15 @@  discard block
 block discarded – undo
2076 2076
 				$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);"; 
2077 2077
 			}
2078 2078
 		}
2079
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2079
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2080 2080
 		try {
2081 2081
 			$sth = $this->db->prepare($query);
2082 2082
 			$sth->execute($query_values);
2083
-		} catch(PDOException $e) {
2083
+		} catch (PDOException $e) {
2084 2084
 			return "error : ".$e->getMessage();
2085 2085
 		}
2086 2086
 	}
2087
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2087
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2088 2088
 		global $globalDBdriver;
2089 2089
 		if ($globalDBdriver == 'mysql') {
2090 2090
 			if ($reset) {
@@ -2099,15 +2099,15 @@  discard block
 block discarded – undo
2099 2099
 				$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);"; 
2100 2100
 			}
2101 2101
 		}
2102
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2102
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2103 2103
 		try {
2104 2104
 			$sth = $this->db->prepare($query);
2105 2105
 			$sth->execute($query_values);
2106
-		} catch(PDOException $e) {
2106
+		} catch (PDOException $e) {
2107 2107
 			return "error : ".$e->getMessage();
2108 2108
 		}
2109 2109
 	}
2110
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2110
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2111 2111
 		global $globalDBdriver;
2112 2112
 		if ($globalDBdriver == 'mysql') {
2113 2113
 			if ($reset) {
@@ -2122,15 +2122,15 @@  discard block
 block discarded – undo
2122 2122
 				$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);"; 
2123 2123
 			}
2124 2124
 		}
2125
-		$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);
2125
+		$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);
2126 2126
 		try {
2127 2127
 			$sth = $this->db->prepare($query);
2128 2128
 			$sth->execute($query_values);
2129
-		} catch(PDOException $e) {
2129
+		} catch (PDOException $e) {
2130 2130
 			return "error : ".$e->getMessage();
2131 2131
 		}
2132 2132
 	}
2133
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2133
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2134 2134
 		global $globalDBdriver;
2135 2135
 		if ($airport_icao != '') {
2136 2136
 			if ($globalDBdriver == 'mysql') {
@@ -2146,16 +2146,16 @@  discard block
 block discarded – undo
2146 2146
 					$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);"; 
2147 2147
 				}
2148 2148
 			}
2149
-			$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);
2149
+			$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);
2150 2150
 			try {
2151 2151
 				$sth = $this->db->prepare($query);
2152 2152
 				$sth->execute($query_values);
2153
-			} catch(PDOException $e) {
2153
+			} catch (PDOException $e) {
2154 2154
 				return "error : ".$e->getMessage();
2155 2155
 			}
2156 2156
 		}
2157 2157
 	}
2158
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2158
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2159 2159
 		global $globalDBdriver;
2160 2160
 		if ($airport_icao != '') {
2161 2161
 			if ($globalDBdriver == 'mysql') {
@@ -2163,16 +2163,16 @@  discard block
 block discarded – undo
2163 2163
 			} else {
2164 2164
 				$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);"; 
2165 2165
 			}
2166
-			$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);
2166
+			$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);
2167 2167
 			 try {
2168 2168
 				$sth = $this->db->prepare($query);
2169 2169
 				$sth->execute($query_values);
2170
-			} catch(PDOException $e) {
2170
+			} catch (PDOException $e) {
2171 2171
 				return "error : ".$e->getMessage();
2172 2172
 			}
2173 2173
 		}
2174 2174
 	}
2175
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2175
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2176 2176
 		global $globalDBdriver;
2177 2177
 		if ($airport_icao != '') {
2178 2178
 			if ($globalDBdriver == 'mysql') {
@@ -2188,16 +2188,16 @@  discard block
 block discarded – undo
2188 2188
 					$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);"; 
2189 2189
 				}
2190 2190
 			}
2191
-			$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);
2191
+			$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);
2192 2192
 			try {
2193 2193
 				$sth = $this->db->prepare($query);
2194 2194
 				$sth->execute($query_values);
2195
-			} catch(PDOException $e) {
2195
+			} catch (PDOException $e) {
2196 2196
 				return "error : ".$e->getMessage();
2197 2197
 			}
2198 2198
 		}
2199 2199
 	}
2200
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2200
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2201 2201
 		global $globalDBdriver;
2202 2202
 		if ($airport_icao != '') {
2203 2203
 			if ($globalDBdriver == 'mysql') {
@@ -2205,11 +2205,11 @@  discard block
 block discarded – undo
2205 2205
 			} else {
2206 2206
 				$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);"; 
2207 2207
 			}
2208
-			$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);
2208
+			$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);
2209 2209
 			try {
2210 2210
 				$sth = $this->db->prepare($query);
2211 2211
 				$sth->execute($query_values);
2212
-			} catch(PDOException $e) {
2212
+			} catch (PDOException $e) {
2213 2213
 				return "error : ".$e->getMessage();
2214 2214
 			}
2215 2215
 		}
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 		try {
2222 2222
 			$sth = $this->db->prepare($query);
2223 2223
 			$sth->execute($query_values);
2224
-		} catch(PDOException $e) {
2224
+		} catch (PDOException $e) {
2225 2225
 			return "error : ".$e->getMessage();
2226 2226
 		}
2227 2227
 	}
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 		try {
2232 2232
 			$sth = $this->db->prepare($query);
2233 2233
 			$sth->execute($query_values);
2234
-		} catch(PDOException $e) {
2234
+		} catch (PDOException $e) {
2235 2235
 			return "error : ".$e->getMessage();
2236 2236
 		}
2237 2237
 	}
@@ -2241,7 +2241,7 @@  discard block
 block discarded – undo
2241 2241
 		try {
2242 2242
 			$sth = $this->db->prepare($query);
2243 2243
 			$sth->execute($query_values);
2244
-		} catch(PDOException $e) {
2244
+		} catch (PDOException $e) {
2245 2245
 			return "error : ".$e->getMessage();
2246 2246
 		}
2247 2247
 	}
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 		try {
2252 2252
 			$sth = $this->db->prepare($query);
2253 2253
 			$sth->execute($query_values);
2254
-		} catch(PDOException $e) {
2254
+		} catch (PDOException $e) {
2255 2255
 			return "error : ".$e->getMessage();
2256 2256
 		}
2257 2257
 	}
@@ -2261,13 +2261,13 @@  discard block
 block discarded – undo
2261 2261
 		try {
2262 2262
 			$sth = $this->db->prepare($query);
2263 2263
 			$sth->execute($query_values);
2264
-		} catch(PDOException $e) {
2264
+		} catch (PDOException $e) {
2265 2265
 			return "error : ".$e->getMessage();
2266 2266
 		}
2267 2267
 	}
2268 2268
 
2269 2269
 	public function addOldStats() {
2270
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2270
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2271 2271
 		$Common = new Common();
2272 2272
 		$Connection = new Connection($this->db);
2273 2273
 		date_default_timezone_set('UTC');
@@ -2282,9 +2282,9 @@  discard block
 block discarded – undo
2282 2282
 			$filtername = 'marine';
2283 2283
 			if ($Connection->tableExists('countries')) {
2284 2284
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2285
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2285
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2286 2286
 				foreach ($alldata as $number) {
2287
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2287
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2288 2288
 				}
2289 2289
 			}
2290 2290
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2294,44 +2294,44 @@  discard block
 block discarded – undo
2294 2294
 			$lastyear = false;
2295 2295
 			foreach ($alldata as $number) {
2296 2296
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2297
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2297
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2298 2298
 			}
2299 2299
 			echo 'Marine data...'."\n";
2300 2300
 			$this->deleteStatMarine('month');
2301 2301
 			echo '-> countAllDatesLastMonth...'."\n";
2302 2302
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2303 2303
 			foreach ($alldata as $number) {
2304
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2304
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2305 2305
 			}
2306 2306
 			echo '-> countAllDates...'."\n";
2307 2307
 			$previousdata = $this->countAllDatesMarine();
2308 2308
 			$this->deleteStatMarine('date');
2309
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2309
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2310 2310
 			$values = array();
2311 2311
 			foreach ($alldata as $cnt) {
2312 2312
 				$values[] = $cnt['date_count'];
2313 2313
 			}
2314
-			array_multisort($values,SORT_DESC,$alldata);
2315
-			array_splice($alldata,11);
2314
+			array_multisort($values, SORT_DESC, $alldata);
2315
+			array_splice($alldata, 11);
2316 2316
 			foreach ($alldata as $number) {
2317
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2317
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2318 2318
 			}
2319 2319
 			
2320 2320
 			$this->deleteStatMarine('hour');
2321 2321
 			echo '-> countAllHours...'."\n";
2322
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2322
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2323 2323
 			foreach ($alldata as $number) {
2324
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2324
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2325 2325
 			}
2326 2326
 			if ($globalDebug) echo 'Count all types...'."\n";
2327
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2327
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2328 2328
 			foreach ($alldata as $number) {
2329
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2329
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2330 2330
 			}
2331 2331
 
2332 2332
 			echo 'Insert last stats update date...'."\n";
2333 2333
 			date_default_timezone_set('UTC');
2334
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2334
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2335 2335
 		}
2336 2336
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2337 2337
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2343,9 +2343,9 @@  discard block
 block discarded – undo
2343 2343
 			$Tracker = new Tracker($this->db);
2344 2344
 			if ($Connection->tableExists('countries')) {
2345 2345
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2346
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2346
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2347 2347
 				foreach ($alldata as $number) {
2348
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2348
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2349 2349
 				}
2350 2350
 			}
2351 2351
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2355,38 +2355,38 @@  discard block
 block discarded – undo
2355 2355
 			$lastyear = false;
2356 2356
 			foreach ($alldata as $number) {
2357 2357
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2358
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2358
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2359 2359
 			}
2360 2360
 			echo 'Tracker data...'."\n";
2361 2361
 			$this->deleteStatTracker('month');
2362 2362
 			echo '-> countAllDatesLastMonth...'."\n";
2363 2363
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2364 2364
 			foreach ($alldata as $number) {
2365
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2365
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2366 2366
 			}
2367 2367
 			echo '-> countAllDates...'."\n";
2368 2368
 			$previousdata = $this->countAllDatesTracker();
2369 2369
 			$this->deleteStatTracker('date');
2370
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2370
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2371 2371
 			$values = array();
2372 2372
 			foreach ($alldata as $cnt) {
2373 2373
 				$values[] = $cnt['date_count'];
2374 2374
 			}
2375
-			array_multisort($values,SORT_DESC,$alldata);
2376
-			array_splice($alldata,11);
2375
+			array_multisort($values, SORT_DESC, $alldata);
2376
+			array_splice($alldata, 11);
2377 2377
 			foreach ($alldata as $number) {
2378
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2378
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2379 2379
 			}
2380 2380
 			
2381 2381
 			$this->deleteStatTracker('hour');
2382 2382
 			echo '-> countAllHours...'."\n";
2383
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2383
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2384 2384
 			foreach ($alldata as $number) {
2385
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2385
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2386 2386
 			}
2387 2387
 			echo 'Insert last stats update date...'."\n";
2388 2388
 			date_default_timezone_set('UTC');
2389
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2389
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2390 2390
 		}
2391 2391
 
2392 2392
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2404,41 +2404,41 @@  discard block
 block discarded – undo
2404 2404
 			$Spotter = new Spotter($this->db);
2405 2405
 
2406 2406
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2407
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2407
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2408 2408
 			foreach ($alldata as $number) {
2409
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2409
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2410 2410
 			}
2411 2411
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2412
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2412
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2413 2413
 			foreach ($alldata as $number) {
2414
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2414
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2415 2415
 			}
2416 2416
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2417
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2417
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2418 2418
 			foreach ($alldata as $number) {
2419
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2419
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2420 2420
 			}
2421 2421
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2422
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2422
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2423 2423
 			foreach ($alldata as $number) {
2424
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2424
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2425 2425
 			}
2426 2426
 			if ($globalDebug) echo 'Count all owners...'."\n";
2427
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2427
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2428 2428
 			foreach ($alldata as $number) {
2429
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2429
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2430 2430
 			}
2431 2431
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2432
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2432
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2433 2433
 			foreach ($alldata as $number) {
2434 2434
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2435
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2435
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2436 2436
 			}
2437 2437
 			
2438 2438
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2439
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2439
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2440 2440
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2441
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2441
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2442 2442
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2443 2443
 			$alldata = array();
2444 2444
 			foreach ($pall as $value) {
@@ -2455,14 +2455,14 @@  discard block
 block discarded – undo
2455 2455
 			foreach ($alldata as $key => $row) {
2456 2456
 				$count[$key] = $row['airport_departure_icao_count'];
2457 2457
 			}
2458
-			array_multisort($count,SORT_DESC,$alldata);
2458
+			array_multisort($count, SORT_DESC, $alldata);
2459 2459
 			foreach ($alldata as $number) {
2460
-				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);
2460
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
2461 2461
 			}
2462 2462
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2463
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2463
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2464 2464
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2465
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2465
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2466 2466
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2467 2467
 			$alldata = array();
2468 2468
 			foreach ($pall as $value) {
@@ -2479,18 +2479,18 @@  discard block
 block discarded – undo
2479 2479
 			foreach ($alldata as $key => $row) {
2480 2480
 				$count[$key] = $row['airport_arrival_icao_count'];
2481 2481
 			}
2482
-			array_multisort($count,SORT_DESC,$alldata);
2482
+			array_multisort($count, SORT_DESC, $alldata);
2483 2483
 			foreach ($alldata as $number) {
2484
-				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);
2484
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
2485 2485
 			}
2486 2486
 			if ($Connection->tableExists('countries')) {
2487 2487
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2488 2488
 				//$SpotterArchive = new SpotterArchive();
2489 2489
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2490 2490
 				$Spotter = new Spotter($this->db);
2491
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2491
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2492 2492
 				foreach ($alldata as $number) {
2493
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2493
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2494 2494
 				}
2495 2495
 			}
2496 2496
 			
@@ -2500,12 +2500,12 @@  discard block
 block discarded – undo
2500 2500
 				$this->deleteStatsByType('fatalities_byyear');
2501 2501
 				$alldata = $Accident->countFatalitiesByYear();
2502 2502
 				foreach ($alldata as $number) {
2503
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2503
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2504 2504
 				}
2505 2505
 				$this->deleteStatsByType('fatalities_bymonth');
2506 2506
 				$alldata = $Accident->countFatalitiesLast12Months();
2507 2507
 				foreach ($alldata as $number) {
2508
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2508
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2509 2509
 				}
2510 2510
 			}
2511 2511
 
@@ -2519,37 +2519,37 @@  discard block
 block discarded – undo
2519 2519
 			$lastyear = false;
2520 2520
 			foreach ($alldata as $number) {
2521 2521
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2522
-				$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'])));
2522
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2523 2523
 			}
2524 2524
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2525 2525
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2526 2526
 			foreach ($alldata as $number) {
2527
-				$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'])));
2527
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2528 2528
 			}
2529 2529
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2530 2530
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2531 2531
 			foreach ($alldata as $number) {
2532
-				$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'])));
2532
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2533 2533
 			}
2534 2534
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2535 2535
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2536 2536
 			foreach ($alldata as $number) {
2537
-				$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'])));
2537
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2538 2538
 			}
2539 2539
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2540 2540
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2541 2541
 			foreach ($alldata as $number) {
2542
-				$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'])));
2542
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2543 2543
 			}
2544 2544
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2545 2545
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2546 2546
 			foreach ($alldata as $number) {
2547
-				$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'])));
2547
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2548 2548
 			}
2549 2549
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2550 2550
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2551 2551
 			foreach ($alldata as $number) {
2552
-				$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'])));
2552
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2553 2553
 			}
2554 2554
 			if ($globalDebug) echo 'Airports data...'."\n";
2555 2555
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
 			}
2595 2595
 			$alldata = $pall;
2596 2596
 			foreach ($alldata as $number) {
2597
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2597
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2598 2598
 			}
2599 2599
 			echo '...Arrival'."\n";
2600 2600
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2635,7 +2635,7 @@  discard block
 block discarded – undo
2635 2635
 			}
2636 2636
 			$alldata = $pall;
2637 2637
 			foreach ($alldata as $number) {
2638
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2638
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2639 2639
 			}
2640 2640
 
2641 2641
 			echo 'Flights data...'."\n";
@@ -2643,28 +2643,28 @@  discard block
 block discarded – undo
2643 2643
 			echo '-> countAllDatesLastMonth...'."\n";
2644 2644
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2645 2645
 			foreach ($alldata as $number) {
2646
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2646
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2647 2647
 			}
2648 2648
 			echo '-> countAllDates...'."\n";
2649 2649
 			$previousdata = $this->countAllDates();
2650 2650
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2651 2651
 			$this->deleteStatFlight('date');
2652
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2652
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2653 2653
 			$values = array();
2654 2654
 			foreach ($alldata as $cnt) {
2655 2655
 				$values[] = $cnt['date_count'];
2656 2656
 			}
2657
-			array_multisort($values,SORT_DESC,$alldata);
2658
-			array_splice($alldata,11);
2657
+			array_multisort($values, SORT_DESC, $alldata);
2658
+			array_splice($alldata, 11);
2659 2659
 			foreach ($alldata as $number) {
2660
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2660
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2661 2661
 			}
2662 2662
 			
2663 2663
 			$this->deleteStatFlight('hour');
2664 2664
 			echo '-> countAllHours...'."\n";
2665
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2665
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2666 2666
 			foreach ($alldata as $number) {
2667
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2667
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2668 2668
 			}
2669 2669
 
2670 2670
 			// Count by airlines
@@ -2673,42 +2673,42 @@  discard block
 block discarded – undo
2673 2673
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2674 2674
 				$SpotterArchive = new SpotterArchive($this->db);
2675 2675
 				//$Spotter = new Spotter($this->db);
2676
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2676
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2677 2677
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2678 2678
 				foreach ($alldata as $number) {
2679
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2679
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2680 2680
 				}
2681 2681
 			}
2682 2682
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2683 2683
 			$Spotter = new Spotter($this->db);
2684
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2684
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2685 2685
 			foreach ($alldata as $number) {
2686
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2686
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2687 2687
 			}
2688 2688
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2689
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2689
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2690 2690
 			foreach ($alldata as $number) {
2691
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2691
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2692 2692
 			}
2693 2693
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2694
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2694
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2695 2695
 			foreach ($alldata as $number) {
2696
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2696
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2697 2697
 			}
2698 2698
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2699
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2699
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2700 2700
 			foreach ($alldata as $number) {
2701
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2701
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2702 2702
 			}
2703 2703
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2704
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2704
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2705 2705
 			foreach ($alldata as $number) {
2706
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2706
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2707 2707
 			}
2708 2708
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2709
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2709
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2710 2710
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2711
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2711
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2712 2712
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2713 2713
 			//$alldata = array();
2714 2714
 			foreach ($dall as $value) {
@@ -2728,12 +2728,12 @@  discard block
 block discarded – undo
2728 2728
 			}
2729 2729
 			$alldata = $pall;
2730 2730
 			foreach ($alldata as $number) {
2731
-				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);
2731
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
2732 2732
 			}
2733 2733
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2734
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2734
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2735 2735
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2736
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2736
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2737 2737
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2738 2738
 			//$alldata = array();
2739 2739
 			foreach ($dall as $value) {
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
 			}
2754 2754
 			$alldata = $pall;
2755 2755
 			foreach ($alldata as $number) {
2756
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2756
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
2757 2757
 			}
2758 2758
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2759 2759
 			$Spotter = new Spotter($this->db);
@@ -2761,27 +2761,27 @@  discard block
 block discarded – undo
2761 2761
 			$lastyear = false;
2762 2762
 			foreach ($alldata as $number) {
2763 2763
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2764
-				$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']);
2764
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
2765 2765
 			}
2766 2766
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2767 2767
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2768 2768
 			foreach ($alldata as $number) {
2769
-				$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']);
2769
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
2770 2770
 			}
2771 2771
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2772 2772
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2773 2773
 			foreach ($alldata as $number) {
2774
-				$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']);
2774
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
2775 2775
 			}
2776 2776
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2777 2777
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2778 2778
 			foreach ($alldata as $number) {
2779
-				$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']);
2779
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
2780 2780
 			}
2781 2781
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2782 2782
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2783 2783
 			foreach ($alldata as $number) {
2784
-				$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']);
2784
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
2785 2785
 			}
2786 2786
 			if ($globalDebug) echo '...Departure'."\n";
2787 2787
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -2804,7 +2804,7 @@  discard block
 block discarded – undo
2804 2804
 			}
2805 2805
 			$alldata = $pall;
2806 2806
 			foreach ($alldata as $number) {
2807
-				$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']);
2807
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
2808 2808
 			}
2809 2809
 			if ($globalDebug) echo '...Arrival'."\n";
2810 2810
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -2827,32 +2827,32 @@  discard block
 block discarded – undo
2827 2827
 			}
2828 2828
 			$alldata = $pall;
2829 2829
 			foreach ($alldata as $number) {
2830
-				$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']);
2830
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
2831 2831
 			}
2832 2832
 
2833 2833
 			if ($globalDebug) echo 'Flights data...'."\n";
2834 2834
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2835 2835
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2836 2836
 			foreach ($alldata as $number) {
2837
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2837
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
2838 2838
 			}
2839 2839
 			if ($globalDebug) echo '-> countAllDates...'."\n";
2840 2840
 			//$previousdata = $this->countAllDatesByAirlines();
2841
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2841
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
2842 2842
 			$values = array();
2843 2843
 			foreach ($alldata as $cnt) {
2844 2844
 				$values[] = $cnt['date_count'];
2845 2845
 			}
2846
-			array_multisort($values,SORT_DESC,$alldata);
2847
-			array_splice($alldata,11);
2846
+			array_multisort($values, SORT_DESC, $alldata);
2847
+			array_splice($alldata, 11);
2848 2848
 			foreach ($alldata as $number) {
2849
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2849
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
2850 2850
 			}
2851 2851
 			
2852 2852
 			if ($globalDebug) echo '-> countAllHours...'."\n";
2853
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2853
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
2854 2854
 			foreach ($alldata as $number) {
2855
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2855
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
2856 2856
 			}
2857 2857
 
2858 2858
 			// Stats by filters
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 							$last_update_day = date('Y').'-01-01 00:00:00';
2877 2877
 						}
2878 2878
 					}
2879
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2879
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2880 2880
 						$last_update_day = date('Y').'-01-01 00:00:00';
2881 2881
 						$reset = true;
2882 2882
 					}
@@ -2884,38 +2884,38 @@  discard block
 block discarded – undo
2884 2884
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2885 2885
 					$Spotter = new Spotter($this->db);
2886 2886
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
2887
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2887
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2888 2888
 					foreach ($alldata as $number) {
2889
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2889
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2890 2890
 					}
2891 2891
 					if ($globalDebug) echo 'Count all airlines...'."\n";
2892
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2892
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2893 2893
 					foreach ($alldata as $number) {
2894
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2894
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2895 2895
 					}
2896 2896
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
2897
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2897
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2898 2898
 					foreach ($alldata as $number) {
2899
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2899
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2900 2900
 					}
2901 2901
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
2902
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2902
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2903 2903
 					foreach ($alldata as $number) {
2904
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2904
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2905 2905
 					}
2906 2906
 					if ($globalDebug) echo 'Count all owners...'."\n";
2907
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2907
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2908 2908
 					foreach ($alldata as $number) {
2909
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2909
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2910 2910
 					}
2911 2911
 					if ($globalDebug) echo 'Count all pilots...'."\n";
2912
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2912
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2913 2913
 					foreach ($alldata as $number) {
2914
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2914
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2915 2915
 					}
2916 2916
 					if ($globalDebug) echo 'Count departure airports...'."\n";
2917
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2918
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2917
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2918
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2919 2919
 					$alldata = array();
2920 2920
 					foreach ($pall as $value) {
2921 2921
 						$icao = $value['airport_departure_icao'];
@@ -2931,13 +2931,13 @@  discard block
 block discarded – undo
2931 2931
 					foreach ($alldata as $key => $row) {
2932 2932
 						$count[$key] = $row['airport_departure_icao_count'];
2933 2933
 					}
2934
-					array_multisort($count,SORT_DESC,$alldata);
2934
+					array_multisort($count, SORT_DESC, $alldata);
2935 2935
 					foreach ($alldata as $number) {
2936
-						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);
2936
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
2937 2937
 					}
2938 2938
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
2939
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2940
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2939
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2940
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2941 2941
 					$alldata = array();
2942 2942
 					foreach ($pall as $value) {
2943 2943
 						$icao = $value['airport_arrival_icao'];
@@ -2953,9 +2953,9 @@  discard block
 block discarded – undo
2953 2953
 					foreach ($alldata as $key => $row) {
2954 2954
 						$count[$key] = $row['airport_arrival_icao_count'];
2955 2955
 					}
2956
-					array_multisort($count,SORT_DESC,$alldata);
2956
+					array_multisort($count, SORT_DESC, $alldata);
2957 2957
 					foreach ($alldata as $number) {
2958
-						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);
2958
+						echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2959 2959
 					}
2960 2960
 					if ($globalDebug) echo 'Count all months...'."\n";
2961 2961
 					$Spotter = new Spotter($this->db);
@@ -2963,36 +2963,36 @@  discard block
 block discarded – undo
2963 2963
 					$lastyear = false;
2964 2964
 					foreach ($alldata as $number) {
2965 2965
 						if ($number['year_name'] != date('Y')) $lastyear = true;
2966
-						$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);
2966
+						$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2967 2967
 					}
2968 2968
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
2969 2969
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2970 2970
 					foreach ($alldata as $number) {
2971
-						$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);
2971
+						$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2972 2972
 					}
2973 2973
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
2974 2974
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2975 2975
 					foreach ($alldata as $number) {
2976
-						$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);
2976
+						$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2977 2977
 					}
2978 2978
 					if ($globalDebug) echo 'Count all military by months...'."\n";
2979 2979
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2980 2980
 					foreach ($alldata as $number) {
2981
-						$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);
2981
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2982 2982
 					}
2983 2983
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2984 2984
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2985 2985
 				    	foreach ($alldata as $number) {
2986
-			    			$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);
2986
+			    			$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2987 2987
 					}
2988 2988
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2989 2989
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2990 2990
 					foreach ($alldata as $number) {
2991
-						$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);
2991
+						$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);
2992 2992
 					}
2993 2993
 					echo '...Departure'."\n";
2994
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2995
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2994
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2995
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2996 2996
 					foreach ($dall as $value) {
2997 2997
 						$icao = $value['departure_airport_icao'];
2998 2998
 						$ddate = $value['date'];
@@ -3010,11 +3010,11 @@  discard block
 block discarded – undo
3010 3010
 					}
3011 3011
 					$alldata = $pall;
3012 3012
 					foreach ($alldata as $number) {
3013
-						$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);
3013
+						$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);
3014 3014
 					}
3015 3015
 					echo '...Arrival'."\n";
3016
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3017
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3016
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3017
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3018 3018
 					foreach ($dall as $value) {
3019 3019
 						$icao = $value['arrival_airport_icao'];
3020 3020
 						$ddate = $value['date'];
@@ -3032,39 +3032,39 @@  discard block
 block discarded – undo
3032 3032
 					}
3033 3033
 					$alldata = $pall;
3034 3034
 					foreach ($alldata as $number) {
3035
-						$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);
3035
+						$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);
3036 3036
 					}
3037 3037
 					echo 'Flights data...'."\n";
3038 3038
 					echo '-> countAllDatesLastMonth...'."\n";
3039 3039
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3040 3040
 					foreach ($alldata as $number) {
3041
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3041
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3042 3042
 					}
3043 3043
 					echo '-> countAllDates...'."\n";
3044
-					$previousdata = $this->countAllDates('',$filter_name);
3045
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3044
+					$previousdata = $this->countAllDates('', $filter_name);
3045
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3046 3046
 					$values = array();
3047 3047
 					foreach ($alldata as $cnt) {
3048 3048
 						$values[] = $cnt['date_count'];
3049 3049
 					}
3050
-					array_multisort($values,SORT_DESC,$alldata);
3051
-					array_splice($alldata,11);
3050
+					array_multisort($values, SORT_DESC, $alldata);
3051
+					array_splice($alldata, 11);
3052 3052
 					foreach ($alldata as $number) {
3053
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3053
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3054 3054
 					}
3055 3055
 				
3056 3056
 					echo '-> countAllHours...'."\n";
3057
-					$alldata = $Spotter->countAllHours('hour',$filter);
3057
+					$alldata = $Spotter->countAllHours('hour', $filter);
3058 3058
 					foreach ($alldata as $number) {
3059
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3059
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3060 3060
 					}
3061 3061
 					echo 'Insert last stats update date...'."\n";
3062 3062
 					date_default_timezone_set('UTC');
3063
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3063
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3064 3064
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3065
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3065
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3066 3066
 							$this->deleteOldStats($filter_name);
3067
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3067
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3068 3068
 						}
3069 3069
 					}
3070 3070
 				}
@@ -3077,16 +3077,16 @@  discard block
 block discarded – undo
3077 3077
 				// SUM all previous month to put as year
3078 3078
 				$previous_year = date('Y');
3079 3079
 				$previous_year--;
3080
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3081
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3082
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3083
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3080
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3081
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3082
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3083
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3084 3084
 				$allairlines = $this->getAllAirlineNames();
3085 3085
 				foreach ($allairlines as $data) {
3086
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3087
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3088
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3089
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3086
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3087
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3088
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3089
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3090 3090
 				}
3091 3091
 				
3092 3092
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3095,21 +3095,21 @@  discard block
 block discarded – undo
3095 3095
 						try {
3096 3096
 							$sth = $this->db->prepare($query);
3097 3097
 							$sth->execute();
3098
-						} catch(PDOException $e) {
3098
+						} catch (PDOException $e) {
3099 3099
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3100 3100
 						}
3101 3101
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3102 3102
 						try {
3103 3103
 							$sth = $this->db->prepare($query);
3104 3104
 							$sth->execute();
3105
-						} catch(PDOException $e) {
3105
+						} catch (PDOException $e) {
3106 3106
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3107 3107
 						}
3108 3108
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3109 3109
 						try {
3110 3110
 							$sth = $this->db->prepare($query);
3111 3111
 							$sth->execute();
3112
-						} catch(PDOException $e) {
3112
+						} catch (PDOException $e) {
3113 3113
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3114 3114
 						}
3115 3115
 					}
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
 					try {
3123 3123
 						$sth = $this->db->prepare($query);
3124 3124
 						$sth->execute();
3125
-					} catch(PDOException $e) {
3125
+					} catch (PDOException $e) {
3126 3126
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3127 3127
 					}
3128 3128
 					if ($globalDBdriver == 'mysql') {
@@ -3133,7 +3133,7 @@  discard block
 block discarded – undo
3133 3133
 					try {
3134 3134
 						$sth = $this->db->prepare($query);
3135 3135
 						$sth->execute();
3136
-					} catch(PDOException $e) {
3136
+					} catch (PDOException $e) {
3137 3137
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3138 3138
 					}
3139 3139
 					if ($globalDBdriver == 'mysql') {
@@ -3144,15 +3144,15 @@  discard block
 block discarded – undo
3144 3144
 					try {
3145 3145
 						$sth = $this->db->prepare($query);
3146 3146
 						$sth->execute();
3147
-					} catch(PDOException $e) {
3147
+					} catch (PDOException $e) {
3148 3148
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3149 3149
 					}
3150 3150
 				}
3151 3151
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3152 3152
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3153
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3153
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3154 3154
 						$this->deleteOldStats();
3155
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3155
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3156 3156
 						$lastyearupdate = true;
3157 3157
 					}
3158 3158
 				}
@@ -3174,7 +3174,7 @@  discard block
 block discarded – undo
3174 3174
 					try {
3175 3175
 						$sth = $this->db->prepare($query);
3176 3176
 						$sth->execute();
3177
-					} catch(PDOException $e) {
3177
+					} catch (PDOException $e) {
3178 3178
 						return "error : ".$e->getMessage();
3179 3179
 					}
3180 3180
 					echo 'Archive old tracker data...'."\n";
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
 					try {
3191 3191
 						$sth = $this->db->prepare($query);
3192 3192
 						$sth->execute();
3193
-					} catch(PDOException $e) {
3193
+					} catch (PDOException $e) {
3194 3194
 						return "error : ".$e->getMessage();
3195 3195
 					}
3196 3196
 					echo 'Archive old marine data...'."\n";
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 					try {
3207 3207
 						$sth = $this->db->prepare($query);
3208 3208
 						$sth->execute();
3209
-					} catch(PDOException $e) {
3209
+					} catch (PDOException $e) {
3210 3210
 						return "error : ".$e->getMessage();
3211 3211
 					}
3212 3212
 				}
@@ -3219,7 +3219,7 @@  discard block
 block discarded – undo
3219 3219
 				try {
3220 3220
 					$sth = $this->db->prepare($query);
3221 3221
 					$sth->execute();
3222
-				} catch(PDOException $e) {
3222
+				} catch (PDOException $e) {
3223 3223
 					return "error : ".$e->getMessage();
3224 3224
 				}
3225 3225
 				echo 'Deleting old tracker data...'."\n";
@@ -3231,7 +3231,7 @@  discard block
 block discarded – undo
3231 3231
 				try {
3232 3232
 					$sth = $this->db->prepare($query);
3233 3233
 					$sth->execute();
3234
-				} catch(PDOException $e) {
3234
+				} catch (PDOException $e) {
3235 3235
 					return "error : ".$e->getMessage();
3236 3236
 				}
3237 3237
 				echo 'Deleting old marine data...'."\n";
@@ -3243,14 +3243,14 @@  discard block
 block discarded – undo
3243 3243
 				try {
3244 3244
 					$sth = $this->db->prepare($query);
3245 3245
 					$sth->execute();
3246
-				} catch(PDOException $e) {
3246
+				} catch (PDOException $e) {
3247 3247
 					return "error : ".$e->getMessage();
3248 3248
 				}
3249 3249
 			}
3250 3250
 			if (!isset($lastyearupdate)) {
3251 3251
 				echo 'Insert last stats update date...'."\n";
3252 3252
 				date_default_timezone_set('UTC');
3253
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3253
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3254 3254
 			}
3255 3255
 			if ($globalStatsResetYear) {
3256 3256
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +715 added lines, -250 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$filters = array('year' => $year,'month' => $month);
237 272
 			if ($filter_name != '') {
@@ -245,10 +280,15 @@  discard block
 block discarded – undo
245 280
 	}
246 281
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
247 282
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
249 286
 		if ($year == '' && $month == '') {
250
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
251
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
287
+			if ($limit) {
288
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
289
+			} else {
290
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
291
+			}
252 292
 			try {
253 293
 				$sth = $this->db->prepare($query);
254 294
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -256,7 +296,9 @@  discard block
 block discarded – undo
256 296
 				echo "error : ".$e->getMessage();
257 297
 			}
258 298
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
259
-		} else $all = array();
299
+		} else {
300
+			$all = array();
301
+		}
260 302
 		if (empty($all)) {
261 303
 			$Spotter = new Spotter($this->db);
262 304
 			$filters = array();
@@ -271,7 +313,9 @@  discard block
 block discarded – undo
271 313
 	}
272 314
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
273 315
 		global $globalStatsFilters;
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
316
+		if ($filter_name == '') {
317
+			$filter_name = $this->filter_name;
318
+		}
275 319
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
276 320
 			$Spotter = new Spotter($this->db);
277 321
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -280,8 +324,11 @@  discard block
 block discarded – undo
280 324
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
281 325
 			}
282 326
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
327
+				if ($limit) {
328
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
329
+				} else {
330
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
331
+				}
285 332
 				try {
286 333
 					$sth = $this->db->prepare($query);
287 334
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -289,11 +336,16 @@  discard block
 block discarded – undo
289 336
 					echo "error : ".$e->getMessage();
290 337
 				}
291 338
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
292
-			} else $all = array();
339
+			} else {
340
+				$all = array();
341
+			}
293 342
 		} else {
294 343
 			if ($year == '' && $month == '') {
295
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
296
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
344
+				if ($limit) {
345
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
346
+				} else {
347
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
348
+				}
297 349
 				try {
298 350
 					$sth = $this->db->prepare($query);
299 351
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -301,7 +353,9 @@  discard block
 block discarded – undo
301 353
 					echo "error : ".$e->getMessage();
302 354
 				}
303 355
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-			} else $all = array();
356
+			} else {
357
+				$all = array();
358
+			}
305 359
 		}
306 360
 		if (empty($all)) {
307 361
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -321,7 +375,9 @@  discard block
 block discarded – undo
321 375
 
322 376
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
323 377
 		global $globalStatsFilters;
324
-		if ($filter_name == '') $filter_name = $this->filter_name;
378
+		if ($filter_name == '') {
379
+			$filter_name = $this->filter_name;
380
+		}
325 381
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
326 382
 			$Spotter = new Spotter($this->db);
327 383
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -330,8 +386,11 @@  discard block
 block discarded – undo
330 386
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
331 387
 			}
332 388
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
389
+				if ($limit) {
390
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
391
+				} else {
392
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
393
+				}
335 394
 				try {
336 395
 					$sth = $this->db->prepare($query);
337 396
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -339,11 +398,16 @@  discard block
 block discarded – undo
339 398
 					echo "error : ".$e->getMessage();
340 399
 				}
341 400
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-			} else $all = array();
401
+			} else {
402
+				$all = array();
403
+			}
343 404
 		} else {
344 405
 			if ($year == '' && $month == '') {
345
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
346
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
406
+				if ($limit) {
407
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
408
+				} else {
409
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
410
+				}
347 411
 				try {
348 412
 					$sth = $this->db->prepare($query);
349 413
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -351,7 +415,9 @@  discard block
 block discarded – undo
351 415
 					echo "error : ".$e->getMessage();
352 416
 				}
353 417
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-			} else $all = array();
418
+			} else {
419
+				$all = array();
420
+			}
355 421
 		}
356 422
 		if (empty($all)) {
357 423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -370,7 +436,9 @@  discard block
 block discarded – undo
370 436
 	}
371 437
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 438
 		global $globalStatsFilters;
373
-		if ($filter_name == '') $filter_name = $this->filter_name;
439
+		if ($filter_name == '') {
440
+			$filter_name = $this->filter_name;
441
+		}
374 442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
375 443
 			$Spotter = new Spotter($this->db);
376 444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -378,12 +446,18 @@  discard block
 block discarded – undo
378 446
 			foreach ($airlines as $airline) {
379 447
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
380 448
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
449
+			if ($limit) {
450
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
451
+			} else {
452
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
453
+			}
383 454
 			$query_values = array(':filter_name' => $filter_name);
384 455
 		} else {
385
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
387 461
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
388 462
 		}
389 463
 		try {
@@ -411,17 +485,29 @@  discard block
 block discarded – undo
411 485
 
412 486
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
413 487
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
415 491
 		if ($year == '' && $month == '') {
416
-			if ($globalVATSIM) $forsource = 'vatsim';
417
-			if ($globalIVAO) $forsource = 'ivao';
492
+			if ($globalVATSIM) {
493
+				$forsource = 'vatsim';
494
+			}
495
+			if ($globalIVAO) {
496
+				$forsource = 'ivao';
497
+			}
418 498
 			if (isset($forsource)) {
419
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
499
+				if ($limit) {
500
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
501
+				} else {
502
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
503
+				}
421 504
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
422 505
 			} else {
423
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
510
+				}
425 511
 				$query_values = array(':filter_name' => $filter_name);
426 512
 			}
427 513
 			try {
@@ -431,7 +517,9 @@  discard block
 block discarded – undo
431 517
 				echo "error : ".$e->getMessage();
432 518
 			}
433 519
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
520
+		} else {
521
+			$all = array();
522
+		}
435 523
                 if (empty($all)) {
436 524
 	                $Spotter = new Spotter($this->db);
437 525
             		$filters = array();
@@ -446,7 +534,9 @@  discard block
 block discarded – undo
446 534
 	}
447 535
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 536
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
537
+		if ($filter_name == '') {
538
+			$filter_name = $this->filter_name;
539
+		}
450 540
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
451 541
 			$Spotter = new Spotter($this->db);
452 542
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -455,8 +545,11 @@  discard block
 block discarded – undo
455 545
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
456 546
 			}
457 547
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
548
+				if ($limit) {
549
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
550
+				} else {
551
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
552
+				}
460 553
 				try {
461 554
 					$sth = $this->db->prepare($query);
462 555
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -464,11 +557,16 @@  discard block
 block discarded – undo
464 557
 					echo "error : ".$e->getMessage();
465 558
 				}
466 559
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-			} else $all = array();
560
+			} else {
561
+				$all = array();
562
+			}
468 563
 		} else {
469 564
 			if ($year == '' && $month == '') {
470
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
471
-				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
565
+				if ($limit) {
566
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
567
+				} else {
568
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
569
+				}
472 570
 				try {
473 571
 					$sth = $this->db->prepare($query);
474 572
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -476,7 +574,9 @@  discard block
 block discarded – undo
476 574
 					echo "error : ".$e->getMessage();
477 575
 				}
478 576
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479
-			} else $all = array();
577
+			} else {
578
+				$all = array();
579
+			}
480 580
 		}
481 581
 		if (empty($all)) {
482 582
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -495,7 +595,9 @@  discard block
 block discarded – undo
495 595
 	}
496 596
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
497 597
 		global $globalStatsFilters;
498
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
499 601
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
500 602
 			$Spotter = new Spotter($this->db);
501 603
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -504,8 +606,11 @@  discard block
 block discarded – undo
504 606
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
505 607
 			}
506 608
 			if ($year == '' && $month == '') {
507
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
609
+				if ($limit) {
610
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
611
+				} else {
612
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
613
+				}
509 614
 				 try {
510 615
 					$sth = $this->db->prepare($query);
511 616
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -513,11 +618,16 @@  discard block
 block discarded – undo
513 618
 					echo "error : ".$e->getMessage();
514 619
 				}
515 620
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
516
-			} else $all = array();
621
+			} else {
622
+				$all = array();
623
+			}
517 624
 		} else {
518 625
 			if ($year == '' && $month == '') {
519
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
520
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
626
+				if ($limit) {
627
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
628
+				} else {
629
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
630
+				}
521 631
 				 try {
522 632
 					$sth = $this->db->prepare($query);
523 633
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -525,7 +635,9 @@  discard block
 block discarded – undo
525 635
 					echo "error : ".$e->getMessage();
526 636
 				}
527 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528
-			} else $all = array();
638
+			} else {
639
+				$all = array();
640
+			}
529 641
 		}
530 642
 		if (empty($all)) {
531 643
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -544,7 +656,9 @@  discard block
 block discarded – undo
544 656
 	}
545 657
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
546 658
 		$Connection = new Connection($this->db);
547
-		if ($filter_name == '') $filter_name = $this->filter_name;
659
+		if ($filter_name == '') {
660
+			$filter_name = $this->filter_name;
661
+		}
548 662
 		if ($Connection->tableExists('countries')) {
549 663
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
550 664
 				$Spotter = new Spotter($this->db);
@@ -554,8 +668,11 @@  discard block
 block discarded – undo
554 668
 					foreach ($airlines as $airline) {
555 669
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
556 670
 					}
557
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
671
+					if ($limit) {
672
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
673
+					} else {
674
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
675
+					}
559 676
 					 try {
560 677
 						$sth = $this->db->prepare($query);
561 678
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -564,11 +681,16 @@  discard block
 block discarded – undo
564 681
 					}
565 682
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
566 683
 					return $all;
567
-				} else return array();
684
+				} else {
685
+					return array();
686
+				}
568 687
 			} else {
569 688
 				if ($year == '' && $month == '') {
570
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
571
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
689
+					if ($limit) {
690
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
691
+					} else {
692
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
693
+					}
572 694
 					 try {
573 695
 						$sth = $this->db->prepare($query);
574 696
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,20 +699,29 @@  discard block
 block discarded – undo
577 699
 					}
578 700
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 701
 					return $all;
580
-				} else return array();
702
+				} else {
703
+					return array();
704
+				}
581 705
 			}
582 706
 			$Spotter = new Spotter($this->db);
583 707
 			return $Spotter->countAllFlightOverCountries($limit);
584
-		} else return array();
708
+		} else {
709
+			return array();
710
+		}
585 711
 	}
586 712
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
587 713
 		$Connection = new Connection($this->db);
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
589 717
 		if ($Connection->tableExists('countries')) {
590 718
 			$all = array();
591 719
 			if ($year == '' && $month == '') {
592
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
593
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
720
+				if ($limit) {
721
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
722
+				} else {
723
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
724
+				}
594 725
 				 try {
595 726
 					$sth = $this->db->prepare($query);
596 727
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -608,17 +739,24 @@  discard block
 block discarded – undo
608 739
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
609 740
 			}
610 741
 			return $all;
611
-		} else return array();
742
+		} else {
743
+			return array();
744
+		}
612 745
 	}
613 746
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
614 747
 		global $globalStatsFilters;
615 748
 		$Connection = new Connection($this->db);
616
-		if ($filter_name == '') $filter_name = $this->filter_name;
749
+		if ($filter_name == '') {
750
+			$filter_name = $this->filter_name;
751
+		}
617 752
 		if ($Connection->tableExists('countries')) {
618 753
 			$all = array();
619 754
 			if ($year == '' && $month == '') {
620
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
621
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
755
+				if ($limit) {
756
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
757
+				} else {
758
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
759
+				}
622 760
 				 try {
623 761
 					$sth = $this->db->prepare($query);
624 762
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -637,14 +775,21 @@  discard block
 block discarded – undo
637 775
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
638 776
 			}
639 777
 			return $all;
640
-		} else return array();
778
+		} else {
779
+			return array();
780
+		}
641 781
 	}
642 782
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
643 783
 		global $globalStatsFilters;
644
-		if ($filter_name == '') $filter_name = $this->filter_name;
784
+		if ($filter_name == '') {
785
+			$filter_name = $this->filter_name;
786
+		}
645 787
 		if ($year == '' && $month == '') {
646
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
647
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
788
+			if ($limit) {
789
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
790
+			} else {
791
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
792
+			}
648 793
 			try {
649 794
 				$sth = $this->db->prepare($query);
650 795
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -652,7 +797,9 @@  discard block
 block discarded – undo
652 797
 				echo "error : ".$e->getMessage();
653 798
 			}
654 799
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655
-		} else $all = array();
800
+		} else {
801
+			$all = array();
802
+		}
656 803
 		if (empty($all)) {
657 804
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
658 805
 			if ($filter_name != '') {
@@ -667,7 +814,9 @@  discard block
 block discarded – undo
667 814
 
668 815
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
669 816
 		global $globalStatsFilters;
670
-		if ($filter_name == '') $filter_name = $this->filter_name;
817
+		if ($filter_name == '') {
818
+			$filter_name = $this->filter_name;
819
+		}
671 820
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
672 821
 			$Spotter = new Spotter($this->db);
673 822
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -676,8 +825,11 @@  discard block
 block discarded – undo
676 825
 				foreach ($airlines as $airline) {
677 826
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
678 827
 				}
679
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
828
+				if ($limit) {
829
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
830
+				} else {
831
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
832
+				}
681 833
 				try {
682 834
 					$sth = $this->db->prepare($query);
683 835
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -685,11 +837,16 @@  discard block
 block discarded – undo
685 837
 					echo "error : ".$e->getMessage();
686 838
 				}
687 839
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
688
-			} else $all = array();
840
+			} else {
841
+				$all = array();
842
+			}
689 843
 		} else {
690 844
 			if ($year == '' && $month == '') {
691
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
692
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
845
+				if ($limit) {
846
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
847
+				} else {
848
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
849
+				}
693 850
 				try {
694 851
 					$sth = $this->db->prepare($query);
695 852
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -697,7 +854,9 @@  discard block
 block discarded – undo
697 854
 					echo "error : ".$e->getMessage();
698 855
 				}
699 856
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
700
-			} else $all = array();
857
+			} else {
858
+				$all = array();
859
+			}
701 860
 		}
702 861
 		if (empty($all)) {
703 862
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -716,7 +875,9 @@  discard block
 block discarded – undo
716 875
 	}
717 876
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
718 877
 		global $globalStatsFilters;
719
-		if ($filter_name == '') $filter_name = $this->filter_name;
878
+		if ($filter_name == '') {
879
+			$filter_name = $this->filter_name;
880
+		}
720 881
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
721 882
 			$Spotter = new Spotter($this->db);
722 883
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -725,8 +886,11 @@  discard block
 block discarded – undo
725 886
 				foreach ($airlines as $airline) {
726 887
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
727 888
 				}
728
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
889
+				if ($limit) {
890
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
891
+				} else {
892
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
893
+				}
730 894
 				try {
731 895
 					$sth = $this->db->prepare($query);
732 896
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -734,11 +898,16 @@  discard block
 block discarded – undo
734 898
 					echo "error : ".$e->getMessage();
735 899
 				}
736 900
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
737
-			} else $all = array();
901
+			} else {
902
+				$all = array();
903
+			}
738 904
 		} else {
739 905
 			if ($year == '' && $month == '') {
740
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
741
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
906
+				if ($limit) {
907
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
908
+				} else {
909
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
910
+				}
742 911
 				try {
743 912
 					$sth = $this->db->prepare($query);
744 913
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -746,7 +915,9 @@  discard block
 block discarded – undo
746 915
 					echo "error : ".$e->getMessage();
747 916
 				}
748 917
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
749
-			} else $all = array();
918
+			} else {
919
+				$all = array();
920
+			}
750 921
 		}
751 922
 		if (empty($all)) {
752 923
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -771,7 +942,9 @@  discard block
 block discarded – undo
771 942
 				$icao = $value['airport_departure_icao'];
772 943
 				if (isset($all[$icao])) {
773 944
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
774
-				} else $all[$icao] = $value;
945
+				} else {
946
+					$all[$icao] = $value;
947
+				}
775 948
 			}
776 949
 			$count = array();
777 950
 			foreach ($all as $key => $row) {
@@ -783,7 +956,9 @@  discard block
 block discarded – undo
783 956
 	}
784 957
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
785 958
 		global $globalStatsFilters;
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
959
+		if ($filter_name == '') {
960
+			$filter_name = $this->filter_name;
961
+		}
787 962
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
788 963
 			$Spotter = new Spotter($this->db);
789 964
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -792,8 +967,11 @@  discard block
 block discarded – undo
792 967
 				foreach ($airlines as $airline) {
793 968
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
794 969
 				}
795
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
970
+				if ($limit) {
971
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
972
+				} else {
973
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
974
+				}
797 975
 				try {
798 976
 					$sth = $this->db->prepare($query);
799 977
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -801,11 +979,16 @@  discard block
 block discarded – undo
801 979
 					echo "error : ".$e->getMessage();
802 980
 				}
803 981
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
804
-			} else $all = array();
982
+			} else {
983
+				$all = array();
984
+			}
805 985
 		} else {
806 986
 			if ($year == '' && $month == '') {
807
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
808
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
987
+				if ($limit) {
988
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
989
+				} else {
990
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
991
+				}
809 992
 				try {
810 993
 					$sth = $this->db->prepare($query);
811 994
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -813,7 +996,9 @@  discard block
 block discarded – undo
813 996
 					echo "error : ".$e->getMessage();
814 997
 				}
815 998
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
816
-			} else $all = array();
999
+			} else {
1000
+				$all = array();
1001
+			}
817 1002
 		}
818 1003
 		if (empty($all)) {
819 1004
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -838,7 +1023,9 @@  discard block
 block discarded – undo
838 1023
 				$icao = $value['airport_arrival_icao'];
839 1024
 				if (isset($all[$icao])) {
840 1025
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
841
-				} else $all[$icao] = $value;
1026
+				} else {
1027
+					$all[$icao] = $value;
1028
+				}
842 1029
 			}
843 1030
 			$count = array();
844 1031
 			foreach ($all as $key => $row) {
@@ -850,7 +1037,9 @@  discard block
 block discarded – undo
850 1037
 	}
851 1038
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
852 1039
 		global $globalDBdriver, $globalStatsFilters;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
1040
+		if ($filter_name == '') {
1041
+			$filter_name = $this->filter_name;
1042
+		}
854 1043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
855 1044
 			$Spotter = new Spotter($this->db);
856 1045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -859,20 +1048,32 @@  discard block
 block discarded – undo
859 1048
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
860 1049
 			}
861 1050
 			if ($globalDBdriver == 'mysql') {
862
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1051
+				if ($limit) {
1052
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1053
+				} else {
1054
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1055
+				}
864 1056
 			} else {
865
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1057
+				if ($limit) {
1058
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1059
+				} else {
1060
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1061
+				}
867 1062
 			}
868 1063
 			$query_data = array(':filter_name' => $filter_name);
869 1064
 		} else {
870 1065
 			if ($globalDBdriver == 'mysql') {
871
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
872
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1066
+				if ($limit) {
1067
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1068
+				} else {
1069
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1070
+				}
873 1071
 			} else {
874
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
875
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1072
+				if ($limit) {
1073
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1074
+				} else {
1075
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1076
+				}
876 1077
 			}
877 1078
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
878 1079
 		}
@@ -900,7 +1101,9 @@  discard block
 block discarded – undo
900 1101
 	
901 1102
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
902 1103
 		global $globalStatsFilters;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1104
+		if ($filter_name == '') {
1105
+			$filter_name = $this->filter_name;
1106
+		}
904 1107
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
905 1108
 			$Spotter = new Spotter($this->db);
906 1109
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -937,7 +1140,9 @@  discard block
 block discarded – undo
937 1140
 	}
938 1141
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
939 1142
 		global $globalDBdriver, $globalStatsFilters;
940
-		if ($filter_name == '') $filter_name = $this->filter_name;
1143
+		if ($filter_name == '') {
1144
+			$filter_name = $this->filter_name;
1145
+		}
941 1146
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
942 1147
 			$Spotter = new Spotter($this->db);
943 1148
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -982,7 +1187,9 @@  discard block
 block discarded – undo
982 1187
 	}
983 1188
 	public function countAllDates($stats_airline = '',$filter_name = '') {
984 1189
 		global $globalStatsFilters;
985
-		if ($filter_name == '') $filter_name = $this->filter_name;
1190
+		if ($filter_name == '') {
1191
+			$filter_name = $this->filter_name;
1192
+		}
986 1193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
987 1194
 			$Spotter = new Spotter($this->db);
988 1195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1019,7 +1226,9 @@  discard block
 block discarded – undo
1019 1226
 	}
1020 1227
 	public function countAllDatesMarine($filter_name = '') {
1021 1228
 		global $globalStatsFilters;
1022
-		if ($filter_name == '') $filter_name = $this->filter_name;
1229
+		if ($filter_name == '') {
1230
+			$filter_name = $this->filter_name;
1231
+		}
1023 1232
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1024 1233
 		$query_data = array(':filter_name' => $filter_name);
1025 1234
 		try {
@@ -1041,7 +1250,9 @@  discard block
 block discarded – undo
1041 1250
 	}
1042 1251
 	public function countAllDatesTracker($filter_name = '') {
1043 1252
 		global $globalStatsFilters;
1044
-		if ($filter_name == '') $filter_name = $this->filter_name;
1253
+		if ($filter_name == '') {
1254
+			$filter_name = $this->filter_name;
1255
+		}
1045 1256
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1046 1257
 		$query_data = array(':filter_name' => $filter_name);
1047 1258
 		try {
@@ -1063,7 +1274,9 @@  discard block
 block discarded – undo
1063 1274
 	}
1064 1275
 	public function countAllDatesByAirlines($filter_name = '') {
1065 1276
 		global $globalStatsFilters;
1066
-		if ($filter_name == '') $filter_name = $this->filter_name;
1277
+		if ($filter_name == '') {
1278
+			$filter_name = $this->filter_name;
1279
+		}
1067 1280
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
1068 1281
 		$query_data = array('filter_name' => $filter_name);
1069 1282
 		try {
@@ -1085,7 +1298,9 @@  discard block
 block discarded – undo
1085 1298
 	}
1086 1299
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1087 1300
 		global $globalStatsFilters, $globalDBdriver;
1088
-		if ($filter_name == '') $filter_name = $this->filter_name;
1301
+		if ($filter_name == '') {
1302
+			$filter_name = $this->filter_name;
1303
+		}
1089 1304
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1090 1305
 			$Spotter = new Spotter($this->db);
1091 1306
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1170,7 +1385,9 @@  discard block
 block discarded – undo
1170 1385
 	}
1171 1386
 	public function countAllMilitaryMonths($filter_name = '') {
1172 1387
 		global $globalStatsFilters;
1173
-		if ($filter_name == '') $filter_name = $this->filter_name;
1388
+		if ($filter_name == '') {
1389
+			$filter_name = $this->filter_name;
1390
+		}
1174 1391
 		$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
1175 1392
 		try {
1176 1393
 			$sth = $this->db->prepare($query);
@@ -1191,7 +1408,9 @@  discard block
 block discarded – undo
1191 1408
 	}
1192 1409
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1193 1410
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1194
-		if ($filter_name == '') $filter_name = $this->filter_name;
1411
+		if ($filter_name == '') {
1412
+			$filter_name = $this->filter_name;
1413
+		}
1195 1414
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1196 1415
 			$Spotter = new Spotter($this->db);
1197 1416
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1199,12 +1418,18 @@  discard block
 block discarded – undo
1199 1418
 			foreach ($airlines as $airline) {
1200 1419
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1201 1420
 			}
1202
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1203
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1421
+			if ($limit) {
1422
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1423
+			} else {
1424
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1425
+			}
1204 1426
 			$query_data = array(':filter_name' => $filter_name);
1205 1427
 		} else {
1206
-			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1207
-			else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1428
+			if ($limit) {
1429
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1430
+			} else {
1431
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1432
+			}
1208 1433
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1209 1434
 		}
1210 1435
 		if ($orderby == 'hour') {
@@ -1214,7 +1439,9 @@  discard block
 block discarded – undo
1214 1439
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1215 1440
 			}
1216 1441
 		}
1217
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1442
+		if ($orderby == 'count') {
1443
+			$query .= " ORDER BY hour_count DESC";
1444
+		}
1218 1445
 		try {
1219 1446
 			$sth = $this->db->prepare($query);
1220 1447
 			$sth->execute($query_data);
@@ -1238,8 +1465,12 @@  discard block
 block discarded – undo
1238 1465
 	}
1239 1466
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1240 1467
 		global $globalStatsFilters;
1241
-		if ($filter_name == '') $filter_name = $this->filter_name;
1242
-		if ($year == '') $year = date('Y');
1468
+		if ($filter_name == '') {
1469
+			$filter_name = $this->filter_name;
1470
+		}
1471
+		if ($year == '') {
1472
+			$year = date('Y');
1473
+		}
1243 1474
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1244 1475
 		if (empty($all)) {
1245 1476
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1258,8 +1489,12 @@  discard block
 block discarded – undo
1258 1489
 	}
1259 1490
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1260 1491
 		global $globalStatsFilters;
1261
-		if ($filter_name == '') $filter_name = $this->filter_name;
1262
-		if ($year == '') $year = date('Y');
1492
+		if ($filter_name == '') {
1493
+			$filter_name = $this->filter_name;
1494
+		}
1495
+		if ($year == '') {
1496
+			$year = date('Y');
1497
+		}
1263 1498
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1264 1499
 		if (empty($all)) {
1265 1500
 			$filters = array('year' => $year,'month' => $month);
@@ -1274,8 +1509,12 @@  discard block
 block discarded – undo
1274 1509
 	}
1275 1510
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1276 1511
 		global $globalStatsFilters;
1277
-		if ($filter_name == '') $filter_name = $this->filter_name;
1278
-		if ($year == '') $year = date('Y');
1512
+		if ($filter_name == '') {
1513
+			$filter_name = $this->filter_name;
1514
+		}
1515
+		if ($year == '') {
1516
+			$year = date('Y');
1517
+		}
1279 1518
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1280 1519
 		if (empty($all)) {
1281 1520
 			$filters = array('year' => $year,'month' => $month);
@@ -1290,8 +1529,12 @@  discard block
 block discarded – undo
1290 1529
 	}
1291 1530
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1292 1531
 		global $globalStatsFilters;
1293
-		if ($filter_name == '') $filter_name = $this->filter_name;
1294
-		if ($year == '') $year = date('Y');
1532
+		if ($filter_name == '') {
1533
+			$filter_name = $this->filter_name;
1534
+		}
1535
+		if ($year == '') {
1536
+			$year = date('Y');
1537
+		}
1295 1538
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1296 1539
 		if (empty($all)) {
1297 1540
 			$filters = array();
@@ -1307,8 +1550,12 @@  discard block
 block discarded – undo
1307 1550
 	}
1308 1551
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1309 1552
 		global $globalStatsFilters;
1310
-		if ($filter_name == '') $filter_name = $this->filter_name;
1311
-		if ($year == '') $year = date('Y');
1553
+		if ($filter_name == '') {
1554
+			$filter_name = $this->filter_name;
1555
+		}
1556
+		if ($year == '') {
1557
+			$year = date('Y');
1558
+		}
1312 1559
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1313 1560
 		if (empty($all)) {
1314 1561
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1327,7 +1574,9 @@  discard block
 block discarded – undo
1327 1574
 	}
1328 1575
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1329 1576
 		global $globalStatsFilters;
1330
-		if ($filter_name == '') $filter_name = $this->filter_name;
1577
+		if ($filter_name == '') {
1578
+			$filter_name = $this->filter_name;
1579
+		}
1331 1580
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1332 1581
 			$Spotter = new Spotter($this->db);
1333 1582
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1345,7 +1594,9 @@  discard block
 block discarded – undo
1345 1594
 				}
1346 1595
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1347 1596
 				$all = $result[0]['nb'];
1348
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1597
+			} else {
1598
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1599
+			}
1349 1600
 		} else {
1350 1601
 			if ($year == '' && $month == '') {
1351 1602
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1357,7 +1608,9 @@  discard block
 block discarded – undo
1357 1608
 				}
1358 1609
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1359 1610
 				$all = $result[0]['nb'];
1360
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1611
+			} else {
1612
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1613
+			}
1361 1614
 		}
1362 1615
 		if (empty($all)) {
1363 1616
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1376,7 +1629,9 @@  discard block
 block discarded – undo
1376 1629
 	}
1377 1630
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1378 1631
 		global $globalStatsFilters;
1379
-		if ($filter_name == '') $filter_name = $this->filter_name;
1632
+		if ($filter_name == '') {
1633
+			$filter_name = $this->filter_name;
1634
+		}
1380 1635
 		if ($year == '' && $month == '') {
1381 1636
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1382 1637
 			try {
@@ -1387,7 +1642,9 @@  discard block
 block discarded – undo
1387 1642
 			}
1388 1643
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1389 1644
 			$all = $result[0]['nb_airline'];
1390
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1645
+		} else {
1646
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1647
+		}
1391 1648
 		if (empty($all)) {
1392 1649
 			$filters = array();
1393 1650
 			$filters = array('year' => $year,'month' => $month);
@@ -1402,7 +1659,9 @@  discard block
 block discarded – undo
1402 1659
 	}
1403 1660
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1404 1661
 		global $globalStatsFilters;
1405
-		if ($filter_name == '') $filter_name = $this->filter_name;
1662
+		if ($filter_name == '') {
1663
+			$filter_name = $this->filter_name;
1664
+		}
1406 1665
 		$all = array();
1407 1666
 		if ($year == '' && $month == '') {
1408 1667
 			$query = "SELECT SUM(cnt) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1429,7 +1688,9 @@  discard block
 block discarded – undo
1429 1688
 	}
1430 1689
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1431 1690
 		global $globalStatsFilters;
1432
-		if ($filter_name == '') $filter_name = $this->filter_name;
1691
+		if ($filter_name == '') {
1692
+			$filter_name = $this->filter_name;
1693
+		}
1433 1694
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1434 1695
 			$Spotter = new Spotter($this->db);
1435 1696
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1484,7 +1745,9 @@  discard block
 block discarded – undo
1484 1745
 	}
1485 1746
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1486 1747
 		global $globalStatsFilters;
1487
-		if ($filter_name == '') $filter_name = $this->filter_name;
1748
+		if ($filter_name == '') {
1749
+			$filter_name = $this->filter_name;
1750
+		}
1488 1751
 		//if ($year == '') $year = date('Y');
1489 1752
 		if ($year == '' && $month == '') {
1490 1753
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1513,7 +1776,9 @@  discard block
 block discarded – undo
1513 1776
 	}
1514 1777
 
1515 1778
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1516
-		if ($filter_name == '') $filter_name = $this->filter_name;
1779
+		if ($filter_name == '') {
1780
+			$filter_name = $this->filter_name;
1781
+		}
1517 1782
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1518 1783
 			$Spotter = new Spotter($this->db);
1519 1784
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1537,7 +1802,9 @@  discard block
 block discarded – undo
1537 1802
 		return $all;
1538 1803
 	}
1539 1804
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1540
-		if ($filter_name == '') $filter_name = $this->filter_name;
1805
+		if ($filter_name == '') {
1806
+			$filter_name = $this->filter_name;
1807
+		}
1541 1808
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1542 1809
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1543 1810
 		try {
@@ -1550,7 +1817,9 @@  discard block
 block discarded – undo
1550 1817
 		return $all;
1551 1818
 	}
1552 1819
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1553
-		if ($filter_name == '') $filter_name = $this->filter_name;
1820
+		if ($filter_name == '') {
1821
+			$filter_name = $this->filter_name;
1822
+		}
1554 1823
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1555 1824
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1556 1825
 		try {
@@ -1561,7 +1830,9 @@  discard block
 block discarded – undo
1561 1830
 		}
1562 1831
 	}
1563 1832
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1564
-		if ($filter_name == '') $filter_name = $this->filter_name;
1833
+		if ($filter_name == '') {
1834
+			$filter_name = $this->filter_name;
1835
+		}
1565 1836
 		global $globalArchiveMonths, $globalDBdriver;
1566 1837
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1567 1838
 			$Spotter = new Spotter($this->db);
@@ -1617,7 +1888,9 @@  discard block
 block discarded – undo
1617 1888
 	}
1618 1889
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1619 1890
 		global $globalArchiveMonths, $globalDBdriver;
1620
-		if ($filter_name == '') $filter_name = $this->filter_name;
1891
+		if ($filter_name == '') {
1892
+			$filter_name = $this->filter_name;
1893
+		}
1621 1894
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1622 1895
 			$Spotter = new Spotter($this->db);
1623 1896
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1650,7 +1923,9 @@  discard block
 block discarded – undo
1650 1923
 	}
1651 1924
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1652 1925
 		global $globalArchiveMonths, $globalDBdriver;
1653
-		if ($filter_name == '') $filter_name = $this->filter_name;
1926
+		if ($filter_name == '') {
1927
+			$filter_name = $this->filter_name;
1928
+		}
1654 1929
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1655 1930
 			$Spotter = new Spotter($this->db);
1656 1931
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1681,7 +1956,9 @@  discard block
 block discarded – undo
1681 1956
 	}
1682 1957
 	public function getStatsAirlineTotal($filter_name = '') {
1683 1958
 		global $globalArchiveMonths, $globalDBdriver;
1684
-		if ($filter_name == '') $filter_name = $this->filter_name;
1959
+		if ($filter_name == '') {
1960
+			$filter_name = $this->filter_name;
1961
+		}
1685 1962
 		if ($globalDBdriver == 'mysql') {
1686 1963
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1687 1964
 		} else {
@@ -1698,7 +1975,9 @@  discard block
 block discarded – undo
1698 1975
 	}
1699 1976
 	public function getStatsOwnerTotal($filter_name = '') {
1700 1977
 		global $globalArchiveMonths, $globalDBdriver;
1701
-		if ($filter_name == '') $filter_name = $this->filter_name;
1978
+		if ($filter_name == '') {
1979
+			$filter_name = $this->filter_name;
1980
+		}
1702 1981
 		if ($globalDBdriver == 'mysql') {
1703 1982
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1704 1983
 		} else {
@@ -1715,7 +1994,9 @@  discard block
 block discarded – undo
1715 1994
 	}
1716 1995
 	public function getStatsOwner($owner_name,$filter_name = '') {
1717 1996
 		global $globalArchiveMonths, $globalDBdriver;
1718
-		if ($filter_name == '') $filter_name = $this->filter_name;
1997
+		if ($filter_name == '') {
1998
+			$filter_name = $this->filter_name;
1999
+		}
1719 2000
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1720 2001
 		try {
1721 2002
 			$sth = $this->db->prepare($query);
@@ -1724,12 +2005,17 @@  discard block
 block discarded – undo
1724 2005
 			echo "error : ".$e->getMessage();
1725 2006
 		}
1726 2007
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1727
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1728
-		else return 0;
2008
+		if (isset($all[0]['cnt'])) {
2009
+			return $all[0]['cnt'];
2010
+		} else {
2011
+			return 0;
2012
+		}
1729 2013
 	}
1730 2014
 	public function getStatsPilotTotal($filter_name = '') {
1731 2015
 		global $globalArchiveMonths, $globalDBdriver;
1732
-		if ($filter_name == '') $filter_name = $this->filter_name;
2016
+		if ($filter_name == '') {
2017
+			$filter_name = $this->filter_name;
2018
+		}
1733 2019
 		if ($globalDBdriver == 'mysql') {
1734 2020
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1735 2021
 		} else {
@@ -1746,7 +2032,9 @@  discard block
 block discarded – undo
1746 2032
 	}
1747 2033
 	public function getStatsPilot($pilot,$filter_name = '') {
1748 2034
 		global $globalArchiveMonths, $globalDBdriver;
1749
-		if ($filter_name == '') $filter_name = $this->filter_name;
2035
+		if ($filter_name == '') {
2036
+			$filter_name = $this->filter_name;
2037
+		}
1750 2038
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1751 2039
 		try {
1752 2040
 			$sth = $this->db->prepare($query);
@@ -1755,13 +2043,18 @@  discard block
 block discarded – undo
1755 2043
 			echo "error : ".$e->getMessage();
1756 2044
 		}
1757 2045
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1758
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1759
-		else return 0;
2046
+		if (isset($all[0]['cnt'])) {
2047
+			return $all[0]['cnt'];
2048
+		} else {
2049
+			return 0;
2050
+		}
1760 2051
 	}
1761 2052
 
1762 2053
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1763 2054
 		global $globalDBdriver;
1764
-		if ($filter_name == '') $filter_name = $this->filter_name;
2055
+		if ($filter_name == '') {
2056
+			$filter_name = $this->filter_name;
2057
+		}
1765 2058
 		if ($globalDBdriver == 'mysql') {
1766 2059
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1767 2060
 		} else {
@@ -1777,7 +2070,9 @@  discard block
 block discarded – undo
1777 2070
 	}
1778 2071
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1779 2072
 		global $globalDBdriver;
1780
-		if ($filter_name == '') $filter_name = $this->filter_name;
2073
+		if ($filter_name == '') {
2074
+			$filter_name = $this->filter_name;
2075
+		}
1781 2076
 		if ($globalDBdriver == 'mysql') {
1782 2077
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1783 2078
 		} else {
@@ -2273,27 +2568,37 @@  discard block
 block discarded – undo
2273 2568
 		date_default_timezone_set('UTC');
2274 2569
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2275 2570
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2276
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2571
+			if ($globalDebug) {
2572
+				echo '!!! Update Marine stats !!!'."\n";
2573
+			}
2277 2574
 			if (isset($last_update[0]['value'])) {
2278 2575
 				$last_update_day = $last_update[0]['value'];
2279
-			} else $last_update_day = '2012-12-12 12:12:12';
2576
+			} else {
2577
+				$last_update_day = '2012-12-12 12:12:12';
2578
+			}
2280 2579
 			$reset = false;
2281 2580
 			$Marine = new Marine($this->db);
2282 2581
 			$filtername = 'marine';
2283 2582
 			if ($Connection->tableExists('countries')) {
2284
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2583
+				if ($globalDebug) {
2584
+					echo 'Count all vessels by countries...'."\n";
2585
+				}
2285 2586
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2286 2587
 				foreach ($alldata as $number) {
2287 2588
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2288 2589
 				}
2289 2590
 			}
2290
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2591
+			if ($globalDebug) {
2592
+				echo 'Count all vessels by months...'."\n";
2593
+			}
2291 2594
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2292 2595
 			$filter_last_month = array('since_date' => $last_month);
2293 2596
 			$alldata = $Marine->countAllMonths($filter_last_month);
2294 2597
 			$lastyear = false;
2295 2598
 			foreach ($alldata as $number) {
2296
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2599
+				if ($number['year_name'] != date('Y')) {
2600
+					$lastyear = true;
2601
+				}
2297 2602
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2298 2603
 			}
2299 2604
 			echo 'Marine data...'."\n";
@@ -2323,7 +2628,9 @@  discard block
 block discarded – undo
2323 2628
 			foreach ($alldata as $number) {
2324 2629
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2325 2630
 			}
2326
-			if ($globalDebug) echo 'Count all types...'."\n";
2631
+			if ($globalDebug) {
2632
+				echo 'Count all types...'."\n";
2633
+			}
2327 2634
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2328 2635
 			foreach ($alldata as $number) {
2329 2636
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2335,26 +2642,36 @@  discard block
 block discarded – undo
2335 2642
 		}
2336 2643
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2337 2644
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2338
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2645
+			if ($globalDebug) {
2646
+				echo '!!! Update tracker stats !!!'."\n";
2647
+			}
2339 2648
 			if (isset($last_update[0]['value'])) {
2340 2649
 				$last_update_day = $last_update[0]['value'];
2341
-			} else $last_update_day = '2012-12-12 12:12:12';
2650
+			} else {
2651
+				$last_update_day = '2012-12-12 12:12:12';
2652
+			}
2342 2653
 			$reset = false;
2343 2654
 			$Tracker = new Tracker($this->db);
2344 2655
 			if ($Connection->tableExists('countries')) {
2345
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2656
+				if ($globalDebug) {
2657
+					echo 'Count all trackers by countries...'."\n";
2658
+				}
2346 2659
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2347 2660
 				foreach ($alldata as $number) {
2348 2661
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2349 2662
 				}
2350 2663
 			}
2351
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2664
+			if ($globalDebug) {
2665
+				echo 'Count all vessels by months...'."\n";
2666
+			}
2352 2667
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2353 2668
 			$filter_last_month = array('since_date' => $last_month);
2354 2669
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2355 2670
 			$lastyear = false;
2356 2671
 			foreach ($alldata as $number) {
2357
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2672
+				if ($number['year_name'] != date('Y')) {
2673
+					$lastyear = true;
2674
+				}
2358 2675
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2359 2676
 			}
2360 2677
 			echo 'Tracker data...'."\n";
@@ -2391,10 +2708,14 @@  discard block
 block discarded – undo
2391 2708
 
2392 2709
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2393 2710
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2394
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2711
+			if ($globalDebug) {
2712
+				echo '!!! Update aicraft stats !!!'."\n";
2713
+			}
2395 2714
 			if (isset($last_update[0]['value'])) {
2396 2715
 				$last_update_day = $last_update[0]['value'];
2397
-			} else $last_update_day = '2012-12-12 12:12:12';
2716
+			} else {
2717
+				$last_update_day = '2012-12-12 12:12:12';
2718
+			}
2398 2719
 			$reset = false;
2399 2720
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2400 2721
 			if ($globalStatsResetYear) {
@@ -2403,43 +2724,63 @@  discard block
 block discarded – undo
2403 2724
 			}
2404 2725
 			$Spotter = new Spotter($this->db);
2405 2726
 
2406
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2727
+			if ($globalDebug) {
2728
+				echo 'Count all aircraft types...'."\n";
2729
+			}
2407 2730
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2408 2731
 			foreach ($alldata as $number) {
2409 2732
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2410 2733
 			}
2411
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2734
+			if ($globalDebug) {
2735
+				echo 'Count all airlines...'."\n";
2736
+			}
2412 2737
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2413 2738
 			foreach ($alldata as $number) {
2414 2739
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2415 2740
 			}
2416
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2741
+			if ($globalDebug) {
2742
+				echo 'Count all registrations...'."\n";
2743
+			}
2417 2744
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2418 2745
 			foreach ($alldata as $number) {
2419 2746
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2420 2747
 			}
2421
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2748
+			if ($globalDebug) {
2749
+				echo 'Count all callsigns...'."\n";
2750
+			}
2422 2751
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2423 2752
 			foreach ($alldata as $number) {
2424 2753
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2425 2754
 			}
2426
-			if ($globalDebug) echo 'Count all owners...'."\n";
2755
+			if ($globalDebug) {
2756
+				echo 'Count all owners...'."\n";
2757
+			}
2427 2758
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2428 2759
 			foreach ($alldata as $number) {
2429 2760
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2430 2761
 			}
2431
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2762
+			if ($globalDebug) {
2763
+				echo 'Count all pilots...'."\n";
2764
+			}
2432 2765
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2433 2766
 			foreach ($alldata as $number) {
2434
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2767
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2768
+					$number['pilot_id'] = $number['pilot_name'];
2769
+				}
2435 2770
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2436 2771
 			}
2437 2772
 			
2438
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2773
+			if ($globalDebug) {
2774
+				echo 'Count all departure airports...'."\n";
2775
+			}
2439 2776
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2440
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2777
+			if ($globalDebug) {
2778
+				echo 'Count all detected departure airports...'."\n";
2779
+			}
2441 2780
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2442
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2781
+			if ($globalDebug) {
2782
+				echo 'Order departure airports...'."\n";
2783
+			}
2443 2784
 			$alldata = array();
2444 2785
 			foreach ($pall as $value) {
2445 2786
 				$icao = $value['airport_departure_icao'];
@@ -2449,7 +2790,9 @@  discard block
 block discarded – undo
2449 2790
 				$icao = $value['airport_departure_icao'];
2450 2791
 				if (isset($alldata[$icao])) {
2451 2792
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2452
-				} else $alldata[$icao] = $value;
2793
+				} else {
2794
+					$alldata[$icao] = $value;
2795
+				}
2453 2796
 			}
2454 2797
 			$count = array();
2455 2798
 			foreach ($alldata as $key => $row) {
@@ -2459,11 +2802,17 @@  discard block
 block discarded – undo
2459 2802
 			foreach ($alldata as $number) {
2460 2803
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2461 2804
 			}
2462
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2805
+			if ($globalDebug) {
2806
+				echo 'Count all arrival airports...'."\n";
2807
+			}
2463 2808
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2464
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2809
+			if ($globalDebug) {
2810
+				echo 'Count all detected arrival airports...'."\n";
2811
+			}
2465 2812
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2466
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2813
+			if ($globalDebug) {
2814
+				echo 'Order arrival airports...'."\n";
2815
+			}
2467 2816
 			$alldata = array();
2468 2817
 			foreach ($pall as $value) {
2469 2818
 				$icao = $value['airport_arrival_icao'];
@@ -2473,7 +2822,9 @@  discard block
 block discarded – undo
2473 2822
 				$icao = $value['airport_arrival_icao'];
2474 2823
 				if (isset($alldata[$icao])) {
2475 2824
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2476
-				} else $alldata[$icao] = $value;
2825
+				} else {
2826
+					$alldata[$icao] = $value;
2827
+				}
2477 2828
 			}
2478 2829
 			$count = array();
2479 2830
 			foreach ($alldata as $key => $row) {
@@ -2484,7 +2835,9 @@  discard block
 block discarded – undo
2484 2835
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2485 2836
 			}
2486 2837
 			if ($Connection->tableExists('countries')) {
2487
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2838
+				if ($globalDebug) {
2839
+					echo 'Count all flights by countries...'."\n";
2840
+				}
2488 2841
 				//$SpotterArchive = new SpotterArchive();
2489 2842
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2490 2843
 				$Spotter = new Spotter($this->db);
@@ -2495,7 +2848,9 @@  discard block
 block discarded – undo
2495 2848
 			}
2496 2849
 			
2497 2850
 			if (isset($globalAccidents) && $globalAccidents) {
2498
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2851
+				if ($globalDebug) {
2852
+					echo 'Count fatalities stats...'."\n";
2853
+				}
2499 2854
 				$Accident = new Accident($this->db);
2500 2855
 				$this->deleteStatsByType('fatalities_byyear');
2501 2856
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2511,48 +2866,68 @@  discard block
 block discarded – undo
2511 2866
 
2512 2867
 			// Add by month using getstat if month finish...
2513 2868
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2514
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2869
+			if ($globalDebug) {
2870
+				echo 'Count all flights by months...'."\n";
2871
+			}
2515 2872
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2516 2873
 			$filter_last_month = array('since_date' => $last_month);
2517 2874
 			$Spotter = new Spotter($this->db);
2518 2875
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2519 2876
 			$lastyear = false;
2520 2877
 			foreach ($alldata as $number) {
2521
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2878
+				if ($number['year_name'] != date('Y')) {
2879
+					$lastyear = true;
2880
+				}
2522 2881
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2523 2882
 			}
2524
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2883
+			if ($globalDebug) {
2884
+				echo 'Count all military flights by months...'."\n";
2885
+			}
2525 2886
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2526 2887
 			foreach ($alldata as $number) {
2527 2888
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2528 2889
 			}
2529
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2890
+			if ($globalDebug) {
2891
+				echo 'Count all owners by months...'."\n";
2892
+			}
2530 2893
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2531 2894
 			foreach ($alldata as $number) {
2532 2895
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2533 2896
 			}
2534
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2897
+			if ($globalDebug) {
2898
+				echo 'Count all pilots by months...'."\n";
2899
+			}
2535 2900
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2536 2901
 			foreach ($alldata as $number) {
2537 2902
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2538 2903
 			}
2539
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2904
+			if ($globalDebug) {
2905
+				echo 'Count all airlines by months...'."\n";
2906
+			}
2540 2907
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2541 2908
 			foreach ($alldata as $number) {
2542 2909
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2543 2910
 			}
2544
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2911
+			if ($globalDebug) {
2912
+				echo 'Count all aircrafts by months...'."\n";
2913
+			}
2545 2914
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2546 2915
 			foreach ($alldata as $number) {
2547 2916
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2548 2917
 			}
2549
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2918
+			if ($globalDebug) {
2919
+				echo 'Count all real arrivals by months...'."\n";
2920
+			}
2550 2921
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2551 2922
 			foreach ($alldata as $number) {
2552 2923
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2553 2924
 			}
2554
-			if ($globalDebug) echo 'Airports data...'."\n";
2555
-			if ($globalDebug) echo '...Departure'."\n";
2925
+			if ($globalDebug) {
2926
+				echo 'Airports data...'."\n";
2927
+			}
2928
+			if ($globalDebug) {
2929
+				echo '...Departure'."\n";
2930
+			}
2556 2931
 			$this->deleteStatAirport('daily');
2557 2932
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2558 2933
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2670,7 +3045,9 @@  discard block
 block discarded – undo
2670 3045
 			// Count by airlines
2671 3046
 			echo '--- Stats by airlines ---'."\n";
2672 3047
 			if ($Connection->tableExists('countries')) {
2673
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3048
+				if ($globalDebug) {
3049
+					echo 'Count all flights by countries by airlines...'."\n";
3050
+				}
2674 3051
 				$SpotterArchive = new SpotterArchive($this->db);
2675 3052
 				//$Spotter = new Spotter($this->db);
2676 3053
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2679,37 +3056,53 @@  discard block
 block discarded – undo
2679 3056
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2680 3057
 				}
2681 3058
 			}
2682
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3059
+			if ($globalDebug) {
3060
+				echo 'Count all aircraft types by airlines...'."\n";
3061
+			}
2683 3062
 			$Spotter = new Spotter($this->db);
2684 3063
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2685 3064
 			foreach ($alldata as $number) {
2686 3065
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2687 3066
 			}
2688
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3067
+			if ($globalDebug) {
3068
+				echo 'Count all aircraft registrations by airlines...'."\n";
3069
+			}
2689 3070
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2690 3071
 			foreach ($alldata as $number) {
2691 3072
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2692 3073
 			}
2693
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3074
+			if ($globalDebug) {
3075
+				echo 'Count all callsigns by airlines...'."\n";
3076
+			}
2694 3077
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2695 3078
 			foreach ($alldata as $number) {
2696 3079
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2697 3080
 			}
2698
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3081
+			if ($globalDebug) {
3082
+				echo 'Count all owners by airlines...'."\n";
3083
+			}
2699 3084
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2700 3085
 			foreach ($alldata as $number) {
2701 3086
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2702 3087
 			}
2703
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3088
+			if ($globalDebug) {
3089
+				echo 'Count all pilots by airlines...'."\n";
3090
+			}
2704 3091
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2705 3092
 			foreach ($alldata as $number) {
2706 3093
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2707 3094
 			}
2708
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3095
+			if ($globalDebug) {
3096
+				echo 'Count all departure airports by airlines...'."\n";
3097
+			}
2709 3098
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2710
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3099
+			if ($globalDebug) {
3100
+				echo 'Count all detected departure airports by airlines...'."\n";
3101
+			}
2711 3102
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2712
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3103
+			if ($globalDebug) {
3104
+				echo 'Order detected departure airports by airlines...'."\n";
3105
+			}
2713 3106
 			//$alldata = array();
2714 3107
 			foreach ($dall as $value) {
2715 3108
 				$icao = $value['airport_departure_icao'];
@@ -2730,11 +3123,17 @@  discard block
 block discarded – undo
2730 3123
 			foreach ($alldata as $number) {
2731 3124
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2732 3125
 			}
2733
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3126
+			if ($globalDebug) {
3127
+				echo 'Count all arrival airports by airlines...'."\n";
3128
+			}
2734 3129
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2735
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3130
+			if ($globalDebug) {
3131
+				echo 'Count all detected arrival airports by airlines...'."\n";
3132
+			}
2736 3133
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2737
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3134
+			if ($globalDebug) {
3135
+				echo 'Order arrival airports by airlines...'."\n";
3136
+			}
2738 3137
 			//$alldata = array();
2739 3138
 			foreach ($dall as $value) {
2740 3139
 				$icao = $value['airport_arrival_icao'];
@@ -2753,37 +3152,53 @@  discard block
 block discarded – undo
2753 3152
 			}
2754 3153
 			$alldata = $pall;
2755 3154
 			foreach ($alldata as $number) {
2756
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3155
+				if ($number['airline_icao'] != '') {
3156
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3157
+				}
3158
+			}
3159
+			if ($globalDebug) {
3160
+				echo 'Count all flights by months by airlines...'."\n";
2757 3161
 			}
2758
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2759 3162
 			$Spotter = new Spotter($this->db);
2760 3163
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2761 3164
 			$lastyear = false;
2762 3165
 			foreach ($alldata as $number) {
2763
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3166
+				if ($number['year_name'] != date('Y')) {
3167
+					$lastyear = true;
3168
+				}
2764 3169
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2765 3170
 			}
2766
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3171
+			if ($globalDebug) {
3172
+				echo 'Count all owners by months by airlines...'."\n";
3173
+			}
2767 3174
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2768 3175
 			foreach ($alldata as $number) {
2769 3176
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2770 3177
 			}
2771
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3178
+			if ($globalDebug) {
3179
+				echo 'Count all pilots by months by airlines...'."\n";
3180
+			}
2772 3181
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2773 3182
 			foreach ($alldata as $number) {
2774 3183
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2775 3184
 			}
2776
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3185
+			if ($globalDebug) {
3186
+				echo 'Count all aircrafts by months by airlines...'."\n";
3187
+			}
2777 3188
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2778 3189
 			foreach ($alldata as $number) {
2779 3190
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2780 3191
 			}
2781
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3192
+			if ($globalDebug) {
3193
+				echo 'Count all real arrivals by months by airlines...'."\n";
3194
+			}
2782 3195
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2783 3196
 			foreach ($alldata as $number) {
2784 3197
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2785 3198
 			}
2786
-			if ($globalDebug) echo '...Departure'."\n";
3199
+			if ($globalDebug) {
3200
+				echo '...Departure'."\n";
3201
+			}
2787 3202
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2788 3203
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2789 3204
 			foreach ($dall as $value) {
@@ -2806,7 +3221,9 @@  discard block
 block discarded – undo
2806 3221
 			foreach ($alldata as $number) {
2807 3222
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
2808 3223
 			}
2809
-			if ($globalDebug) echo '...Arrival'."\n";
3224
+			if ($globalDebug) {
3225
+				echo '...Arrival'."\n";
3226
+			}
2810 3227
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2811 3228
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2812 3229
 			foreach ($dall as $value) {
@@ -2830,13 +3247,19 @@  discard block
 block discarded – undo
2830 3247
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
2831 3248
 			}
2832 3249
 
2833
-			if ($globalDebug) echo 'Flights data...'."\n";
2834
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3250
+			if ($globalDebug) {
3251
+				echo 'Flights data...'."\n";
3252
+			}
3253
+			if ($globalDebug) {
3254
+				echo '-> countAllDatesLastMonth...'."\n";
3255
+			}
2835 3256
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2836 3257
 			foreach ($alldata as $number) {
2837 3258
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2838 3259
 			}
2839
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3260
+			if ($globalDebug) {
3261
+				echo '-> countAllDates...'."\n";
3262
+			}
2840 3263
 			//$previousdata = $this->countAllDatesByAirlines();
2841 3264
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2842 3265
 			$values = array();
@@ -2849,14 +3272,18 @@  discard block
 block discarded – undo
2849 3272
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2850 3273
 			}
2851 3274
 			
2852
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3275
+			if ($globalDebug) {
3276
+				echo '-> countAllHours...'."\n";
3277
+			}
2853 3278
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2854 3279
 			foreach ($alldata as $number) {
2855 3280
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2856 3281
 			}
2857 3282
 
2858 3283
 			// Stats by filters
2859
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3284
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3285
+				$globalStatsFilters = array();
3286
+			}
2860 3287
 			foreach ($globalStatsFilters as $name => $filter) {
2861 3288
 				if (!empty($filter)) {
2862 3289
 					//$filter_name = $filter['name'];
@@ -2864,7 +3291,9 @@  discard block
 block discarded – undo
2864 3291
 					$reset = false;
2865 3292
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2866 3293
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2867
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3294
+						if ($globalDebug) {
3295
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3296
+						}
2868 3297
 						$this->deleteOldStats($filter_name);
2869 3298
 						unset($last_update);
2870 3299
 					}
@@ -2881,39 +3310,55 @@  discard block
 block discarded – undo
2881 3310
 						$reset = true;
2882 3311
 					}
2883 3312
 					// Count by filter
2884
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3313
+					if ($globalDebug) {
3314
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3315
+					}
2885 3316
 					$Spotter = new Spotter($this->db);
2886
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3317
+					if ($globalDebug) {
3318
+						echo 'Count all aircraft types...'."\n";
3319
+					}
2887 3320
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2888 3321
 					foreach ($alldata as $number) {
2889 3322
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2890 3323
 					}
2891
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3324
+					if ($globalDebug) {
3325
+						echo 'Count all airlines...'."\n";
3326
+					}
2892 3327
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2893 3328
 					foreach ($alldata as $number) {
2894 3329
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2895 3330
 					}
2896
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3331
+					if ($globalDebug) {
3332
+						echo 'Count all aircraft registrations...'."\n";
3333
+					}
2897 3334
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2898 3335
 					foreach ($alldata as $number) {
2899 3336
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2900 3337
 					}
2901
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3338
+					if ($globalDebug) {
3339
+						echo 'Count all callsigns...'."\n";
3340
+					}
2902 3341
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2903 3342
 					foreach ($alldata as $number) {
2904 3343
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2905 3344
 					}
2906
-					if ($globalDebug) echo 'Count all owners...'."\n";
3345
+					if ($globalDebug) {
3346
+						echo 'Count all owners...'."\n";
3347
+					}
2907 3348
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2908 3349
 					foreach ($alldata as $number) {
2909 3350
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2910 3351
 					}
2911
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3352
+					if ($globalDebug) {
3353
+						echo 'Count all pilots...'."\n";
3354
+					}
2912 3355
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2913 3356
 					foreach ($alldata as $number) {
2914 3357
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2915 3358
 					}
2916
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3359
+					if ($globalDebug) {
3360
+						echo 'Count departure airports...'."\n";
3361
+					}
2917 3362
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2918 3363
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2919 3364
 					$alldata = array();
@@ -2925,7 +3370,9 @@  discard block
 block discarded – undo
2925 3370
 						$icao = $value['airport_departure_icao'];
2926 3371
 						if (isset($alldata[$icao])) {
2927 3372
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2928
-						} else $alldata[$icao] = $value;
3373
+						} else {
3374
+							$alldata[$icao] = $value;
3375
+						}
2929 3376
 					}
2930 3377
 					$count = array();
2931 3378
 					foreach ($alldata as $key => $row) {
@@ -2935,7 +3382,9 @@  discard block
 block discarded – undo
2935 3382
 					foreach ($alldata as $number) {
2936 3383
 						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2937 3384
 					}
2938
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3385
+					if ($globalDebug) {
3386
+						echo 'Count all arrival airports...'."\n";
3387
+					}
2939 3388
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2940 3389
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2941 3390
 					$alldata = array();
@@ -2947,7 +3396,9 @@  discard block
 block discarded – undo
2947 3396
 						$icao = $value['airport_arrival_icao'];
2948 3397
 						if (isset($alldata[$icao])) {
2949 3398
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2950
-						} else $alldata[$icao] = $value;
3399
+						} else {
3400
+							$alldata[$icao] = $value;
3401
+						}
2951 3402
 					}
2952 3403
 					$count = array();
2953 3404
 					foreach ($alldata as $key => $row) {
@@ -2957,35 +3408,49 @@  discard block
 block discarded – undo
2957 3408
 					foreach ($alldata as $number) {
2958 3409
 						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2959 3410
 					}
2960
-					if ($globalDebug) echo 'Count all months...'."\n";
3411
+					if ($globalDebug) {
3412
+						echo 'Count all months...'."\n";
3413
+					}
2961 3414
 					$Spotter = new Spotter($this->db);
2962 3415
 					$alldata = $Spotter->countAllMonths($filter);
2963 3416
 					$lastyear = false;
2964 3417
 					foreach ($alldata as $number) {
2965
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3418
+						if ($number['year_name'] != date('Y')) {
3419
+							$lastyear = true;
3420
+						}
2966 3421
 						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2967 3422
 					}
2968
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3423
+					if ($globalDebug) {
3424
+						echo 'Count all owners by months...'."\n";
3425
+					}
2969 3426
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2970 3427
 					foreach ($alldata as $number) {
2971 3428
 						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2972 3429
 					}
2973
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3430
+					if ($globalDebug) {
3431
+						echo 'Count all pilots by months...'."\n";
3432
+					}
2974 3433
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2975 3434
 					foreach ($alldata as $number) {
2976 3435
 						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2977 3436
 					}
2978
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3437
+					if ($globalDebug) {
3438
+						echo 'Count all military by months...'."\n";
3439
+					}
2979 3440
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2980 3441
 					foreach ($alldata as $number) {
2981 3442
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2982 3443
 					}
2983
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3444
+					if ($globalDebug) {
3445
+						echo 'Count all aircrafts by months...'."\n";
3446
+					}
2984 3447
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2985 3448
 				    	foreach ($alldata as $number) {
2986 3449
 			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2987 3450
 					}
2988
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3451
+					if ($globalDebug) {
3452
+						echo 'Count all real arrivals by months...'."\n";
3453
+					}
2989 3454
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2990 3455
 					foreach ($alldata as $number) {
2991 3456
 						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
Please login to merge, or discard this patch.