Completed
Push — master ( f7c9fa...92ea23 )
by Yannick
27:20
created
require/class.Stats.php 1 patch
Braces   +661 added lines, -231 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 countAllAirlineCountries($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 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";
226
-			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";
255
+			if ($limit) {
256
+				$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";
257
+			} else {
258
+				$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";
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
 			$Spotter = new Spotter($this->db);
237 272
 			$filters = array();
@@ -246,7 +281,9 @@  discard block
 block discarded – undo
246 281
 	}
247 282
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
248 283
 		global $globalStatsFilters;
249
-		if ($filter_name == '') $filter_name = $this->filter_name;
284
+		if ($filter_name == '') {
285
+			$filter_name = $this->filter_name;
286
+		}
250 287
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
251 288
 			$Spotter = new Spotter($this->db);
252 289
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -255,8 +292,11 @@  discard block
 block discarded – undo
255 292
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
256 293
 			}
257 294
 			if ($year == '' && $month == '') {
258
-				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";
259
-				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";
295
+				if ($limit) {
296
+					$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";
297
+				} else {
298
+					$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";
299
+				}
260 300
 				try {
261 301
 					$sth = $this->db->prepare($query);
262 302
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -264,11 +304,16 @@  discard block
 block discarded – undo
264 304
 					echo "error : ".$e->getMessage();
265 305
 				}
266 306
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
267
-			} else $all = array();
307
+			} else {
308
+				$all = array();
309
+			}
268 310
 		} else {
269 311
 			if ($year == '' && $month == '') {
270
-				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";
271
-				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";
312
+				if ($limit) {
313
+					$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";
314
+				} else {
315
+					$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";
316
+				}
272 317
 				try {
273 318
 					$sth = $this->db->prepare($query);
274 319
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -276,7 +321,9 @@  discard block
 block discarded – undo
276 321
 					echo "error : ".$e->getMessage();
277 322
 				}
278 323
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
279
-			} else $all = array();
324
+			} else {
325
+				$all = array();
326
+			}
280 327
 		}
281 328
 		if (empty($all)) {
282 329
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -296,7 +343,9 @@  discard block
 block discarded – undo
296 343
 
297 344
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
298 345
 		global $globalStatsFilters;
299
-		if ($filter_name == '') $filter_name = $this->filter_name;
346
+		if ($filter_name == '') {
347
+			$filter_name = $this->filter_name;
348
+		}
300 349
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
301 350
 			$Spotter = new Spotter($this->db);
302 351
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -305,8 +354,11 @@  discard block
 block discarded – undo
305 354
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
306 355
 			}
307 356
 			if ($year == '' && $month == '') {
308
-				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";
309
-				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";
357
+				if ($limit) {
358
+					$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";
359
+				} else {
360
+					$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";
361
+				}
310 362
 				try {
311 363
 					$sth = $this->db->prepare($query);
312 364
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -314,11 +366,16 @@  discard block
 block discarded – undo
314 366
 					echo "error : ".$e->getMessage();
315 367
 				}
316 368
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
317
-			} else $all = array();
369
+			} else {
370
+				$all = array();
371
+			}
318 372
 		} else {
319 373
 			if ($year == '' && $month == '') {
320
-				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";
321
-				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";
374
+				if ($limit) {
375
+					$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";
376
+				} else {
377
+					$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";
378
+				}
322 379
 				try {
323 380
 					$sth = $this->db->prepare($query);
324 381
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -326,7 +383,9 @@  discard block
 block discarded – undo
326 383
 					echo "error : ".$e->getMessage();
327 384
 				}
328 385
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
329
-			} else $all = array();
386
+			} else {
387
+				$all = array();
388
+			}
330 389
 		}
331 390
 		if (empty($all)) {
332 391
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -345,7 +404,9 @@  discard block
 block discarded – undo
345 404
 	}
346 405
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
347 406
 		global $globalStatsFilters;
348
-		if ($filter_name == '') $filter_name = $this->filter_name;
407
+		if ($filter_name == '') {
408
+			$filter_name = $this->filter_name;
409
+		}
349 410
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
350 411
 			$Spotter = new Spotter($this->db);
351 412
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -353,12 +414,18 @@  discard block
 block discarded – undo
353 414
 			foreach ($airlines as $airline) {
354 415
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
355 416
 			}
356
-			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";
357
-			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";
417
+			if ($limit) {
418
+				$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";
419
+			} else {
420
+				$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";
421
+			}
358 422
 			$query_values = array(':filter_name' => $filter_name);
359 423
 		} else {
360
-			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";
361
-			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";
424
+			if ($limit) {
425
+				$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";
426
+			} else {
427
+				$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";
428
+			}
362 429
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
363 430
 		}
364 431
 		try {
@@ -386,17 +453,29 @@  discard block
 block discarded – undo
386 453
 
387 454
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
388 455
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
389
-		if ($filter_name == '') $filter_name = $this->filter_name;
456
+		if ($filter_name == '') {
457
+			$filter_name = $this->filter_name;
458
+		}
390 459
 		if ($year == '' && $month == '') {
391
-			if ($globalVATSIM) $forsource = 'vatsim';
392
-			if ($globalIVAO) $forsource = 'ivao';
460
+			if ($globalVATSIM) {
461
+				$forsource = 'vatsim';
462
+			}
463
+			if ($globalIVAO) {
464
+				$forsource = 'ivao';
465
+			}
393 466
 			if (isset($forsource)) {
394
-				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";
395
-				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";
467
+				if ($limit) {
468
+					$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";
469
+				} else {
470
+					$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";
471
+				}
396 472
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
397 473
 			} else {
398
-				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";
399
-				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";
474
+				if ($limit) {
475
+					$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";
476
+				} else {
477
+					$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";
478
+				}
400 479
 				$query_values = array(':filter_name' => $filter_name);
401 480
 			}
402 481
 			try {
@@ -406,7 +485,9 @@  discard block
 block discarded – undo
406 485
 				echo "error : ".$e->getMessage();
407 486
 			}
408 487
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409
-		} else $all = array();
488
+		} else {
489
+			$all = array();
490
+		}
410 491
                 if (empty($all)) {
411 492
 	                $Spotter = new Spotter($this->db);
412 493
             		$filters = array();
@@ -421,7 +502,9 @@  discard block
 block discarded – undo
421 502
 	}
422 503
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423 504
 		global $globalStatsFilters;
424
-		if ($filter_name == '') $filter_name = $this->filter_name;
505
+		if ($filter_name == '') {
506
+			$filter_name = $this->filter_name;
507
+		}
425 508
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
426 509
 			$Spotter = new Spotter($this->db);
427 510
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -430,8 +513,11 @@  discard block
 block discarded – undo
430 513
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
431 514
 			}
432 515
 			if ($year == '' && $month == '') {
433
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
434
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
516
+				if ($limit) {
517
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
518
+				} else {
519
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
520
+				}
435 521
 				try {
436 522
 					$sth = $this->db->prepare($query);
437 523
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -439,11 +525,16 @@  discard block
 block discarded – undo
439 525
 					echo "error : ".$e->getMessage();
440 526
 				}
441 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
442
-			} else $all = array();
528
+			} else {
529
+				$all = array();
530
+			}
443 531
 		} else {
444 532
 			if ($year == '' && $month == '') {
445
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
446
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
533
+				if ($limit) {
534
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
535
+				} else {
536
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
537
+				}
447 538
 				try {
448 539
 					$sth = $this->db->prepare($query);
449 540
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -451,7 +542,9 @@  discard block
 block discarded – undo
451 542
 					echo "error : ".$e->getMessage();
452 543
 				}
453 544
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-			} else $all = array();
545
+			} else {
546
+				$all = array();
547
+			}
455 548
 		}
456 549
 		if (empty($all)) {
457 550
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -470,7 +563,9 @@  discard block
 block discarded – undo
470 563
 	}
471 564
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
472 565
 		global $globalStatsFilters;
473
-		if ($filter_name == '') $filter_name = $this->filter_name;
566
+		if ($filter_name == '') {
567
+			$filter_name = $this->filter_name;
568
+		}
474 569
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
475 570
 			$Spotter = new Spotter($this->db);
476 571
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -479,8 +574,11 @@  discard block
 block discarded – undo
479 574
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
480 575
 			}
481 576
 			if ($year == '' && $month == '') {
482
-				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";
483
-				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";
577
+				if ($limit) {
578
+					$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";
579
+				} else {
580
+					$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";
581
+				}
484 582
 				 try {
485 583
 					$sth = $this->db->prepare($query);
486 584
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -488,11 +586,16 @@  discard block
 block discarded – undo
488 586
 					echo "error : ".$e->getMessage();
489 587
 				}
490 588
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
491
-			} else $all = array();
589
+			} else {
590
+				$all = array();
591
+			}
492 592
 		} else {
493 593
 			if ($year == '' && $month == '') {
494
-				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";
495
-				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";
594
+				if ($limit) {
595
+					$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";
596
+				} else {
597
+					$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";
598
+				}
496 599
 				 try {
497 600
 					$sth = $this->db->prepare($query);
498 601
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -500,7 +603,9 @@  discard block
 block discarded – undo
500 603
 					echo "error : ".$e->getMessage();
501 604
 				}
502 605
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-			} else $all = array();
606
+			} else {
607
+				$all = array();
608
+			}
504 609
 		}
505 610
 		if (empty($all)) {
506 611
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -519,7 +624,9 @@  discard block
 block discarded – undo
519 624
 	}
520 625
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
521 626
 		$Connection = new Connection($this->db);
522
-		if ($filter_name == '') $filter_name = $this->filter_name;
627
+		if ($filter_name == '') {
628
+			$filter_name = $this->filter_name;
629
+		}
523 630
 		if ($Connection->tableExists('countries')) {
524 631
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
525 632
 				$Spotter = new Spotter($this->db);
@@ -529,8 +636,11 @@  discard block
 block discarded – undo
529 636
 					foreach ($airlines as $airline) {
530 637
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
531 638
 					}
532
-					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";
533
-					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";
639
+					if ($limit) {
640
+						$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";
641
+					} else {
642
+						$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";
643
+					}
534 644
 					 try {
535 645
 						$sth = $this->db->prepare($query);
536 646
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -539,11 +649,16 @@  discard block
 block discarded – undo
539 649
 					}
540 650
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541 651
 					return $all;
542
-				} else return array();
652
+				} else {
653
+					return array();
654
+				}
543 655
 			} else {
544 656
 				if ($year == '' && $month == '') {
545
-					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";
546
-					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";
657
+					if ($limit) {
658
+						$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";
659
+					} else {
660
+						$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";
661
+					}
547 662
 					 try {
548 663
 						$sth = $this->db->prepare($query);
549 664
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -552,7 +667,9 @@  discard block
 block discarded – undo
552 667
 					}
553 668
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 669
 					return $all;
555
-				} else return array();
670
+				} else {
671
+					return array();
672
+				}
556 673
 			}
557 674
 		} else {
558 675
 			/*
@@ -566,10 +683,15 @@  discard block
 block discarded – undo
566 683
 	}
567 684
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
568 685
 		global $globalStatsFilters;
569
-		if ($filter_name == '') $filter_name = $this->filter_name;
686
+		if ($filter_name == '') {
687
+			$filter_name = $this->filter_name;
688
+		}
570 689
 		if ($year == '' && $month == '') {
571
-			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";
572
-			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";
690
+			if ($limit) {
691
+				$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";
692
+			} else {
693
+				$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";
694
+			}
573 695
 			try {
574 696
 				$sth = $this->db->prepare($query);
575 697
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,7 +699,9 @@  discard block
 block discarded – undo
577 699
 				echo "error : ".$e->getMessage();
578 700
 			}
579 701
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
580
-		} else $all = array();
702
+		} else {
703
+			$all = array();
704
+		}
581 705
 		if (empty($all)) {
582 706
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
583 707
 			if ($filter_name != '') {
@@ -592,7 +716,9 @@  discard block
 block discarded – undo
592 716
 
593 717
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
594 718
 		global $globalStatsFilters;
595
-		if ($filter_name == '') $filter_name = $this->filter_name;
719
+		if ($filter_name == '') {
720
+			$filter_name = $this->filter_name;
721
+		}
596 722
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
597 723
 			$Spotter = new Spotter($this->db);
598 724
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -601,8 +727,11 @@  discard block
 block discarded – undo
601 727
 				foreach ($airlines as $airline) {
602 728
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
603 729
 				}
604
-				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";
605
-				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";
730
+				if ($limit) {
731
+					$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";
732
+				} else {
733
+					$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";
734
+				}
606 735
 				try {
607 736
 					$sth = $this->db->prepare($query);
608 737
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -610,11 +739,16 @@  discard block
 block discarded – undo
610 739
 					echo "error : ".$e->getMessage();
611 740
 				}
612 741
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
613
-			} else $all = array();
742
+			} else {
743
+				$all = array();
744
+			}
614 745
 		} else {
615 746
 			if ($year == '' && $month == '') {
616
-				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";
617
-				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";
747
+				if ($limit) {
748
+					$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";
749
+				} else {
750
+					$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";
751
+				}
618 752
 				try {
619 753
 					$sth = $this->db->prepare($query);
620 754
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -622,7 +756,9 @@  discard block
 block discarded – undo
622 756
 					echo "error : ".$e->getMessage();
623 757
 				}
624 758
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
625
-			} else $all = array();
759
+			} else {
760
+				$all = array();
761
+			}
626 762
 		}
627 763
 		if (empty($all)) {
628 764
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -641,7 +777,9 @@  discard block
 block discarded – undo
641 777
 	}
642 778
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
643 779
 		global $globalStatsFilters;
644
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
645 783
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
646 784
 			$Spotter = new Spotter($this->db);
647 785
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -650,8 +788,11 @@  discard block
 block discarded – undo
650 788
 				foreach ($airlines as $airline) {
651 789
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
652 790
 				}
653
-				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";
654
-				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";
791
+				if ($limit) {
792
+					$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";
793
+				} else {
794
+					$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";
795
+				}
655 796
 				try {
656 797
 					$sth = $this->db->prepare($query);
657 798
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -659,11 +800,16 @@  discard block
 block discarded – undo
659 800
 					echo "error : ".$e->getMessage();
660 801
 				}
661 802
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662
-			} else $all = array();
803
+			} else {
804
+				$all = array();
805
+			}
663 806
 		} else {
664 807
 			if ($year == '' && $month == '') {
665
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
666
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
808
+				if ($limit) {
809
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
810
+				} else {
811
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
812
+				}
667 813
 				try {
668 814
 					$sth = $this->db->prepare($query);
669 815
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -671,7 +817,9 @@  discard block
 block discarded – undo
671 817
 					echo "error : ".$e->getMessage();
672 818
 				}
673 819
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
674
-			} else $all = array();
820
+			} else {
821
+				$all = array();
822
+			}
675 823
 		}
676 824
 		if (empty($all)) {
677 825
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -696,7 +844,9 @@  discard block
 block discarded – undo
696 844
 				$icao = $value['airport_departure_icao'];
697 845
 				if (isset($all[$icao])) {
698 846
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
699
-				} else $all[$icao] = $value;
847
+				} else {
848
+					$all[$icao] = $value;
849
+				}
700 850
 			}
701 851
 			$count = array();
702 852
 			foreach ($all as $key => $row) {
@@ -708,7 +858,9 @@  discard block
 block discarded – undo
708 858
 	}
709 859
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
710 860
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
712 864
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
713 865
 			$Spotter = new Spotter($this->db);
714 866
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -717,8 +869,11 @@  discard block
 block discarded – undo
717 869
 				foreach ($airlines as $airline) {
718 870
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
719 871
 				}
720
-				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";
721
-				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";
872
+				if ($limit) {
873
+					$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";
874
+				} else {
875
+					$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";
876
+				}
722 877
 				try {
723 878
 					$sth = $this->db->prepare($query);
724 879
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -726,11 +881,16 @@  discard block
 block discarded – undo
726 881
 					echo "error : ".$e->getMessage();
727 882
 				}
728 883
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
729
-			} else $all = array();
884
+			} else {
885
+				$all = array();
886
+			}
730 887
 		} else {
731 888
 			if ($year == '' && $month == '') {
732
-				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";
733
-				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";
889
+				if ($limit) {
890
+					$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";
891
+				} else {
892
+					$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";
893
+				}
734 894
 				try {
735 895
 					$sth = $this->db->prepare($query);
736 896
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -738,7 +898,9 @@  discard block
 block discarded – undo
738 898
 					echo "error : ".$e->getMessage();
739 899
 				}
740 900
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
741
-			} else $all = array();
901
+			} else {
902
+				$all = array();
903
+			}
742 904
 		}
743 905
 		if (empty($all)) {
744 906
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -763,7 +925,9 @@  discard block
 block discarded – undo
763 925
 				$icao = $value['airport_arrival_icao'];
764 926
 				if (isset($all[$icao])) {
765 927
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
766
-				} else $all[$icao] = $value;
928
+				} else {
929
+					$all[$icao] = $value;
930
+				}
767 931
 			}
768 932
 			$count = array();
769 933
 			foreach ($all as $key => $row) {
@@ -775,7 +939,9 @@  discard block
 block discarded – undo
775 939
 	}
776 940
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
777 941
 		global $globalDBdriver, $globalStatsFilters;
778
-		if ($filter_name == '') $filter_name = $this->filter_name;
942
+		if ($filter_name == '') {
943
+			$filter_name = $this->filter_name;
944
+		}
779 945
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
780 946
 			$Spotter = new Spotter($this->db);
781 947
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -784,20 +950,32 @@  discard block
 block discarded – undo
784 950
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
785 951
 			}
786 952
 			if ($globalDBdriver == 'mysql') {
787
-				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";
788
-				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";
953
+				if ($limit) {
954
+					$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";
955
+				} else {
956
+					$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";
957
+				}
789 958
 			} else {
790
-				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";
791
-				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";
959
+				if ($limit) {
960
+					$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";
961
+				} else {
962
+					$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";
963
+				}
792 964
 			}
793 965
 			$query_data = array(':filter_name' => $filter_name);
794 966
 		} else {
795 967
 			if ($globalDBdriver == 'mysql') {
796
-				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";
797
-				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";
968
+				if ($limit) {
969
+					$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";
970
+				} else {
971
+					$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";
972
+				}
798 973
 			} else {
799
-				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";
800
-				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";
974
+				if ($limit) {
975
+					$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";
976
+				} else {
977
+					$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";
978
+				}
801 979
 			}
802 980
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
803 981
 		}
@@ -825,7 +1003,9 @@  discard block
 block discarded – undo
825 1003
 	
826 1004
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
827 1005
 		global $globalStatsFilters;
828
-		if ($filter_name == '') $filter_name = $this->filter_name;
1006
+		if ($filter_name == '') {
1007
+			$filter_name = $this->filter_name;
1008
+		}
829 1009
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
830 1010
 			$Spotter = new Spotter($this->db);
831 1011
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -862,7 +1042,9 @@  discard block
 block discarded – undo
862 1042
 	}
863 1043
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
864 1044
 		global $globalDBdriver, $globalStatsFilters;
865
-		if ($filter_name == '') $filter_name = $this->filter_name;
1045
+		if ($filter_name == '') {
1046
+			$filter_name = $this->filter_name;
1047
+		}
866 1048
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
867 1049
 			$Spotter = new Spotter($this->db);
868 1050
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -907,7 +1089,9 @@  discard block
 block discarded – undo
907 1089
 	}
908 1090
 	public function countAllDates($stats_airline = '',$filter_name = '') {
909 1091
 		global $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1092
+		if ($filter_name == '') {
1093
+			$filter_name = $this->filter_name;
1094
+		}
911 1095
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
912 1096
 			$Spotter = new Spotter($this->db);
913 1097
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -944,7 +1128,9 @@  discard block
 block discarded – undo
944 1128
 	}
945 1129
 	public function countAllDatesMarine($filter_name = '') {
946 1130
 		global $globalStatsFilters;
947
-		if ($filter_name == '') $filter_name = $this->filter_name;
1131
+		if ($filter_name == '') {
1132
+			$filter_name = $this->filter_name;
1133
+		}
948 1134
 		$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";
949 1135
 		$query_data = array(':filter_name' => $filter_name);
950 1136
 		try {
@@ -966,7 +1152,9 @@  discard block
 block discarded – undo
966 1152
 	}
967 1153
 	public function countAllDatesTracker($filter_name = '') {
968 1154
 		global $globalStatsFilters;
969
-		if ($filter_name == '') $filter_name = $this->filter_name;
1155
+		if ($filter_name == '') {
1156
+			$filter_name = $this->filter_name;
1157
+		}
970 1158
 		$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";
971 1159
 		$query_data = array(':filter_name' => $filter_name);
972 1160
 		try {
@@ -988,7 +1176,9 @@  discard block
 block discarded – undo
988 1176
 	}
989 1177
 	public function countAllDatesByAirlines($filter_name = '') {
990 1178
 		global $globalStatsFilters;
991
-		if ($filter_name == '') $filter_name = $this->filter_name;
1179
+		if ($filter_name == '') {
1180
+			$filter_name = $this->filter_name;
1181
+		}
992 1182
 		$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";
993 1183
 		$query_data = array('filter_name' => $filter_name);
994 1184
 		try {
@@ -1010,7 +1200,9 @@  discard block
 block discarded – undo
1010 1200
 	}
1011 1201
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1012 1202
 		global $globalStatsFilters, $globalDBdriver;
1013
-		if ($filter_name == '') $filter_name = $this->filter_name;
1203
+		if ($filter_name == '') {
1204
+			$filter_name = $this->filter_name;
1205
+		}
1014 1206
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1015 1207
 			$Spotter = new Spotter($this->db);
1016 1208
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1095,7 +1287,9 @@  discard block
 block discarded – undo
1095 1287
 	}
1096 1288
 	public function countAllMilitaryMonths($filter_name = '') {
1097 1289
 		global $globalStatsFilters;
1098
-		if ($filter_name == '') $filter_name = $this->filter_name;
1290
+		if ($filter_name == '') {
1291
+			$filter_name = $this->filter_name;
1292
+		}
1099 1293
 		$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";
1100 1294
 		try {
1101 1295
 			$sth = $this->db->prepare($query);
@@ -1116,7 +1310,9 @@  discard block
 block discarded – undo
1116 1310
 	}
1117 1311
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1118 1312
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1119
-		if ($filter_name == '') $filter_name = $this->filter_name;
1313
+		if ($filter_name == '') {
1314
+			$filter_name = $this->filter_name;
1315
+		}
1120 1316
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1121 1317
 			$Spotter = new Spotter($this->db);
1122 1318
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1124,12 +1320,18 @@  discard block
 block discarded – undo
1124 1320
 			foreach ($airlines as $airline) {
1125 1321
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1126 1322
 			}
1127
-			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";
1128
-			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";
1323
+			if ($limit) {
1324
+				$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";
1325
+			} else {
1326
+				$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";
1327
+			}
1129 1328
 			$query_data = array(':filter_name' => $filter_name);
1130 1329
 		} else {
1131
-			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";
1132
-			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";
1330
+			if ($limit) {
1331
+				$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";
1332
+			} else {
1333
+				$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";
1334
+			}
1133 1335
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1134 1336
 		}
1135 1337
 		if ($orderby == 'hour') {
@@ -1139,7 +1341,9 @@  discard block
 block discarded – undo
1139 1341
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1140 1342
 			}
1141 1343
 		}
1142
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1344
+		if ($orderby == 'count') {
1345
+			$query .= " ORDER BY hour_count DESC";
1346
+		}
1143 1347
 		try {
1144 1348
 			$sth = $this->db->prepare($query);
1145 1349
 			$sth->execute($query_data);
@@ -1163,8 +1367,12 @@  discard block
 block discarded – undo
1163 1367
 	}
1164 1368
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1165 1369
 		global $globalStatsFilters;
1166
-		if ($filter_name == '') $filter_name = $this->filter_name;
1167
-		if ($year == '') $year = date('Y');
1370
+		if ($filter_name == '') {
1371
+			$filter_name = $this->filter_name;
1372
+		}
1373
+		if ($year == '') {
1374
+			$year = date('Y');
1375
+		}
1168 1376
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1169 1377
 		if (empty($all)) {
1170 1378
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1183,8 +1391,12 @@  discard block
 block discarded – undo
1183 1391
 	}
1184 1392
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1185 1393
 		global $globalStatsFilters;
1186
-		if ($filter_name == '') $filter_name = $this->filter_name;
1187
-		if ($year == '') $year = date('Y');
1394
+		if ($filter_name == '') {
1395
+			$filter_name = $this->filter_name;
1396
+		}
1397
+		if ($year == '') {
1398
+			$year = date('Y');
1399
+		}
1188 1400
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1189 1401
 		if (empty($all)) {
1190 1402
 			$filters = array();
@@ -1200,8 +1412,12 @@  discard block
 block discarded – undo
1200 1412
 	}
1201 1413
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1202 1414
 		global $globalStatsFilters;
1203
-		if ($filter_name == '') $filter_name = $this->filter_name;
1204
-		if ($year == '') $year = date('Y');
1415
+		if ($filter_name == '') {
1416
+			$filter_name = $this->filter_name;
1417
+		}
1418
+		if ($year == '') {
1419
+			$year = date('Y');
1420
+		}
1205 1421
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1206 1422
 		if (empty($all)) {
1207 1423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1220,7 +1436,9 @@  discard block
 block discarded – undo
1220 1436
 	}
1221 1437
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1222 1438
 		global $globalStatsFilters;
1223
-		if ($filter_name == '') $filter_name = $this->filter_name;
1439
+		if ($filter_name == '') {
1440
+			$filter_name = $this->filter_name;
1441
+		}
1224 1442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1225 1443
 			$Spotter = new Spotter($this->db);
1226 1444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1238,7 +1456,9 @@  discard block
 block discarded – undo
1238 1456
 				}
1239 1457
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1240 1458
 				$all = $result[0]['nb'];
1241
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1459
+			} else {
1460
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1461
+			}
1242 1462
 		} else {
1243 1463
 			if ($year == '' && $month == '') {
1244 1464
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1250,7 +1470,9 @@  discard block
 block discarded – undo
1250 1470
 				}
1251 1471
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1252 1472
 				$all = $result[0]['nb'];
1253
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1473
+			} else {
1474
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1475
+			}
1254 1476
 		}
1255 1477
 		if (empty($all)) {
1256 1478
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1269,7 +1491,9 @@  discard block
 block discarded – undo
1269 1491
 	}
1270 1492
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1271 1493
 		global $globalStatsFilters;
1272
-		if ($filter_name == '') $filter_name = $this->filter_name;
1494
+		if ($filter_name == '') {
1495
+			$filter_name = $this->filter_name;
1496
+		}
1273 1497
 		if ($year == '' && $month == '') {
1274 1498
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1275 1499
 			try {
@@ -1280,7 +1504,9 @@  discard block
 block discarded – undo
1280 1504
 			}
1281 1505
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1282 1506
 			$all = $result[0]['nb_airline'];
1283
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1507
+		} else {
1508
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1509
+		}
1284 1510
 		if (empty($all)) {
1285 1511
 			$filters = array();
1286 1512
 			$filters = array('year' => $year,'month' => $month);
@@ -1295,7 +1521,9 @@  discard block
 block discarded – undo
1295 1521
 	}
1296 1522
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1297 1523
 		global $globalStatsFilters;
1298
-		if ($filter_name == '') $filter_name = $this->filter_name;
1524
+		if ($filter_name == '') {
1525
+			$filter_name = $this->filter_name;
1526
+		}
1299 1527
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1300 1528
 			$Spotter = new Spotter($this->db);
1301 1529
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1350,7 +1578,9 @@  discard block
 block discarded – undo
1350 1578
 	}
1351 1579
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1352 1580
 		global $globalStatsFilters;
1353
-		if ($filter_name == '') $filter_name = $this->filter_name;
1581
+		if ($filter_name == '') {
1582
+			$filter_name = $this->filter_name;
1583
+		}
1354 1584
 		//if ($year == '') $year = date('Y');
1355 1585
 		if ($year == '' && $month == '') {
1356 1586
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1379,7 +1609,9 @@  discard block
 block discarded – undo
1379 1609
 	}
1380 1610
 
1381 1611
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1382
-		if ($filter_name == '') $filter_name = $this->filter_name;
1612
+		if ($filter_name == '') {
1613
+			$filter_name = $this->filter_name;
1614
+		}
1383 1615
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1384 1616
 			$Spotter = new Spotter($this->db);
1385 1617
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1403,7 +1635,9 @@  discard block
 block discarded – undo
1403 1635
 		return $all;
1404 1636
 	}
1405 1637
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1406
-		if ($filter_name == '') $filter_name = $this->filter_name;
1638
+		if ($filter_name == '') {
1639
+			$filter_name = $this->filter_name;
1640
+		}
1407 1641
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1408 1642
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1409 1643
 		try {
@@ -1416,7 +1650,9 @@  discard block
 block discarded – undo
1416 1650
 		return $all;
1417 1651
 	}
1418 1652
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1419
-		if ($filter_name == '') $filter_name = $this->filter_name;
1653
+		if ($filter_name == '') {
1654
+			$filter_name = $this->filter_name;
1655
+		}
1420 1656
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1421 1657
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1422 1658
 		try {
@@ -1427,7 +1663,9 @@  discard block
 block discarded – undo
1427 1663
 		}
1428 1664
 	}
1429 1665
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1430
-		if ($filter_name == '') $filter_name = $this->filter_name;
1666
+		if ($filter_name == '') {
1667
+			$filter_name = $this->filter_name;
1668
+		}
1431 1669
 		global $globalArchiveMonths, $globalDBdriver;
1432 1670
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1433 1671
 			$Spotter = new Spotter($this->db);
@@ -1483,7 +1721,9 @@  discard block
 block discarded – undo
1483 1721
 	}
1484 1722
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1485 1723
 		global $globalArchiveMonths, $globalDBdriver;
1486
-		if ($filter_name == '') $filter_name = $this->filter_name;
1724
+		if ($filter_name == '') {
1725
+			$filter_name = $this->filter_name;
1726
+		}
1487 1727
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1488 1728
 			$Spotter = new Spotter($this->db);
1489 1729
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1516,7 +1756,9 @@  discard block
 block discarded – undo
1516 1756
 	}
1517 1757
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1518 1758
 		global $globalArchiveMonths, $globalDBdriver;
1519
-		if ($filter_name == '') $filter_name = $this->filter_name;
1759
+		if ($filter_name == '') {
1760
+			$filter_name = $this->filter_name;
1761
+		}
1520 1762
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1521 1763
 			$Spotter = new Spotter($this->db);
1522 1764
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1547,7 +1789,9 @@  discard block
 block discarded – undo
1547 1789
 	}
1548 1790
 	public function getStatsAirlineTotal($filter_name = '') {
1549 1791
 		global $globalArchiveMonths, $globalDBdriver;
1550
-		if ($filter_name == '') $filter_name = $this->filter_name;
1792
+		if ($filter_name == '') {
1793
+			$filter_name = $this->filter_name;
1794
+		}
1551 1795
 		if ($globalDBdriver == 'mysql') {
1552 1796
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1553 1797
 		} else {
@@ -1564,7 +1808,9 @@  discard block
 block discarded – undo
1564 1808
 	}
1565 1809
 	public function getStatsOwnerTotal($filter_name = '') {
1566 1810
 		global $globalArchiveMonths, $globalDBdriver;
1567
-		if ($filter_name == '') $filter_name = $this->filter_name;
1811
+		if ($filter_name == '') {
1812
+			$filter_name = $this->filter_name;
1813
+		}
1568 1814
 		if ($globalDBdriver == 'mysql') {
1569 1815
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1570 1816
 		} else {
@@ -1581,7 +1827,9 @@  discard block
 block discarded – undo
1581 1827
 	}
1582 1828
 	public function getStatsOwner($owner_name,$filter_name = '') {
1583 1829
 		global $globalArchiveMonths, $globalDBdriver;
1584
-		if ($filter_name == '') $filter_name = $this->filter_name;
1830
+		if ($filter_name == '') {
1831
+			$filter_name = $this->filter_name;
1832
+		}
1585 1833
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1586 1834
 		try {
1587 1835
 			$sth = $this->db->prepare($query);
@@ -1590,12 +1838,17 @@  discard block
 block discarded – undo
1590 1838
 			echo "error : ".$e->getMessage();
1591 1839
 		}
1592 1840
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1593
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1594
-		else return 0;
1841
+		if (isset($all[0]['cnt'])) {
1842
+			return $all[0]['cnt'];
1843
+		} else {
1844
+			return 0;
1845
+		}
1595 1846
 	}
1596 1847
 	public function getStatsPilotTotal($filter_name = '') {
1597 1848
 		global $globalArchiveMonths, $globalDBdriver;
1598
-		if ($filter_name == '') $filter_name = $this->filter_name;
1849
+		if ($filter_name == '') {
1850
+			$filter_name = $this->filter_name;
1851
+		}
1599 1852
 		if ($globalDBdriver == 'mysql') {
1600 1853
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1601 1854
 		} else {
@@ -1612,7 +1865,9 @@  discard block
 block discarded – undo
1612 1865
 	}
1613 1866
 	public function getStatsPilot($pilot,$filter_name = '') {
1614 1867
 		global $globalArchiveMonths, $globalDBdriver;
1615
-		if ($filter_name == '') $filter_name = $this->filter_name;
1868
+		if ($filter_name == '') {
1869
+			$filter_name = $this->filter_name;
1870
+		}
1616 1871
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1617 1872
 		try {
1618 1873
 			$sth = $this->db->prepare($query);
@@ -1621,13 +1876,18 @@  discard block
 block discarded – undo
1621 1876
 			echo "error : ".$e->getMessage();
1622 1877
 		}
1623 1878
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1624
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1625
-		else return 0;
1879
+		if (isset($all[0]['cnt'])) {
1880
+			return $all[0]['cnt'];
1881
+		} else {
1882
+			return 0;
1883
+		}
1626 1884
 	}
1627 1885
 
1628 1886
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1629 1887
 		global $globalDBdriver;
1630
-		if ($filter_name == '') $filter_name = $this->filter_name;
1888
+		if ($filter_name == '') {
1889
+			$filter_name = $this->filter_name;
1890
+		}
1631 1891
 		if ($globalDBdriver == 'mysql') {
1632 1892
 			$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";
1633 1893
 		} else {
@@ -1643,7 +1903,9 @@  discard block
 block discarded – undo
1643 1903
 	}
1644 1904
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1645 1905
 		global $globalDBdriver;
1646
-		if ($filter_name == '') $filter_name = $this->filter_name;
1906
+		if ($filter_name == '') {
1907
+			$filter_name = $this->filter_name;
1908
+		}
1647 1909
 		if ($globalDBdriver == 'mysql') {
1648 1910
 			$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";
1649 1911
 		} else {
@@ -2116,27 +2378,37 @@  discard block
 block discarded – undo
2116 2378
 		date_default_timezone_set('UTC');
2117 2379
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2118 2380
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2119
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2381
+			if ($globalDebug) {
2382
+				echo '!!! Update Marine stats !!!'."\n";
2383
+			}
2120 2384
 			if (isset($last_update[0]['value'])) {
2121 2385
 				$last_update_day = $last_update[0]['value'];
2122
-			} else $last_update_day = '2012-12-12 12:12:12';
2386
+			} else {
2387
+				$last_update_day = '2012-12-12 12:12:12';
2388
+			}
2123 2389
 			$reset = false;
2124 2390
 			$Marine = new Marine($this->db);
2125 2391
 			$filtername = 'marine';
2126 2392
 			if ($Connection->tableExists('countries')) {
2127
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2393
+				if ($globalDebug) {
2394
+					echo 'Count all vessels by countries...'."\n";
2395
+				}
2128 2396
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2129 2397
 				foreach ($alldata as $number) {
2130 2398
 					$this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2131 2399
 				}
2132 2400
 			}
2133
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2401
+			if ($globalDebug) {
2402
+				echo 'Count all vessels by months...'."\n";
2403
+			}
2134 2404
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2135 2405
 			$filter_last_month = array('since_date' => $last_month);
2136 2406
 			$alldata = $Marine->countAllMonths($filter_last_month);
2137 2407
 			$lastyear = false;
2138 2408
 			foreach ($alldata as $number) {
2139
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2409
+				if ($number['year_name'] != date('Y')) {
2410
+					$lastyear = true;
2411
+				}
2140 2412
 				$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'])));
2141 2413
 			}
2142 2414
 			echo 'Marine data...'."\n";
@@ -2172,26 +2444,36 @@  discard block
 block discarded – undo
2172 2444
 		}
2173 2445
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2174 2446
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2175
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2447
+			if ($globalDebug) {
2448
+				echo '!!! Update tracker stats !!!'."\n";
2449
+			}
2176 2450
 			if (isset($last_update[0]['value'])) {
2177 2451
 				$last_update_day = $last_update[0]['value'];
2178
-			} else $last_update_day = '2012-12-12 12:12:12';
2452
+			} else {
2453
+				$last_update_day = '2012-12-12 12:12:12';
2454
+			}
2179 2455
 			$reset = false;
2180 2456
 			$Tracker = new Tracker($this->db);
2181 2457
 			if ($Connection->tableExists('countries')) {
2182
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2458
+				if ($globalDebug) {
2459
+					echo 'Count all trackers by countries...'."\n";
2460
+				}
2183 2461
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2184 2462
 				foreach ($alldata as $number) {
2185 2463
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2186 2464
 				}
2187 2465
 			}
2188
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2466
+			if ($globalDebug) {
2467
+				echo 'Count all vessels by months...'."\n";
2468
+			}
2189 2469
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2190 2470
 			$filter_last_month = array('since_date' => $last_month);
2191 2471
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2192 2472
 			$lastyear = false;
2193 2473
 			foreach ($alldata as $number) {
2194
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2474
+				if ($number['year_name'] != date('Y')) {
2475
+					$lastyear = true;
2476
+				}
2195 2477
 				$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'])));
2196 2478
 			}
2197 2479
 			echo 'Tracker data...'."\n";
@@ -2228,10 +2510,14 @@  discard block
 block discarded – undo
2228 2510
 
2229 2511
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2230 2512
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2231
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2513
+			if ($globalDebug) {
2514
+				echo '!!! Update aicraft stats !!!'."\n";
2515
+			}
2232 2516
 			if (isset($last_update[0]['value'])) {
2233 2517
 				$last_update_day = $last_update[0]['value'];
2234
-			} else $last_update_day = '2012-12-12 12:12:12';
2518
+			} else {
2519
+				$last_update_day = '2012-12-12 12:12:12';
2520
+			}
2235 2521
 			$reset = false;
2236 2522
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2237 2523
 			if ($globalStatsResetYear) {
@@ -2240,43 +2526,63 @@  discard block
 block discarded – undo
2240 2526
 			}
2241 2527
 			$Spotter = new Spotter($this->db);
2242 2528
 
2243
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2529
+			if ($globalDebug) {
2530
+				echo 'Count all aircraft types...'."\n";
2531
+			}
2244 2532
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2245 2533
 			foreach ($alldata as $number) {
2246 2534
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2247 2535
 			}
2248
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2536
+			if ($globalDebug) {
2537
+				echo 'Count all airlines...'."\n";
2538
+			}
2249 2539
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2250 2540
 			foreach ($alldata as $number) {
2251 2541
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2252 2542
 			}
2253
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2543
+			if ($globalDebug) {
2544
+				echo 'Count all registrations...'."\n";
2545
+			}
2254 2546
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2255 2547
 			foreach ($alldata as $number) {
2256 2548
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2257 2549
 			}
2258
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2550
+			if ($globalDebug) {
2551
+				echo 'Count all callsigns...'."\n";
2552
+			}
2259 2553
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2260 2554
 			foreach ($alldata as $number) {
2261 2555
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2262 2556
 			}
2263
-			if ($globalDebug) echo 'Count all owners...'."\n";
2557
+			if ($globalDebug) {
2558
+				echo 'Count all owners...'."\n";
2559
+			}
2264 2560
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2265 2561
 			foreach ($alldata as $number) {
2266 2562
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2267 2563
 			}
2268
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2564
+			if ($globalDebug) {
2565
+				echo 'Count all pilots...'."\n";
2566
+			}
2269 2567
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2270 2568
 			foreach ($alldata as $number) {
2271
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2569
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2570
+					$number['pilot_id'] = $number['pilot_name'];
2571
+				}
2272 2572
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2273 2573
 			}
2274 2574
 			
2275
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2575
+			if ($globalDebug) {
2576
+				echo 'Count all departure airports...'."\n";
2577
+			}
2276 2578
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2277
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2579
+			if ($globalDebug) {
2580
+				echo 'Count all detected departure airports...'."\n";
2581
+			}
2278 2582
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2279
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2583
+			if ($globalDebug) {
2584
+				echo 'Order departure airports...'."\n";
2585
+			}
2280 2586
 			$alldata = array();
2281 2587
 			foreach ($pall as $value) {
2282 2588
 				$icao = $value['airport_departure_icao'];
@@ -2286,7 +2592,9 @@  discard block
 block discarded – undo
2286 2592
 				$icao = $value['airport_departure_icao'];
2287 2593
 				if (isset($alldata[$icao])) {
2288 2594
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2289
-				} else $alldata[$icao] = $value;
2595
+				} else {
2596
+					$alldata[$icao] = $value;
2597
+				}
2290 2598
 			}
2291 2599
 			$count = array();
2292 2600
 			foreach ($alldata as $key => $row) {
@@ -2296,11 +2604,17 @@  discard block
 block discarded – undo
2296 2604
 			foreach ($alldata as $number) {
2297 2605
 				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);
2298 2606
 			}
2299
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2607
+			if ($globalDebug) {
2608
+				echo 'Count all arrival airports...'."\n";
2609
+			}
2300 2610
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2301
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2611
+			if ($globalDebug) {
2612
+				echo 'Count all detected arrival airports...'."\n";
2613
+			}
2302 2614
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2303
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2615
+			if ($globalDebug) {
2616
+				echo 'Order arrival airports...'."\n";
2617
+			}
2304 2618
 			$alldata = array();
2305 2619
 			foreach ($pall as $value) {
2306 2620
 				$icao = $value['airport_arrival_icao'];
@@ -2310,7 +2624,9 @@  discard block
 block discarded – undo
2310 2624
 				$icao = $value['airport_arrival_icao'];
2311 2625
 				if (isset($alldata[$icao])) {
2312 2626
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2313
-				} else $alldata[$icao] = $value;
2627
+				} else {
2628
+					$alldata[$icao] = $value;
2629
+				}
2314 2630
 			}
2315 2631
 			$count = array();
2316 2632
 			foreach ($alldata as $key => $row) {
@@ -2321,7 +2637,9 @@  discard block
 block discarded – undo
2321 2637
 				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);
2322 2638
 			}
2323 2639
 			if ($Connection->tableExists('countries')) {
2324
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2640
+				if ($globalDebug) {
2641
+					echo 'Count all flights by countries...'."\n";
2642
+				}
2325 2643
 				//$SpotterArchive = new SpotterArchive();
2326 2644
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2327 2645
 				$Spotter = new Spotter($this->db);
@@ -2332,7 +2650,9 @@  discard block
 block discarded – undo
2332 2650
 			}
2333 2651
 			
2334 2652
 			if (isset($globalAccidents) && $globalAccidents) {
2335
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2653
+				if ($globalDebug) {
2654
+					echo 'Count fatalities stats...'."\n";
2655
+				}
2336 2656
 				$Accident = new Accident($this->db);
2337 2657
 				$this->deleteStatsByType('fatalities_byyear');
2338 2658
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2348,48 +2668,68 @@  discard block
 block discarded – undo
2348 2668
 
2349 2669
 			// Add by month using getstat if month finish...
2350 2670
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2351
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2671
+			if ($globalDebug) {
2672
+				echo 'Count all flights by months...'."\n";
2673
+			}
2352 2674
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2353 2675
 			$filter_last_month = array('since_date' => $last_month);
2354 2676
 			$Spotter = new Spotter($this->db);
2355 2677
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2356 2678
 			$lastyear = false;
2357 2679
 			foreach ($alldata as $number) {
2358
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2680
+				if ($number['year_name'] != date('Y')) {
2681
+					$lastyear = true;
2682
+				}
2359 2683
 				$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'])));
2360 2684
 			}
2361
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2685
+			if ($globalDebug) {
2686
+				echo 'Count all military flights by months...'."\n";
2687
+			}
2362 2688
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2363 2689
 			foreach ($alldata as $number) {
2364 2690
 				$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'])));
2365 2691
 			}
2366
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2692
+			if ($globalDebug) {
2693
+				echo 'Count all owners by months...'."\n";
2694
+			}
2367 2695
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2368 2696
 			foreach ($alldata as $number) {
2369 2697
 				$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'])));
2370 2698
 			}
2371
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2699
+			if ($globalDebug) {
2700
+				echo 'Count all pilots by months...'."\n";
2701
+			}
2372 2702
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2373 2703
 			foreach ($alldata as $number) {
2374 2704
 				$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'])));
2375 2705
 			}
2376
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2706
+			if ($globalDebug) {
2707
+				echo 'Count all airlines by months...'."\n";
2708
+			}
2377 2709
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2378 2710
 			foreach ($alldata as $number) {
2379 2711
 				$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'])));
2380 2712
 			}
2381
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2713
+			if ($globalDebug) {
2714
+				echo 'Count all aircrafts by months...'."\n";
2715
+			}
2382 2716
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2383 2717
 			foreach ($alldata as $number) {
2384 2718
 				$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'])));
2385 2719
 			}
2386
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2720
+			if ($globalDebug) {
2721
+				echo 'Count all real arrivals by months...'."\n";
2722
+			}
2387 2723
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2388 2724
 			foreach ($alldata as $number) {
2389 2725
 				$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'])));
2390 2726
 			}
2391
-			if ($globalDebug) echo 'Airports data...'."\n";
2392
-			if ($globalDebug) echo '...Departure'."\n";
2727
+			if ($globalDebug) {
2728
+				echo 'Airports data...'."\n";
2729
+			}
2730
+			if ($globalDebug) {
2731
+				echo '...Departure'."\n";
2732
+			}
2393 2733
 			$this->deleteStatAirport('daily');
2394 2734
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2395 2735
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2507,7 +2847,9 @@  discard block
 block discarded – undo
2507 2847
 			// Count by airlines
2508 2848
 			echo '--- Stats by airlines ---'."\n";
2509 2849
 			if ($Connection->tableExists('countries')) {
2510
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2850
+				if ($globalDebug) {
2851
+					echo 'Count all flights by countries by airlines...'."\n";
2852
+				}
2511 2853
 				$SpotterArchive = new SpotterArchive($this->db);
2512 2854
 				//$Spotter = new Spotter($this->db);
2513 2855
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2516,37 +2858,53 @@  discard block
 block discarded – undo
2516 2858
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2517 2859
 				}
2518 2860
 			}
2519
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2861
+			if ($globalDebug) {
2862
+				echo 'Count all aircraft types by airlines...'."\n";
2863
+			}
2520 2864
 			$Spotter = new Spotter($this->db);
2521 2865
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2522 2866
 			foreach ($alldata as $number) {
2523 2867
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2524 2868
 			}
2525
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2869
+			if ($globalDebug) {
2870
+				echo 'Count all aircraft registrations by airlines...'."\n";
2871
+			}
2526 2872
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2527 2873
 			foreach ($alldata as $number) {
2528 2874
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2529 2875
 			}
2530
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2876
+			if ($globalDebug) {
2877
+				echo 'Count all callsigns by airlines...'."\n";
2878
+			}
2531 2879
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2532 2880
 			foreach ($alldata as $number) {
2533 2881
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2534 2882
 			}
2535
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2883
+			if ($globalDebug) {
2884
+				echo 'Count all owners by airlines...'."\n";
2885
+			}
2536 2886
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2537 2887
 			foreach ($alldata as $number) {
2538 2888
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2539 2889
 			}
2540
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2890
+			if ($globalDebug) {
2891
+				echo 'Count all pilots by airlines...'."\n";
2892
+			}
2541 2893
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2542 2894
 			foreach ($alldata as $number) {
2543 2895
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2544 2896
 			}
2545
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2897
+			if ($globalDebug) {
2898
+				echo 'Count all departure airports by airlines...'."\n";
2899
+			}
2546 2900
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2547
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2901
+			if ($globalDebug) {
2902
+				echo 'Count all detected departure airports by airlines...'."\n";
2903
+			}
2548 2904
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2549
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2905
+			if ($globalDebug) {
2906
+				echo 'Order detected departure airports by airlines...'."\n";
2907
+			}
2550 2908
 			//$alldata = array();
2551 2909
 			foreach ($dall as $value) {
2552 2910
 				$icao = $value['airport_departure_icao'];
@@ -2567,11 +2925,17 @@  discard block
 block discarded – undo
2567 2925
 			foreach ($alldata as $number) {
2568 2926
 				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);
2569 2927
 			}
2570
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2928
+			if ($globalDebug) {
2929
+				echo 'Count all arrival airports by airlines...'."\n";
2930
+			}
2571 2931
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2572
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2932
+			if ($globalDebug) {
2933
+				echo 'Count all detected arrival airports by airlines...'."\n";
2934
+			}
2573 2935
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2574
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2936
+			if ($globalDebug) {
2937
+				echo 'Order arrival airports by airlines...'."\n";
2938
+			}
2575 2939
 			//$alldata = array();
2576 2940
 			foreach ($dall as $value) {
2577 2941
 				$icao = $value['airport_arrival_icao'];
@@ -2590,37 +2954,53 @@  discard block
 block discarded – undo
2590 2954
 			}
2591 2955
 			$alldata = $pall;
2592 2956
 			foreach ($alldata as $number) {
2593
-				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);
2957
+				if ($number['airline_icao'] != '') {
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'],$number['airline_icao'],'',$reset);
2959
+				}
2960
+			}
2961
+			if ($globalDebug) {
2962
+				echo 'Count all flights by months by airlines...'."\n";
2594 2963
 			}
2595
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2596 2964
 			$Spotter = new Spotter($this->db);
2597 2965
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2598 2966
 			$lastyear = false;
2599 2967
 			foreach ($alldata as $number) {
2600
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2968
+				if ($number['year_name'] != date('Y')) {
2969
+					$lastyear = true;
2970
+				}
2601 2971
 				$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']);
2602 2972
 			}
2603
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2973
+			if ($globalDebug) {
2974
+				echo 'Count all owners by months by airlines...'."\n";
2975
+			}
2604 2976
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2605 2977
 			foreach ($alldata as $number) {
2606 2978
 				$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']);
2607 2979
 			}
2608
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2980
+			if ($globalDebug) {
2981
+				echo 'Count all pilots by months by airlines...'."\n";
2982
+			}
2609 2983
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2610 2984
 			foreach ($alldata as $number) {
2611 2985
 				$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']);
2612 2986
 			}
2613
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2987
+			if ($globalDebug) {
2988
+				echo 'Count all aircrafts by months by airlines...'."\n";
2989
+			}
2614 2990
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2615 2991
 			foreach ($alldata as $number) {
2616 2992
 				$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']);
2617 2993
 			}
2618
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2994
+			if ($globalDebug) {
2995
+				echo 'Count all real arrivals by months by airlines...'."\n";
2996
+			}
2619 2997
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2620 2998
 			foreach ($alldata as $number) {
2621 2999
 				$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']);
2622 3000
 			}
2623
-			if ($globalDebug) echo '...Departure'."\n";
3001
+			if ($globalDebug) {
3002
+				echo '...Departure'."\n";
3003
+			}
2624 3004
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2625 3005
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2626 3006
 			foreach ($dall as $value) {
@@ -2643,7 +3023,9 @@  discard block
 block discarded – undo
2643 3023
 			foreach ($alldata as $number) {
2644 3024
 				$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']);
2645 3025
 			}
2646
-			if ($globalDebug) echo '...Arrival'."\n";
3026
+			if ($globalDebug) {
3027
+				echo '...Arrival'."\n";
3028
+			}
2647 3029
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2648 3030
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2649 3031
 			foreach ($dall as $value) {
@@ -2667,13 +3049,19 @@  discard block
 block discarded – undo
2667 3049
 				$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']);
2668 3050
 			}
2669 3051
 
2670
-			if ($globalDebug) echo 'Flights data...'."\n";
2671
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3052
+			if ($globalDebug) {
3053
+				echo 'Flights data...'."\n";
3054
+			}
3055
+			if ($globalDebug) {
3056
+				echo '-> countAllDatesLastMonth...'."\n";
3057
+			}
2672 3058
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2673 3059
 			foreach ($alldata as $number) {
2674 3060
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2675 3061
 			}
2676
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3062
+			if ($globalDebug) {
3063
+				echo '-> countAllDates...'."\n";
3064
+			}
2677 3065
 			//$previousdata = $this->countAllDatesByAirlines();
2678 3066
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2679 3067
 			$values = array();
@@ -2686,14 +3074,18 @@  discard block
 block discarded – undo
2686 3074
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2687 3075
 			}
2688 3076
 			
2689
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3077
+			if ($globalDebug) {
3078
+				echo '-> countAllHours...'."\n";
3079
+			}
2690 3080
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2691 3081
 			foreach ($alldata as $number) {
2692 3082
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2693 3083
 			}
2694 3084
 
2695 3085
 			// Stats by filters
2696
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3086
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3087
+				$globalStatsFilters = array();
3088
+			}
2697 3089
 			foreach ($globalStatsFilters as $name => $filter) {
2698 3090
 				if (!empty($filter)) {
2699 3091
 					//$filter_name = $filter['name'];
@@ -2701,7 +3093,9 @@  discard block
 block discarded – undo
2701 3093
 					$reset = false;
2702 3094
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2703 3095
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2704
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3096
+						if ($globalDebug) {
3097
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3098
+						}
2705 3099
 						$this->deleteOldStats($filter_name);
2706 3100
 						unset($last_update);
2707 3101
 					}
@@ -2718,39 +3112,55 @@  discard block
 block discarded – undo
2718 3112
 						$reset = true;
2719 3113
 					}
2720 3114
 					// Count by filter
2721
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3115
+					if ($globalDebug) {
3116
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3117
+					}
2722 3118
 					$Spotter = new Spotter($this->db);
2723
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3119
+					if ($globalDebug) {
3120
+						echo 'Count all aircraft types...'."\n";
3121
+					}
2724 3122
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2725 3123
 					foreach ($alldata as $number) {
2726 3124
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2727 3125
 					}
2728
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3126
+					if ($globalDebug) {
3127
+						echo 'Count all airlines...'."\n";
3128
+					}
2729 3129
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2730 3130
 					foreach ($alldata as $number) {
2731 3131
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2732 3132
 					}
2733
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3133
+					if ($globalDebug) {
3134
+						echo 'Count all aircraft registrations...'."\n";
3135
+					}
2734 3136
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2735 3137
 					foreach ($alldata as $number) {
2736 3138
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2737 3139
 					}
2738
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3140
+					if ($globalDebug) {
3141
+						echo 'Count all callsigns...'."\n";
3142
+					}
2739 3143
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2740 3144
 					foreach ($alldata as $number) {
2741 3145
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2742 3146
 					}
2743
-					if ($globalDebug) echo 'Count all owners...'."\n";
3147
+					if ($globalDebug) {
3148
+						echo 'Count all owners...'."\n";
3149
+					}
2744 3150
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2745 3151
 					foreach ($alldata as $number) {
2746 3152
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2747 3153
 					}
2748
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3154
+					if ($globalDebug) {
3155
+						echo 'Count all pilots...'."\n";
3156
+					}
2749 3157
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2750 3158
 					foreach ($alldata as $number) {
2751 3159
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2752 3160
 					}
2753
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3161
+					if ($globalDebug) {
3162
+						echo 'Count departure airports...'."\n";
3163
+					}
2754 3164
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2755 3165
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2756 3166
 					$alldata = array();
@@ -2762,7 +3172,9 @@  discard block
 block discarded – undo
2762 3172
 						$icao = $value['airport_departure_icao'];
2763 3173
 						if (isset($alldata[$icao])) {
2764 3174
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2765
-						} else $alldata[$icao] = $value;
3175
+						} else {
3176
+							$alldata[$icao] = $value;
3177
+						}
2766 3178
 					}
2767 3179
 					$count = array();
2768 3180
 					foreach ($alldata as $key => $row) {
@@ -2772,7 +3184,9 @@  discard block
 block discarded – undo
2772 3184
 					foreach ($alldata as $number) {
2773 3185
 						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);
2774 3186
 					}
2775
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3187
+					if ($globalDebug) {
3188
+						echo 'Count all arrival airports...'."\n";
3189
+					}
2776 3190
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2777 3191
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2778 3192
 					$alldata = array();
@@ -2784,7 +3198,9 @@  discard block
 block discarded – undo
2784 3198
 						$icao = $value['airport_arrival_icao'];
2785 3199
 						if (isset($alldata[$icao])) {
2786 3200
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2787
-						} else $alldata[$icao] = $value;
3201
+						} else {
3202
+							$alldata[$icao] = $value;
3203
+						}
2788 3204
 					}
2789 3205
 					$count = array();
2790 3206
 					foreach ($alldata as $key => $row) {
@@ -2794,35 +3210,49 @@  discard block
 block discarded – undo
2794 3210
 					foreach ($alldata as $number) {
2795 3211
 						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);
2796 3212
 					}
2797
-					if ($globalDebug) echo 'Count all months...'."\n";
3213
+					if ($globalDebug) {
3214
+						echo 'Count all months...'."\n";
3215
+					}
2798 3216
 					$Spotter = new Spotter($this->db);
2799 3217
 					$alldata = $Spotter->countAllMonths($filter);
2800 3218
 					$lastyear = false;
2801 3219
 					foreach ($alldata as $number) {
2802
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3220
+						if ($number['year_name'] != date('Y')) {
3221
+							$lastyear = true;
3222
+						}
2803 3223
 						$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);
2804 3224
 					}
2805
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3225
+					if ($globalDebug) {
3226
+						echo 'Count all owners by months...'."\n";
3227
+					}
2806 3228
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2807 3229
 					foreach ($alldata as $number) {
2808 3230
 						$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);
2809 3231
 					}
2810
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3232
+					if ($globalDebug) {
3233
+						echo 'Count all pilots by months...'."\n";
3234
+					}
2811 3235
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2812 3236
 					foreach ($alldata as $number) {
2813 3237
 						$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);
2814 3238
 					}
2815
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3239
+					if ($globalDebug) {
3240
+						echo 'Count all military by months...'."\n";
3241
+					}
2816 3242
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2817 3243
 					foreach ($alldata as $number) {
2818 3244
 						$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);
2819 3245
 					}
2820
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3246
+					if ($globalDebug) {
3247
+						echo 'Count all aircrafts by months...'."\n";
3248
+					}
2821 3249
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2822 3250
 				    	foreach ($alldata as $number) {
2823 3251
 			    			$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);
2824 3252
 					}
2825
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3253
+					if ($globalDebug) {
3254
+						echo 'Count all real arrivals by months...'."\n";
3255
+					}
2826 3256
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2827 3257
 					foreach ($alldata as $number) {
2828 3258
 						$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.