Completed
Push — master ( 708bc7...3d67e6 )
by Yannick
30:22
created
require/class.Stats.php 1 patch
Braces   +778 added lines, -273 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$filters = array('year' => $year,'month' => $month);
237 272
 			if ($filter_name != '') {
@@ -245,10 +280,15 @@  discard block
 block discarded – undo
245 280
 	}
246 281
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
247 282
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
249 286
 		if ($year == '' && $month == '') {
250
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
251
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
287
+			if ($limit) {
288
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
289
+			} else {
290
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
291
+			}
252 292
 			try {
253 293
 				$sth = $this->db->prepare($query);
254 294
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -256,7 +296,9 @@  discard block
 block discarded – undo
256 296
 				echo "error : ".$e->getMessage();
257 297
 			}
258 298
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
259
-		} else $all = array();
299
+		} else {
300
+			$all = array();
301
+		}
260 302
 		if (empty($all)) {
261 303
 			$Spotter = new Spotter($this->db);
262 304
 			$filters = array();
@@ -271,7 +313,9 @@  discard block
 block discarded – undo
271 313
 	}
272 314
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
273 315
 		global $globalStatsFilters;
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
316
+		if ($filter_name == '') {
317
+			$filter_name = $this->filter_name;
318
+		}
275 319
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
276 320
 			$Spotter = new Spotter($this->db);
277 321
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -280,8 +324,11 @@  discard block
 block discarded – undo
280 324
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
281 325
 			}
282 326
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
327
+				if ($limit) {
328
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
329
+				} else {
330
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
331
+				}
285 332
 				try {
286 333
 					$sth = $this->db->prepare($query);
287 334
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -289,11 +336,16 @@  discard block
 block discarded – undo
289 336
 					echo "error : ".$e->getMessage();
290 337
 				}
291 338
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
292
-			} else $all = array();
339
+			} else {
340
+				$all = array();
341
+			}
293 342
 		} else {
294 343
 			if ($year == '' && $month == '') {
295
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
296
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
344
+				if ($limit) {
345
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
346
+				} else {
347
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
348
+				}
297 349
 				try {
298 350
 					$sth = $this->db->prepare($query);
299 351
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -301,7 +353,9 @@  discard block
 block discarded – undo
301 353
 					echo "error : ".$e->getMessage();
302 354
 				}
303 355
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-			} else $all = array();
356
+			} else {
357
+				$all = array();
358
+			}
305 359
 		}
306 360
 		if (empty($all)) {
307 361
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -321,7 +375,9 @@  discard block
 block discarded – undo
321 375
 
322 376
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
323 377
 		global $globalStatsFilters;
324
-		if ($filter_name == '') $filter_name = $this->filter_name;
378
+		if ($filter_name == '') {
379
+			$filter_name = $this->filter_name;
380
+		}
325 381
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
326 382
 			$Spotter = new Spotter($this->db);
327 383
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -330,8 +386,11 @@  discard block
 block discarded – undo
330 386
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
331 387
 			}
332 388
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
389
+				if ($limit) {
390
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
391
+				} else {
392
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
393
+				}
335 394
 				try {
336 395
 					$sth = $this->db->prepare($query);
337 396
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -339,11 +398,16 @@  discard block
 block discarded – undo
339 398
 					echo "error : ".$e->getMessage();
340 399
 				}
341 400
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-			} else $all = array();
401
+			} else {
402
+				$all = array();
403
+			}
343 404
 		} else {
344 405
 			if ($year == '' && $month == '') {
345
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
346
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
406
+				if ($limit) {
407
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
408
+				} else {
409
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
410
+				}
347 411
 				try {
348 412
 					$sth = $this->db->prepare($query);
349 413
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -351,7 +415,9 @@  discard block
 block discarded – undo
351 415
 					echo "error : ".$e->getMessage();
352 416
 				}
353 417
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-			} else $all = array();
418
+			} else {
419
+				$all = array();
420
+			}
355 421
 		}
356 422
 		if (empty($all)) {
357 423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -370,7 +436,9 @@  discard block
 block discarded – undo
370 436
 	}
371 437
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 438
 		global $globalStatsFilters;
373
-		if ($filter_name == '') $filter_name = $this->filter_name;
439
+		if ($filter_name == '') {
440
+			$filter_name = $this->filter_name;
441
+		}
374 442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
375 443
 			$Spotter = new Spotter($this->db);
376 444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -378,12 +446,18 @@  discard block
 block discarded – undo
378 446
 			foreach ($airlines as $airline) {
379 447
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
380 448
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
449
+			if ($limit) {
450
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
451
+			} else {
452
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
453
+			}
383 454
 			$query_values = array(':filter_name' => $filter_name);
384 455
 		} else {
385
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
387 461
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
388 462
 		}
389 463
 		try {
@@ -411,17 +485,29 @@  discard block
 block discarded – undo
411 485
 
412 486
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
413 487
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
415 491
 		if ($year == '' && $month == '') {
416
-			if ($globalVATSIM) $forsource = 'vatsim';
417
-			if ($globalIVAO) $forsource = 'ivao';
492
+			if ($globalVATSIM) {
493
+				$forsource = 'vatsim';
494
+			}
495
+			if ($globalIVAO) {
496
+				$forsource = 'ivao';
497
+			}
418 498
 			if (isset($forsource)) {
419
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
499
+				if ($limit) {
500
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
501
+				} else {
502
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
503
+				}
421 504
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
422 505
 			} else {
423
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
510
+				}
425 511
 				$query_values = array(':filter_name' => $filter_name);
426 512
 			}
427 513
 			try {
@@ -431,7 +517,9 @@  discard block
 block discarded – undo
431 517
 				echo "error : ".$e->getMessage();
432 518
 			}
433 519
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
520
+		} else {
521
+			$all = array();
522
+		}
435 523
                 if (empty($all)) {
436 524
 	                $Spotter = new Spotter($this->db);
437 525
             		$filters = array();
@@ -446,7 +534,9 @@  discard block
 block discarded – undo
446 534
 	}
447 535
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 536
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
537
+		if ($filter_name == '') {
538
+			$filter_name = $this->filter_name;
539
+		}
450 540
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
451 541
 			$Spotter = new Spotter($this->db);
452 542
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -455,8 +545,11 @@  discard block
 block discarded – undo
455 545
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
456 546
 			}
457 547
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
548
+				if ($limit) {
549
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
550
+				} else {
551
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
552
+				}
460 553
 				try {
461 554
 					$sth = $this->db->prepare($query);
462 555
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -464,11 +557,16 @@  discard block
 block discarded – undo
464 557
 					echo "error : ".$e->getMessage();
465 558
 				}
466 559
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-			} else $all = array();
560
+			} else {
561
+				$all = array();
562
+			}
468 563
 		} else {
469 564
 			if ($year == '' && $month == '') {
470
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
471
-				else $query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
565
+				if ($limit) {
566
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
567
+				} else {
568
+					$query = "SELECT s.aircraft_icao, s.cnt AS registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
569
+				}
472 570
 				try {
473 571
 					$sth = $this->db->prepare($query);
474 572
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -476,7 +574,9 @@  discard block
 block discarded – undo
476 574
 					echo "error : ".$e->getMessage();
477 575
 				}
478 576
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479
-			} else $all = array();
577
+			} else {
578
+				$all = array();
579
+			}
480 580
 		}
481 581
 		if (empty($all)) {
482 582
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -495,7 +595,9 @@  discard block
 block discarded – undo
495 595
 	}
496 596
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
497 597
 		global $globalStatsFilters;
498
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
499 601
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
500 602
 			$Spotter = new Spotter($this->db);
501 603
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -504,8 +606,11 @@  discard block
 block discarded – undo
504 606
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
505 607
 			}
506 608
 			if ($year == '' && $month == '') {
507
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
609
+				if ($limit) {
610
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
611
+				} else {
612
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
613
+				}
509 614
 				 try {
510 615
 					$sth = $this->db->prepare($query);
511 616
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -513,11 +618,16 @@  discard block
 block discarded – undo
513 618
 					echo "error : ".$e->getMessage();
514 619
 				}
515 620
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
516
-			} else $all = array();
621
+			} else {
622
+				$all = array();
623
+			}
517 624
 		} else {
518 625
 			if ($year == '' && $month == '') {
519
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
520
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
626
+				if ($limit) {
627
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
628
+				} else {
629
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
630
+				}
521 631
 				 try {
522 632
 					$sth = $this->db->prepare($query);
523 633
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -525,7 +635,9 @@  discard block
 block discarded – undo
525 635
 					echo "error : ".$e->getMessage();
526 636
 				}
527 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528
-			} else $all = array();
638
+			} else {
639
+				$all = array();
640
+			}
529 641
 		}
530 642
 		if (empty($all)) {
531 643
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -544,7 +656,9 @@  discard block
 block discarded – undo
544 656
 	}
545 657
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
546 658
 		$Connection = new Connection($this->db);
547
-		if ($filter_name == '') $filter_name = $this->filter_name;
659
+		if ($filter_name == '') {
660
+			$filter_name = $this->filter_name;
661
+		}
548 662
 		if ($Connection->tableExists('countries')) {
549 663
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
550 664
 				$Spotter = new Spotter($this->db);
@@ -554,8 +668,11 @@  discard block
 block discarded – undo
554 668
 					foreach ($airlines as $airline) {
555 669
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
556 670
 					}
557
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
671
+					if ($limit) {
672
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
673
+					} else {
674
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
675
+					}
559 676
 					 try {
560 677
 						$sth = $this->db->prepare($query);
561 678
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -564,11 +681,16 @@  discard block
 block discarded – undo
564 681
 					}
565 682
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
566 683
 					return $all;
567
-				} else return array();
684
+				} else {
685
+					return array();
686
+				}
568 687
 			} else {
569 688
 				if ($year == '' && $month == '') {
570
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
571
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
689
+					if ($limit) {
690
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
691
+					} else {
692
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
693
+					}
572 694
 					 try {
573 695
 						$sth = $this->db->prepare($query);
574 696
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,20 +699,29 @@  discard block
 block discarded – undo
577 699
 					}
578 700
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 701
 					return $all;
580
-				} else return array();
702
+				} else {
703
+					return array();
704
+				}
581 705
 			}
582 706
 			$Spotter = new Spotter($this->db);
583 707
 			return $Spotter->countAllFlightOverCountries($limit);
584
-		} else return array();
708
+		} else {
709
+			return array();
710
+		}
585 711
 	}
586 712
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
587 713
 		$Connection = new Connection($this->db);
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
589 717
 		if ($Connection->tableExists('countries')) {
590 718
 			$all = array();
591 719
 			if ($year == '' && $month == '') {
592
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
593
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
720
+				if ($limit) {
721
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
722
+				} else {
723
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
724
+				}
594 725
 				 try {
595 726
 					$sth = $this->db->prepare($query);
596 727
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -608,17 +739,24 @@  discard block
 block discarded – undo
608 739
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
609 740
 			}
610 741
 			return $all;
611
-		} else return array();
742
+		} else {
743
+			return array();
744
+		}
612 745
 	}
613 746
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
614 747
 		global $globalStatsFilters;
615 748
 		$Connection = new Connection($this->db);
616
-		if ($filter_name == '') $filter_name = $this->filter_name;
749
+		if ($filter_name == '') {
750
+			$filter_name = $this->filter_name;
751
+		}
617 752
 		if ($Connection->tableExists('countries')) {
618 753
 			$all = array();
619 754
 			if ($year == '' && $month == '') {
620
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
621
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
755
+				if ($limit) {
756
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
757
+				} else {
758
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
759
+				}
622 760
 				 try {
623 761
 					$sth = $this->db->prepare($query);
624 762
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -637,14 +775,21 @@  discard block
 block discarded – undo
637 775
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
638 776
 			}
639 777
 			return $all;
640
-		} else return array();
778
+		} else {
779
+			return array();
780
+		}
641 781
 	}
642 782
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
643 783
 		global $globalStatsFilters;
644
-		if ($filter_name == '') $filter_name = $this->filter_name;
784
+		if ($filter_name == '') {
785
+			$filter_name = $this->filter_name;
786
+		}
645 787
 		if ($year == '' && $month == '') {
646
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
647
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
788
+			if ($limit) {
789
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
790
+			} else {
791
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
792
+			}
648 793
 			try {
649 794
 				$sth = $this->db->prepare($query);
650 795
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -652,7 +797,9 @@  discard block
 block discarded – undo
652 797
 				echo "error : ".$e->getMessage();
653 798
 			}
654 799
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655
-		} else $all = array();
800
+		} else {
801
+			$all = array();
802
+		}
656 803
 		if (empty($all)) {
657 804
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
658 805
 			if ($filter_name != '') {
@@ -667,7 +814,9 @@  discard block
 block discarded – undo
667 814
 
668 815
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
669 816
 		global $globalStatsFilters;
670
-		if ($filter_name == '') $filter_name = $this->filter_name;
817
+		if ($filter_name == '') {
818
+			$filter_name = $this->filter_name;
819
+		}
671 820
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
672 821
 			$Spotter = new Spotter($this->db);
673 822
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -676,8 +825,11 @@  discard block
 block discarded – undo
676 825
 				foreach ($airlines as $airline) {
677 826
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
678 827
 				}
679
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
828
+				if ($limit) {
829
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
830
+				} else {
831
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
832
+				}
681 833
 				try {
682 834
 					$sth = $this->db->prepare($query);
683 835
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -685,11 +837,16 @@  discard block
 block discarded – undo
685 837
 					echo "error : ".$e->getMessage();
686 838
 				}
687 839
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
688
-			} else $all = array();
840
+			} else {
841
+				$all = array();
842
+			}
689 843
 		} else {
690 844
 			if ($year == '' && $month == '') {
691
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
692
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
845
+				if ($limit) {
846
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
847
+				} else {
848
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
849
+				}
693 850
 				try {
694 851
 					$sth = $this->db->prepare($query);
695 852
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -697,7 +854,9 @@  discard block
 block discarded – undo
697 854
 					echo "error : ".$e->getMessage();
698 855
 				}
699 856
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
700
-			} else $all = array();
857
+			} else {
858
+				$all = array();
859
+			}
701 860
 		}
702 861
 		if (empty($all)) {
703 862
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -716,7 +875,9 @@  discard block
 block discarded – undo
716 875
 	}
717 876
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
718 877
 		global $globalStatsFilters;
719
-		if ($filter_name == '') $filter_name = $this->filter_name;
878
+		if ($filter_name == '') {
879
+			$filter_name = $this->filter_name;
880
+		}
720 881
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
721 882
 			$Spotter = new Spotter($this->db);
722 883
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -725,8 +886,11 @@  discard block
 block discarded – undo
725 886
 				foreach ($airlines as $airline) {
726 887
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
727 888
 				}
728
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
889
+				if ($limit) {
890
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
891
+				} else {
892
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
893
+				}
730 894
 				try {
731 895
 					$sth = $this->db->prepare($query);
732 896
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -734,11 +898,16 @@  discard block
 block discarded – undo
734 898
 					echo "error : ".$e->getMessage();
735 899
 				}
736 900
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
737
-			} else $all = array();
901
+			} else {
902
+				$all = array();
903
+			}
738 904
 		} else {
739 905
 			if ($year == '' && $month == '') {
740
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
741
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
906
+				if ($limit) {
907
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
908
+				} else {
909
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
910
+				}
742 911
 				try {
743 912
 					$sth = $this->db->prepare($query);
744 913
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -746,7 +915,9 @@  discard block
 block discarded – undo
746 915
 					echo "error : ".$e->getMessage();
747 916
 				}
748 917
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
749
-			} else $all = array();
918
+			} else {
919
+				$all = array();
920
+			}
750 921
 		}
751 922
 		if (empty($all)) {
752 923
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -771,7 +942,9 @@  discard block
 block discarded – undo
771 942
 				$icao = $value['airport_departure_icao'];
772 943
 				if (isset($all[$icao])) {
773 944
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
774
-				} else $all[$icao] = $value;
945
+				} else {
946
+					$all[$icao] = $value;
947
+				}
775 948
 			}
776 949
 			$count = array();
777 950
 			foreach ($all as $key => $row) {
@@ -783,7 +956,9 @@  discard block
 block discarded – undo
783 956
 	}
784 957
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
785 958
 		global $globalStatsFilters;
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
959
+		if ($filter_name == '') {
960
+			$filter_name = $this->filter_name;
961
+		}
787 962
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
788 963
 			$Spotter = new Spotter($this->db);
789 964
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -792,8 +967,11 @@  discard block
 block discarded – undo
792 967
 				foreach ($airlines as $airline) {
793 968
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
794 969
 				}
795
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
970
+				if ($limit) {
971
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
972
+				} else {
973
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
974
+				}
797 975
 				try {
798 976
 					$sth = $this->db->prepare($query);
799 977
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -801,11 +979,16 @@  discard block
 block discarded – undo
801 979
 					echo "error : ".$e->getMessage();
802 980
 				}
803 981
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
804
-			} else $all = array();
982
+			} else {
983
+				$all = array();
984
+			}
805 985
 		} else {
806 986
 			if ($year == '' && $month == '') {
807
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
808
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
987
+				if ($limit) {
988
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
989
+				} else {
990
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
991
+				}
809 992
 				try {
810 993
 					$sth = $this->db->prepare($query);
811 994
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -813,7 +996,9 @@  discard block
 block discarded – undo
813 996
 					echo "error : ".$e->getMessage();
814 997
 				}
815 998
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
816
-			} else $all = array();
999
+			} else {
1000
+				$all = array();
1001
+			}
817 1002
 		}
818 1003
 		if (empty($all)) {
819 1004
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -838,7 +1023,9 @@  discard block
 block discarded – undo
838 1023
 				$icao = $value['airport_arrival_icao'];
839 1024
 				if (isset($all[$icao])) {
840 1025
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
841
-				} else $all[$icao] = $value;
1026
+				} else {
1027
+					$all[$icao] = $value;
1028
+				}
842 1029
 			}
843 1030
 			$count = array();
844 1031
 			foreach ($all as $key => $row) {
@@ -850,7 +1037,9 @@  discard block
 block discarded – undo
850 1037
 	}
851 1038
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
852 1039
 		global $globalDBdriver, $globalStatsFilters;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
1040
+		if ($filter_name == '') {
1041
+			$filter_name = $this->filter_name;
1042
+		}
854 1043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
855 1044
 			$Spotter = new Spotter($this->db);
856 1045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -859,20 +1048,32 @@  discard block
 block discarded – undo
859 1048
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
860 1049
 			}
861 1050
 			if ($globalDBdriver == 'mysql') {
862
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1051
+				if ($limit) {
1052
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1053
+				} else {
1054
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1055
+				}
864 1056
 			} else {
865
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1057
+				if ($limit) {
1058
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1059
+				} else {
1060
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1061
+				}
867 1062
 			}
868 1063
 			$query_data = array(':filter_name' => $filter_name);
869 1064
 		} else {
870 1065
 			if ($globalDBdriver == 'mysql') {
871
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
872
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1066
+				if ($limit) {
1067
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1068
+				} else {
1069
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1070
+				}
873 1071
 			} else {
874
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
875
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1072
+				if ($limit) {
1073
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1074
+				} else {
1075
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1076
+				}
876 1077
 			}
877 1078
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
878 1079
 		}
@@ -900,13 +1101,21 @@  discard block
 block discarded – undo
900 1101
 
901 1102
 	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
902 1103
 		global $globalDBdriver, $globalStatsFilters;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1104
+		if ($filter_name == '') {
1105
+			$filter_name = $this->filter_name;
1106
+		}
904 1107
 		if ($globalDBdriver == 'mysql') {
905
-			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 = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
906
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1108
+			if ($limit) {
1109
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1110
+			} else {
1111
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1112
+			}
907 1113
 		} else {
908
-			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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
909
-			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 = 'marine_bymonth' AND filter_name = :filter_name";
1114
+			if ($limit) {
1115
+				$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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1116
+			} else {
1117
+				$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 = 'marine_bymonth' AND filter_name = :filter_name";
1118
+			}
910 1119
 		}
911 1120
 		$query_data = array(':filter_name' => $filter_name);
912 1121
 		try {
@@ -929,13 +1138,21 @@  discard block
 block discarded – undo
929 1138
 
930 1139
 	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
931 1140
 		global $globalDBdriver, $globalStatsFilters;
932
-		if ($filter_name == '') $filter_name = $this->filter_name;
1141
+		if ($filter_name == '') {
1142
+			$filter_name = $this->filter_name;
1143
+		}
933 1144
 		if ($globalDBdriver == 'mysql') {
934
-			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 = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
935
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1145
+			if ($limit) {
1146
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1147
+			} else {
1148
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1149
+			}
936 1150
 		} else {
937
-			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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
938
-			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 = 'tracker_bymonth' AND filter_name = :filter_name";
1151
+			if ($limit) {
1152
+				$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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1153
+			} else {
1154
+				$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 = 'tracker_bymonth' AND filter_name = :filter_name";
1155
+			}
939 1156
 		}
940 1157
 		$query_data = array(':filter_name' => $filter_name);
941 1158
 		try {
@@ -958,7 +1175,9 @@  discard block
 block discarded – undo
958 1175
 	
959 1176
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
960 1177
 		global $globalStatsFilters;
961
-		if ($filter_name == '') $filter_name = $this->filter_name;
1178
+		if ($filter_name == '') {
1179
+			$filter_name = $this->filter_name;
1180
+		}
962 1181
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
963 1182
 			$Spotter = new Spotter($this->db);
964 1183
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -995,7 +1214,9 @@  discard block
 block discarded – undo
995 1214
 	}
996 1215
 	public function countAllMarineDatesLastMonth($filter_name = '') {
997 1216
 		global $globalStatsFilters;
998
-		if ($filter_name == '') $filter_name = $this->filter_name;
1217
+		if ($filter_name == '') {
1218
+			$filter_name = $this->filter_name;
1219
+		}
999 1220
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name";
1000 1221
 		$query_data = array(':filter_name' => $filter_name);
1001 1222
 		try {
@@ -1017,7 +1238,9 @@  discard block
 block discarded – undo
1017 1238
 	}
1018 1239
 	public function countAllTrackerDatesLastMonth($filter_name = '') {
1019 1240
 		global $globalStatsFilters;
1020
-		if ($filter_name == '') $filter_name = $this->filter_name;
1241
+		if ($filter_name == '') {
1242
+			$filter_name = $this->filter_name;
1243
+		}
1021 1244
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name";
1022 1245
 		$query_data = array(':filter_name' => $filter_name);
1023 1246
 		try {
@@ -1039,7 +1262,9 @@  discard block
 block discarded – undo
1039 1262
 	}
1040 1263
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1041 1264
 		global $globalDBdriver, $globalStatsFilters;
1042
-		if ($filter_name == '') $filter_name = $this->filter_name;
1265
+		if ($filter_name == '') {
1266
+			$filter_name = $this->filter_name;
1267
+		}
1043 1268
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1044 1269
 			$Spotter = new Spotter($this->db);
1045 1270
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1084,7 +1309,9 @@  discard block
 block discarded – undo
1084 1309
 	}
1085 1310
 	public function countAllMarineDatesLast7Days($filter_name = '') {
1086 1311
 		global $globalDBdriver, $globalStatsFilters;
1087
-		if ($filter_name == '') $filter_name = $this->filter_name;
1312
+		if ($filter_name == '') {
1313
+			$filter_name = $this->filter_name;
1314
+		}
1088 1315
 		if ($globalDBdriver == 'mysql') {
1089 1316
 			$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1090 1317
 		} else {
@@ -1110,7 +1337,9 @@  discard block
 block discarded – undo
1110 1337
 	}
1111 1338
 	public function countAllTrackerDatesLast7Days($filter_name = '') {
1112 1339
 		global $globalDBdriver, $globalStatsFilters;
1113
-		if ($filter_name == '') $filter_name = $this->filter_name;
1340
+		if ($filter_name == '') {
1341
+			$filter_name = $this->filter_name;
1342
+		}
1114 1343
 		if ($globalDBdriver == 'mysql') {
1115 1344
 			$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1116 1345
 		} else {
@@ -1136,7 +1365,9 @@  discard block
 block discarded – undo
1136 1365
 	}
1137 1366
 	public function countAllDates($stats_airline = '',$filter_name = '') {
1138 1367
 		global $globalStatsFilters;
1139
-		if ($filter_name == '') $filter_name = $this->filter_name;
1368
+		if ($filter_name == '') {
1369
+			$filter_name = $this->filter_name;
1370
+		}
1140 1371
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1141 1372
 			$Spotter = new Spotter($this->db);
1142 1373
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1173,7 +1404,9 @@  discard block
 block discarded – undo
1173 1404
 	}
1174 1405
 	public function countAllDatesMarine($filter_name = '') {
1175 1406
 		global $globalStatsFilters;
1176
-		if ($filter_name == '') $filter_name = $this->filter_name;
1407
+		if ($filter_name == '') {
1408
+			$filter_name = $this->filter_name;
1409
+		}
1177 1410
 		$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";
1178 1411
 		$query_data = array(':filter_name' => $filter_name);
1179 1412
 		try {
@@ -1195,7 +1428,9 @@  discard block
 block discarded – undo
1195 1428
 	}
1196 1429
 	public function countAllDatesTracker($filter_name = '') {
1197 1430
 		global $globalStatsFilters;
1198
-		if ($filter_name == '') $filter_name = $this->filter_name;
1431
+		if ($filter_name == '') {
1432
+			$filter_name = $this->filter_name;
1433
+		}
1199 1434
 		$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";
1200 1435
 		$query_data = array(':filter_name' => $filter_name);
1201 1436
 		try {
@@ -1217,7 +1452,9 @@  discard block
 block discarded – undo
1217 1452
 	}
1218 1453
 	public function countAllDatesByAirlines($filter_name = '') {
1219 1454
 		global $globalStatsFilters;
1220
-		if ($filter_name == '') $filter_name = $this->filter_name;
1455
+		if ($filter_name == '') {
1456
+			$filter_name = $this->filter_name;
1457
+		}
1221 1458
 		$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";
1222 1459
 		$query_data = array('filter_name' => $filter_name);
1223 1460
 		try {
@@ -1239,7 +1476,9 @@  discard block
 block discarded – undo
1239 1476
 	}
1240 1477
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1241 1478
 		global $globalStatsFilters, $globalDBdriver;
1242
-		if ($filter_name == '') $filter_name = $this->filter_name;
1479
+		if ($filter_name == '') {
1480
+			$filter_name = $this->filter_name;
1481
+		}
1243 1482
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1244 1483
 			$Spotter = new Spotter($this->db);
1245 1484
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1324,7 +1563,9 @@  discard block
 block discarded – undo
1324 1563
 	}
1325 1564
 	public function countAllMilitaryMonths($filter_name = '') {
1326 1565
 		global $globalStatsFilters;
1327
-		if ($filter_name == '') $filter_name = $this->filter_name;
1566
+		if ($filter_name == '') {
1567
+			$filter_name = $this->filter_name;
1568
+		}
1328 1569
 		$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";
1329 1570
 		try {
1330 1571
 			$sth = $this->db->prepare($query);
@@ -1345,7 +1586,9 @@  discard block
 block discarded – undo
1345 1586
 	}
1346 1587
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1347 1588
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1348
-		if ($filter_name == '') $filter_name = $this->filter_name;
1589
+		if ($filter_name == '') {
1590
+			$filter_name = $this->filter_name;
1591
+		}
1349 1592
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1350 1593
 			$Spotter = new Spotter($this->db);
1351 1594
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1353,12 +1596,18 @@  discard block
 block discarded – undo
1353 1596
 			foreach ($airlines as $airline) {
1354 1597
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1355 1598
 			}
1356
-			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";
1357
-			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";
1599
+			if ($limit) {
1600
+				$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";
1601
+			} else {
1602
+				$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";
1603
+			}
1358 1604
 			$query_data = array(':filter_name' => $filter_name);
1359 1605
 		} else {
1360
-			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";
1361
-			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";
1606
+			if ($limit) {
1607
+				$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";
1608
+			} else {
1609
+				$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";
1610
+			}
1362 1611
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1363 1612
 		}
1364 1613
 		if ($orderby == 'hour') {
@@ -1368,7 +1617,9 @@  discard block
 block discarded – undo
1368 1617
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1369 1618
 			}
1370 1619
 		}
1371
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1620
+		if ($orderby == 'count') {
1621
+			$query .= " ORDER BY hour_count DESC";
1622
+		}
1372 1623
 		try {
1373 1624
 			$sth = $this->db->prepare($query);
1374 1625
 			$sth->execute($query_data);
@@ -1392,9 +1643,14 @@  discard block
 block discarded – undo
1392 1643
 	}
1393 1644
 	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1394 1645
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1395
-		if ($filter_name == '') $filter_name = $this->filter_name;
1396
-		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1397
-		else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1646
+		if ($filter_name == '') {
1647
+			$filter_name = $this->filter_name;
1648
+		}
1649
+		if ($limit) {
1650
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1651
+		} else {
1652
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1653
+		}
1398 1654
 		$query_data = array(':filter_name' => $filter_name);
1399 1655
 		if ($orderby == 'hour') {
1400 1656
 			if ($globalDBdriver == 'mysql') {
@@ -1403,7 +1659,9 @@  discard block
 block discarded – undo
1403 1659
 				$query .= " ORDER BY CAST(marine_date AS integer) ASC";
1404 1660
 			}
1405 1661
 		}
1406
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1662
+		if ($orderby == 'count') {
1663
+			$query .= " ORDER BY hour_count DESC";
1664
+		}
1407 1665
 		try {
1408 1666
 			$sth = $this->db->prepare($query);
1409 1667
 			$sth->execute($query_data);
@@ -1423,9 +1681,14 @@  discard block
 block discarded – undo
1423 1681
 	}
1424 1682
 	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1425 1683
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1426
-		if ($filter_name == '') $filter_name = $this->filter_name;
1427
-		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1428
-		else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1684
+		if ($filter_name == '') {
1685
+			$filter_name = $this->filter_name;
1686
+		}
1687
+		if ($limit) {
1688
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1689
+		} else {
1690
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1691
+		}
1429 1692
 		$query_data = array(':filter_name' => $filter_name);
1430 1693
 		if ($orderby == 'hour') {
1431 1694
 			if ($globalDBdriver == 'mysql') {
@@ -1434,7 +1697,9 @@  discard block
 block discarded – undo
1434 1697
 				$query .= " ORDER BY CAST(tracker_date AS integer) ASC";
1435 1698
 			}
1436 1699
 		}
1437
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1700
+		if ($orderby == 'count') {
1701
+			$query .= " ORDER BY hour_count DESC";
1702
+		}
1438 1703
 		try {
1439 1704
 			$sth = $this->db->prepare($query);
1440 1705
 			$sth->execute($query_data);
@@ -1454,8 +1719,12 @@  discard block
 block discarded – undo
1454 1719
 	}
1455 1720
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1456 1721
 		global $globalStatsFilters;
1457
-		if ($filter_name == '') $filter_name = $this->filter_name;
1458
-		if ($year == '') $year = date('Y');
1722
+		if ($filter_name == '') {
1723
+			$filter_name = $this->filter_name;
1724
+		}
1725
+		if ($year == '') {
1726
+			$year = date('Y');
1727
+		}
1459 1728
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1460 1729
 		if (empty($all)) {
1461 1730
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1474,8 +1743,12 @@  discard block
 block discarded – undo
1474 1743
 	}
1475 1744
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1476 1745
 		global $globalStatsFilters;
1477
-		if ($filter_name == '') $filter_name = $this->filter_name;
1478
-		if ($year == '') $year = date('Y');
1746
+		if ($filter_name == '') {
1747
+			$filter_name = $this->filter_name;
1748
+		}
1749
+		if ($year == '') {
1750
+			$year = date('Y');
1751
+		}
1479 1752
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1480 1753
 		if (empty($all)) {
1481 1754
 			$filters = array('year' => $year,'month' => $month);
@@ -1490,8 +1763,12 @@  discard block
 block discarded – undo
1490 1763
 	}
1491 1764
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1492 1765
 		global $globalStatsFilters;
1493
-		if ($filter_name == '') $filter_name = $this->filter_name;
1494
-		if ($year == '') $year = date('Y');
1766
+		if ($filter_name == '') {
1767
+			$filter_name = $this->filter_name;
1768
+		}
1769
+		if ($year == '') {
1770
+			$year = date('Y');
1771
+		}
1495 1772
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1496 1773
 		if (empty($all)) {
1497 1774
 			$filters = array('year' => $year,'month' => $month);
@@ -1506,8 +1783,12 @@  discard block
 block discarded – undo
1506 1783
 	}
1507 1784
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1508 1785
 		global $globalStatsFilters;
1509
-		if ($filter_name == '') $filter_name = $this->filter_name;
1510
-		if ($year == '') $year = date('Y');
1786
+		if ($filter_name == '') {
1787
+			$filter_name = $this->filter_name;
1788
+		}
1789
+		if ($year == '') {
1790
+			$year = date('Y');
1791
+		}
1511 1792
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1512 1793
 		if (empty($all)) {
1513 1794
 			$filters = array();
@@ -1523,8 +1804,12 @@  discard block
 block discarded – undo
1523 1804
 	}
1524 1805
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1525 1806
 		global $globalStatsFilters;
1526
-		if ($filter_name == '') $filter_name = $this->filter_name;
1527
-		if ($year == '') $year = date('Y');
1807
+		if ($filter_name == '') {
1808
+			$filter_name = $this->filter_name;
1809
+		}
1810
+		if ($year == '') {
1811
+			$year = date('Y');
1812
+		}
1528 1813
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1529 1814
 		if (empty($all)) {
1530 1815
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1543,7 +1828,9 @@  discard block
 block discarded – undo
1543 1828
 	}
1544 1829
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1545 1830
 		global $globalStatsFilters;
1546
-		if ($filter_name == '') $filter_name = $this->filter_name;
1831
+		if ($filter_name == '') {
1832
+			$filter_name = $this->filter_name;
1833
+		}
1547 1834
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1548 1835
 			$Spotter = new Spotter($this->db);
1549 1836
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1561,7 +1848,9 @@  discard block
 block discarded – undo
1561 1848
 				}
1562 1849
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1563 1850
 				$all = $result[0]['nb'];
1564
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1851
+			} else {
1852
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1853
+			}
1565 1854
 		} else {
1566 1855
 			if ($year == '' && $month == '') {
1567 1856
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1573,7 +1862,9 @@  discard block
 block discarded – undo
1573 1862
 				}
1574 1863
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1575 1864
 				$all = $result[0]['nb'];
1576
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1865
+			} else {
1866
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1867
+			}
1577 1868
 		}
1578 1869
 		if (empty($all)) {
1579 1870
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1592,7 +1883,9 @@  discard block
 block discarded – undo
1592 1883
 	}
1593 1884
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1594 1885
 		global $globalStatsFilters;
1595
-		if ($filter_name == '') $filter_name = $this->filter_name;
1886
+		if ($filter_name == '') {
1887
+			$filter_name = $this->filter_name;
1888
+		}
1596 1889
 		if ($year == '' && $month == '') {
1597 1890
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1598 1891
 			try {
@@ -1603,7 +1896,9 @@  discard block
 block discarded – undo
1603 1896
 			}
1604 1897
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1605 1898
 			$all = $result[0]['nb_airline'];
1606
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1899
+		} else {
1900
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1901
+		}
1607 1902
 		if (empty($all)) {
1608 1903
 			$filters = array();
1609 1904
 			$filters = array('year' => $year,'month' => $month);
@@ -1618,7 +1913,9 @@  discard block
 block discarded – undo
1618 1913
 	}
1619 1914
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1620 1915
 		global $globalStatsFilters;
1621
-		if ($filter_name == '') $filter_name = $this->filter_name;
1916
+		if ($filter_name == '') {
1917
+			$filter_name = $this->filter_name;
1918
+		}
1622 1919
 		$all = array();
1623 1920
 		if ($year == '' && $month == '') {
1624 1921
 			$query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1645,7 +1942,9 @@  discard block
 block discarded – undo
1645 1942
 	}
1646 1943
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1647 1944
 		global $globalStatsFilters;
1648
-		if ($filter_name == '') $filter_name = $this->filter_name;
1945
+		if ($filter_name == '') {
1946
+			$filter_name = $this->filter_name;
1947
+		}
1649 1948
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1650 1949
 			$Spotter = new Spotter($this->db);
1651 1950
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1700,7 +1999,9 @@  discard block
 block discarded – undo
1700 1999
 	}
1701 2000
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1702 2001
 		global $globalStatsFilters;
1703
-		if ($filter_name == '') $filter_name = $this->filter_name;
2002
+		if ($filter_name == '') {
2003
+			$filter_name = $this->filter_name;
2004
+		}
1704 2005
 		//if ($year == '') $year = date('Y');
1705 2006
 		if ($year == '' && $month == '') {
1706 2007
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1729,7 +2030,9 @@  discard block
 block discarded – undo
1729 2030
 	}
1730 2031
 
1731 2032
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1732
-		if ($filter_name == '') $filter_name = $this->filter_name;
2033
+		if ($filter_name == '') {
2034
+			$filter_name = $this->filter_name;
2035
+		}
1733 2036
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1734 2037
 			$Spotter = new Spotter($this->db);
1735 2038
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1753,7 +2056,9 @@  discard block
 block discarded – undo
1753 2056
 		return $all;
1754 2057
 	}
1755 2058
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1756
-		if ($filter_name == '') $filter_name = $this->filter_name;
2059
+		if ($filter_name == '') {
2060
+			$filter_name = $this->filter_name;
2061
+		}
1757 2062
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1758 2063
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1759 2064
 		try {
@@ -1766,7 +2071,9 @@  discard block
 block discarded – undo
1766 2071
 		return $all;
1767 2072
 	}
1768 2073
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1769
-		if ($filter_name == '') $filter_name = $this->filter_name;
2074
+		if ($filter_name == '') {
2075
+			$filter_name = $this->filter_name;
2076
+		}
1770 2077
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1771 2078
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1772 2079
 		try {
@@ -1777,7 +2084,9 @@  discard block
 block discarded – undo
1777 2084
 		}
1778 2085
 	}
1779 2086
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1780
-		if ($filter_name == '') $filter_name = $this->filter_name;
2087
+		if ($filter_name == '') {
2088
+			$filter_name = $this->filter_name;
2089
+		}
1781 2090
 		global $globalArchiveMonths, $globalDBdriver;
1782 2091
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1783 2092
 			$Spotter = new Spotter($this->db);
@@ -1833,7 +2142,9 @@  discard block
 block discarded – undo
1833 2142
 	}
1834 2143
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1835 2144
 		global $globalArchiveMonths, $globalDBdriver;
1836
-		if ($filter_name == '') $filter_name = $this->filter_name;
2145
+		if ($filter_name == '') {
2146
+			$filter_name = $this->filter_name;
2147
+		}
1837 2148
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1838 2149
 			$Spotter = new Spotter($this->db);
1839 2150
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1866,7 +2177,9 @@  discard block
 block discarded – undo
1866 2177
 	}
1867 2178
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1868 2179
 		global $globalArchiveMonths, $globalDBdriver;
1869
-		if ($filter_name == '') $filter_name = $this->filter_name;
2180
+		if ($filter_name == '') {
2181
+			$filter_name = $this->filter_name;
2182
+		}
1870 2183
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1871 2184
 			$Spotter = new Spotter($this->db);
1872 2185
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1897,7 +2210,9 @@  discard block
 block discarded – undo
1897 2210
 	}
1898 2211
 	public function getStatsAirlineTotal($filter_name = '') {
1899 2212
 		global $globalArchiveMonths, $globalDBdriver;
1900
-		if ($filter_name == '') $filter_name = $this->filter_name;
2213
+		if ($filter_name == '') {
2214
+			$filter_name = $this->filter_name;
2215
+		}
1901 2216
 		if ($globalDBdriver == 'mysql') {
1902 2217
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1903 2218
 		} else {
@@ -1914,7 +2229,9 @@  discard block
 block discarded – undo
1914 2229
 	}
1915 2230
 	public function getStatsOwnerTotal($filter_name = '') {
1916 2231
 		global $globalArchiveMonths, $globalDBdriver;
1917
-		if ($filter_name == '') $filter_name = $this->filter_name;
2232
+		if ($filter_name == '') {
2233
+			$filter_name = $this->filter_name;
2234
+		}
1918 2235
 		if ($globalDBdriver == 'mysql') {
1919 2236
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1920 2237
 		} else {
@@ -1931,7 +2248,9 @@  discard block
 block discarded – undo
1931 2248
 	}
1932 2249
 	public function getStatsOwner($owner_name,$filter_name = '') {
1933 2250
 		global $globalArchiveMonths, $globalDBdriver;
1934
-		if ($filter_name == '') $filter_name = $this->filter_name;
2251
+		if ($filter_name == '') {
2252
+			$filter_name = $this->filter_name;
2253
+		}
1935 2254
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1936 2255
 		try {
1937 2256
 			$sth = $this->db->prepare($query);
@@ -1940,12 +2259,17 @@  discard block
 block discarded – undo
1940 2259
 			echo "error : ".$e->getMessage();
1941 2260
 		}
1942 2261
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1943
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1944
-		else return 0;
2262
+		if (isset($all[0]['cnt'])) {
2263
+			return $all[0]['cnt'];
2264
+		} else {
2265
+			return 0;
2266
+		}
1945 2267
 	}
1946 2268
 	public function getStatsPilotTotal($filter_name = '') {
1947 2269
 		global $globalArchiveMonths, $globalDBdriver;
1948
-		if ($filter_name == '') $filter_name = $this->filter_name;
2270
+		if ($filter_name == '') {
2271
+			$filter_name = $this->filter_name;
2272
+		}
1949 2273
 		if ($globalDBdriver == 'mysql') {
1950 2274
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1951 2275
 		} else {
@@ -1962,7 +2286,9 @@  discard block
 block discarded – undo
1962 2286
 	}
1963 2287
 	public function getStatsPilot($pilot,$filter_name = '') {
1964 2288
 		global $globalArchiveMonths, $globalDBdriver;
1965
-		if ($filter_name == '') $filter_name = $this->filter_name;
2289
+		if ($filter_name == '') {
2290
+			$filter_name = $this->filter_name;
2291
+		}
1966 2292
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1967 2293
 		try {
1968 2294
 			$sth = $this->db->prepare($query);
@@ -1971,13 +2297,18 @@  discard block
 block discarded – undo
1971 2297
 			echo "error : ".$e->getMessage();
1972 2298
 		}
1973 2299
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1974
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1975
-		else return 0;
2300
+		if (isset($all[0]['cnt'])) {
2301
+			return $all[0]['cnt'];
2302
+		} else {
2303
+			return 0;
2304
+		}
1976 2305
 	}
1977 2306
 
1978 2307
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1979 2308
 		global $globalDBdriver;
1980
-		if ($filter_name == '') $filter_name = $this->filter_name;
2309
+		if ($filter_name == '') {
2310
+			$filter_name = $this->filter_name;
2311
+		}
1981 2312
 		if ($globalDBdriver == 'mysql') {
1982 2313
 			$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";
1983 2314
 		} else {
@@ -1993,7 +2324,9 @@  discard block
 block discarded – undo
1993 2324
 	}
1994 2325
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1995 2326
 		global $globalDBdriver;
1996
-		if ($filter_name == '') $filter_name = $this->filter_name;
2327
+		if ($filter_name == '') {
2328
+			$filter_name = $this->filter_name;
2329
+		}
1997 2330
 		if ($globalDBdriver == 'mysql') {
1998 2331
 			$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";
1999 2332
 		} else {
@@ -2512,27 +2845,37 @@  discard block
 block discarded – undo
2512 2845
 		date_default_timezone_set('UTC');
2513 2846
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2514 2847
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2515
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2848
+			if ($globalDebug) {
2849
+				echo '!!! Update Marine stats !!!'."\n";
2850
+			}
2516 2851
 			if (isset($last_update[0]['value'])) {
2517 2852
 				$last_update_day = $last_update[0]['value'];
2518
-			} else $last_update_day = '2012-12-12 12:12:12';
2853
+			} else {
2854
+				$last_update_day = '2012-12-12 12:12:12';
2855
+			}
2519 2856
 			$reset = false;
2520 2857
 			$Marine = new Marine($this->db);
2521 2858
 			$filtername = 'marine';
2522 2859
 			if ($Connection->tableExists('countries')) {
2523
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2860
+				if ($globalDebug) {
2861
+					echo 'Count all vessels by countries...'."\n";
2862
+				}
2524 2863
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2525 2864
 				foreach ($alldata as $number) {
2526 2865
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2527 2866
 				}
2528 2867
 			}
2529
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2868
+			if ($globalDebug) {
2869
+				echo 'Count all vessels by months...'."\n";
2870
+			}
2530 2871
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2531 2872
 			$filter_last_month = array('since_date' => $last_month);
2532 2873
 			$alldata = $Marine->countAllMonths($filter_last_month);
2533 2874
 			$lastyear = false;
2534 2875
 			foreach ($alldata as $number) {
2535
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2876
+				if ($number['year_name'] != date('Y')) {
2877
+					$lastyear = true;
2878
+				}
2536 2879
 				$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'])));
2537 2880
 			}
2538 2881
 			echo 'Marine data...'."\n";
@@ -2562,7 +2905,9 @@  discard block
 block discarded – undo
2562 2905
 			foreach ($alldata as $number) {
2563 2906
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2564 2907
 			}
2565
-			if ($globalDebug) echo 'Count all types...'."\n";
2908
+			if ($globalDebug) {
2909
+				echo 'Count all types...'."\n";
2910
+			}
2566 2911
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2567 2912
 			foreach ($alldata as $number) {
2568 2913
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2574,26 +2919,36 @@  discard block
 block discarded – undo
2574 2919
 		}
2575 2920
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2576 2921
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2577
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2922
+			if ($globalDebug) {
2923
+				echo '!!! Update tracker stats !!!'."\n";
2924
+			}
2578 2925
 			if (isset($last_update[0]['value'])) {
2579 2926
 				$last_update_day = $last_update[0]['value'];
2580
-			} else $last_update_day = '2012-12-12 12:12:12';
2927
+			} else {
2928
+				$last_update_day = '2012-12-12 12:12:12';
2929
+			}
2581 2930
 			$reset = false;
2582 2931
 			$Tracker = new Tracker($this->db);
2583 2932
 			if ($Connection->tableExists('countries')) {
2584
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2933
+				if ($globalDebug) {
2934
+					echo 'Count all trackers by countries...'."\n";
2935
+				}
2585 2936
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2586 2937
 				foreach ($alldata as $number) {
2587 2938
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2588 2939
 				}
2589 2940
 			}
2590
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2941
+			if ($globalDebug) {
2942
+				echo 'Count all vessels by months...'."\n";
2943
+			}
2591 2944
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2592 2945
 			$filter_last_month = array('since_date' => $last_month);
2593 2946
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2594 2947
 			$lastyear = false;
2595 2948
 			foreach ($alldata as $number) {
2596
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2949
+				if ($number['year_name'] != date('Y')) {
2950
+					$lastyear = true;
2951
+				}
2597 2952
 				$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'])));
2598 2953
 			}
2599 2954
 			echo 'Tracker data...'."\n";
@@ -2623,7 +2978,9 @@  discard block
 block discarded – undo
2623 2978
 			foreach ($alldata as $number) {
2624 2979
 				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2625 2980
 			}
2626
-			if ($globalDebug) echo 'Count all types...'."\n";
2981
+			if ($globalDebug) {
2982
+				echo 'Count all types...'."\n";
2983
+			}
2627 2984
 			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2628 2985
 			foreach ($alldata as $number) {
2629 2986
 				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
@@ -2635,10 +2992,14 @@  discard block
 block discarded – undo
2635 2992
 
2636 2993
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2637 2994
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2638
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2995
+			if ($globalDebug) {
2996
+				echo '!!! Update aicraft stats !!!'."\n";
2997
+			}
2639 2998
 			if (isset($last_update[0]['value'])) {
2640 2999
 				$last_update_day = $last_update[0]['value'];
2641
-			} else $last_update_day = '2012-12-12 12:12:12';
3000
+			} else {
3001
+				$last_update_day = '2012-12-12 12:12:12';
3002
+			}
2642 3003
 			$reset = false;
2643 3004
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2644 3005
 			if ($globalStatsResetYear) {
@@ -2647,43 +3008,63 @@  discard block
 block discarded – undo
2647 3008
 			}
2648 3009
 			$Spotter = new Spotter($this->db);
2649 3010
 
2650
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
3011
+			if ($globalDebug) {
3012
+				echo 'Count all aircraft types...'."\n";
3013
+			}
2651 3014
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2652 3015
 			foreach ($alldata as $number) {
2653 3016
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2654 3017
 			}
2655
-			if ($globalDebug) echo 'Count all airlines...'."\n";
3018
+			if ($globalDebug) {
3019
+				echo 'Count all airlines...'."\n";
3020
+			}
2656 3021
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2657 3022
 			foreach ($alldata as $number) {
2658 3023
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2659 3024
 			}
2660
-			if ($globalDebug) echo 'Count all registrations...'."\n";
3025
+			if ($globalDebug) {
3026
+				echo 'Count all registrations...'."\n";
3027
+			}
2661 3028
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2662 3029
 			foreach ($alldata as $number) {
2663 3030
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2664 3031
 			}
2665
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
3032
+			if ($globalDebug) {
3033
+				echo 'Count all callsigns...'."\n";
3034
+			}
2666 3035
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2667 3036
 			foreach ($alldata as $number) {
2668 3037
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2669 3038
 			}
2670
-			if ($globalDebug) echo 'Count all owners...'."\n";
3039
+			if ($globalDebug) {
3040
+				echo 'Count all owners...'."\n";
3041
+			}
2671 3042
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2672 3043
 			foreach ($alldata as $number) {
2673 3044
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2674 3045
 			}
2675
-			if ($globalDebug) echo 'Count all pilots...'."\n";
3046
+			if ($globalDebug) {
3047
+				echo 'Count all pilots...'."\n";
3048
+			}
2676 3049
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2677 3050
 			foreach ($alldata as $number) {
2678
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
3051
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
3052
+					$number['pilot_id'] = $number['pilot_name'];
3053
+				}
2679 3054
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2680 3055
 			}
2681 3056
 			
2682
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
3057
+			if ($globalDebug) {
3058
+				echo 'Count all departure airports...'."\n";
3059
+			}
2683 3060
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2684
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
3061
+			if ($globalDebug) {
3062
+				echo 'Count all detected departure airports...'."\n";
3063
+			}
2685 3064
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2686
-			if ($globalDebug) echo 'Order departure airports...'."\n";
3065
+			if ($globalDebug) {
3066
+				echo 'Order departure airports...'."\n";
3067
+			}
2687 3068
 			$alldata = array();
2688 3069
 			foreach ($pall as $value) {
2689 3070
 				$icao = $value['airport_departure_icao'];
@@ -2693,7 +3074,9 @@  discard block
 block discarded – undo
2693 3074
 				$icao = $value['airport_departure_icao'];
2694 3075
 				if (isset($alldata[$icao])) {
2695 3076
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2696
-				} else $alldata[$icao] = $value;
3077
+				} else {
3078
+					$alldata[$icao] = $value;
3079
+				}
2697 3080
 			}
2698 3081
 			$count = array();
2699 3082
 			foreach ($alldata as $key => $row) {
@@ -2703,11 +3086,17 @@  discard block
 block discarded – undo
2703 3086
 			foreach ($alldata as $number) {
2704 3087
 				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);
2705 3088
 			}
2706
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
3089
+			if ($globalDebug) {
3090
+				echo 'Count all arrival airports...'."\n";
3091
+			}
2707 3092
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2708
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
3093
+			if ($globalDebug) {
3094
+				echo 'Count all detected arrival airports...'."\n";
3095
+			}
2709 3096
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2710
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
3097
+			if ($globalDebug) {
3098
+				echo 'Order arrival airports...'."\n";
3099
+			}
2711 3100
 			$alldata = array();
2712 3101
 			foreach ($pall as $value) {
2713 3102
 				$icao = $value['airport_arrival_icao'];
@@ -2717,7 +3106,9 @@  discard block
 block discarded – undo
2717 3106
 				$icao = $value['airport_arrival_icao'];
2718 3107
 				if (isset($alldata[$icao])) {
2719 3108
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2720
-				} else $alldata[$icao] = $value;
3109
+				} else {
3110
+					$alldata[$icao] = $value;
3111
+				}
2721 3112
 			}
2722 3113
 			$count = array();
2723 3114
 			foreach ($alldata as $key => $row) {
@@ -2728,7 +3119,9 @@  discard block
 block discarded – undo
2728 3119
 				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);
2729 3120
 			}
2730 3121
 			if ($Connection->tableExists('countries')) {
2731
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
3122
+				if ($globalDebug) {
3123
+					echo 'Count all flights by countries...'."\n";
3124
+				}
2732 3125
 				//$SpotterArchive = new SpotterArchive();
2733 3126
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2734 3127
 				$Spotter = new Spotter($this->db);
@@ -2739,7 +3132,9 @@  discard block
 block discarded – undo
2739 3132
 			}
2740 3133
 			
2741 3134
 			if (isset($globalAccidents) && $globalAccidents) {
2742
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
3135
+				if ($globalDebug) {
3136
+					echo 'Count fatalities stats...'."\n";
3137
+				}
2743 3138
 				$Accident = new Accident($this->db);
2744 3139
 				$this->deleteStatsByType('fatalities_byyear');
2745 3140
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2755,48 +3150,68 @@  discard block
 block discarded – undo
2755 3150
 
2756 3151
 			// Add by month using getstat if month finish...
2757 3152
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2758
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
3153
+			if ($globalDebug) {
3154
+				echo 'Count all flights by months...'."\n";
3155
+			}
2759 3156
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2760 3157
 			$filter_last_month = array('since_date' => $last_month);
2761 3158
 			$Spotter = new Spotter($this->db);
2762 3159
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2763 3160
 			$lastyear = false;
2764 3161
 			foreach ($alldata as $number) {
2765
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3162
+				if ($number['year_name'] != date('Y')) {
3163
+					$lastyear = true;
3164
+				}
2766 3165
 				$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'])));
2767 3166
 			}
2768
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
3167
+			if ($globalDebug) {
3168
+				echo 'Count all military flights by months...'."\n";
3169
+			}
2769 3170
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2770 3171
 			foreach ($alldata as $number) {
2771 3172
 				$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'])));
2772 3173
 			}
2773
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
3174
+			if ($globalDebug) {
3175
+				echo 'Count all owners by months...'."\n";
3176
+			}
2774 3177
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2775 3178
 			foreach ($alldata as $number) {
2776 3179
 				$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'])));
2777 3180
 			}
2778
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
3181
+			if ($globalDebug) {
3182
+				echo 'Count all pilots by months...'."\n";
3183
+			}
2779 3184
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2780 3185
 			foreach ($alldata as $number) {
2781 3186
 				$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'])));
2782 3187
 			}
2783
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
3188
+			if ($globalDebug) {
3189
+				echo 'Count all airlines by months...'."\n";
3190
+			}
2784 3191
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2785 3192
 			foreach ($alldata as $number) {
2786 3193
 				$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'])));
2787 3194
 			}
2788
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3195
+			if ($globalDebug) {
3196
+				echo 'Count all aircrafts by months...'."\n";
3197
+			}
2789 3198
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2790 3199
 			foreach ($alldata as $number) {
2791 3200
 				$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'])));
2792 3201
 			}
2793
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3202
+			if ($globalDebug) {
3203
+				echo 'Count all real arrivals by months...'."\n";
3204
+			}
2794 3205
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2795 3206
 			foreach ($alldata as $number) {
2796 3207
 				$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'])));
2797 3208
 			}
2798
-			if ($globalDebug) echo 'Airports data...'."\n";
2799
-			if ($globalDebug) echo '...Departure'."\n";
3209
+			if ($globalDebug) {
3210
+				echo 'Airports data...'."\n";
3211
+			}
3212
+			if ($globalDebug) {
3213
+				echo '...Departure'."\n";
3214
+			}
2800 3215
 			$this->deleteStatAirport('daily');
2801 3216
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2802 3217
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2914,7 +3329,9 @@  discard block
 block discarded – undo
2914 3329
 			// Count by airlines
2915 3330
 			echo '--- Stats by airlines ---'."\n";
2916 3331
 			if ($Connection->tableExists('countries')) {
2917
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3332
+				if ($globalDebug) {
3333
+					echo 'Count all flights by countries by airlines...'."\n";
3334
+				}
2918 3335
 				$SpotterArchive = new SpotterArchive($this->db);
2919 3336
 				//$Spotter = new Spotter($this->db);
2920 3337
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2923,37 +3340,53 @@  discard block
 block discarded – undo
2923 3340
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2924 3341
 				}
2925 3342
 			}
2926
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3343
+			if ($globalDebug) {
3344
+				echo 'Count all aircraft types by airlines...'."\n";
3345
+			}
2927 3346
 			$Spotter = new Spotter($this->db);
2928 3347
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2929 3348
 			foreach ($alldata as $number) {
2930 3349
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2931 3350
 			}
2932
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3351
+			if ($globalDebug) {
3352
+				echo 'Count all aircraft registrations by airlines...'."\n";
3353
+			}
2933 3354
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2934 3355
 			foreach ($alldata as $number) {
2935 3356
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2936 3357
 			}
2937
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3358
+			if ($globalDebug) {
3359
+				echo 'Count all callsigns by airlines...'."\n";
3360
+			}
2938 3361
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2939 3362
 			foreach ($alldata as $number) {
2940 3363
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2941 3364
 			}
2942
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3365
+			if ($globalDebug) {
3366
+				echo 'Count all owners by airlines...'."\n";
3367
+			}
2943 3368
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2944 3369
 			foreach ($alldata as $number) {
2945 3370
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2946 3371
 			}
2947
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3372
+			if ($globalDebug) {
3373
+				echo 'Count all pilots by airlines...'."\n";
3374
+			}
2948 3375
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2949 3376
 			foreach ($alldata as $number) {
2950 3377
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2951 3378
 			}
2952
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3379
+			if ($globalDebug) {
3380
+				echo 'Count all departure airports by airlines...'."\n";
3381
+			}
2953 3382
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2954
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3383
+			if ($globalDebug) {
3384
+				echo 'Count all detected departure airports by airlines...'."\n";
3385
+			}
2955 3386
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2956
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3387
+			if ($globalDebug) {
3388
+				echo 'Order detected departure airports by airlines...'."\n";
3389
+			}
2957 3390
 			//$alldata = array();
2958 3391
 			foreach ($dall as $value) {
2959 3392
 				$icao = $value['airport_departure_icao'];
@@ -2974,11 +3407,17 @@  discard block
 block discarded – undo
2974 3407
 			foreach ($alldata as $number) {
2975 3408
 				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);
2976 3409
 			}
2977
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3410
+			if ($globalDebug) {
3411
+				echo 'Count all arrival airports by airlines...'."\n";
3412
+			}
2978 3413
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2979
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3414
+			if ($globalDebug) {
3415
+				echo 'Count all detected arrival airports by airlines...'."\n";
3416
+			}
2980 3417
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2981
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3418
+			if ($globalDebug) {
3419
+				echo 'Order arrival airports by airlines...'."\n";
3420
+			}
2982 3421
 			//$alldata = array();
2983 3422
 			foreach ($dall as $value) {
2984 3423
 				$icao = $value['airport_arrival_icao'];
@@ -2997,37 +3436,53 @@  discard block
 block discarded – undo
2997 3436
 			}
2998 3437
 			$alldata = $pall;
2999 3438
 			foreach ($alldata as $number) {
3000
-				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);
3439
+				if ($number['airline_icao'] != '') {
3440
+					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);
3441
+				}
3442
+			}
3443
+			if ($globalDebug) {
3444
+				echo 'Count all flights by months by airlines...'."\n";
3001 3445
 			}
3002
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3003 3446
 			$Spotter = new Spotter($this->db);
3004 3447
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
3005 3448
 			$lastyear = false;
3006 3449
 			foreach ($alldata as $number) {
3007
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3450
+				if ($number['year_name'] != date('Y')) {
3451
+					$lastyear = true;
3452
+				}
3008 3453
 				$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']);
3009 3454
 			}
3010
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3455
+			if ($globalDebug) {
3456
+				echo 'Count all owners by months by airlines...'."\n";
3457
+			}
3011 3458
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3012 3459
 			foreach ($alldata as $number) {
3013 3460
 				$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']);
3014 3461
 			}
3015
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3462
+			if ($globalDebug) {
3463
+				echo 'Count all pilots by months by airlines...'."\n";
3464
+			}
3016 3465
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3017 3466
 			foreach ($alldata as $number) {
3018 3467
 				$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']);
3019 3468
 			}
3020
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3469
+			if ($globalDebug) {
3470
+				echo 'Count all aircrafts by months by airlines...'."\n";
3471
+			}
3021 3472
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3022 3473
 			foreach ($alldata as $number) {
3023 3474
 				$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']);
3024 3475
 			}
3025
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3476
+			if ($globalDebug) {
3477
+				echo 'Count all real arrivals by months by airlines...'."\n";
3478
+			}
3026 3479
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3027 3480
 			foreach ($alldata as $number) {
3028 3481
 				$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']);
3029 3482
 			}
3030
-			if ($globalDebug) echo '...Departure'."\n";
3483
+			if ($globalDebug) {
3484
+				echo '...Departure'."\n";
3485
+			}
3031 3486
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
3032 3487
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
3033 3488
 			foreach ($dall as $value) {
@@ -3050,7 +3505,9 @@  discard block
 block discarded – undo
3050 3505
 			foreach ($alldata as $number) {
3051 3506
 				$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']);
3052 3507
 			}
3053
-			if ($globalDebug) echo '...Arrival'."\n";
3508
+			if ($globalDebug) {
3509
+				echo '...Arrival'."\n";
3510
+			}
3054 3511
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
3055 3512
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
3056 3513
 			foreach ($dall as $value) {
@@ -3074,13 +3531,19 @@  discard block
 block discarded – undo
3074 3531
 				$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']);
3075 3532
 			}
3076 3533
 
3077
-			if ($globalDebug) echo 'Flights data...'."\n";
3078
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3534
+			if ($globalDebug) {
3535
+				echo 'Flights data...'."\n";
3536
+			}
3537
+			if ($globalDebug) {
3538
+				echo '-> countAllDatesLastMonth...'."\n";
3539
+			}
3079 3540
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3080 3541
 			foreach ($alldata as $number) {
3081 3542
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3082 3543
 			}
3083
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3544
+			if ($globalDebug) {
3545
+				echo '-> countAllDates...'."\n";
3546
+			}
3084 3547
 			//$previousdata = $this->countAllDatesByAirlines();
3085 3548
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3086 3549
 			$values = array();
@@ -3093,14 +3556,18 @@  discard block
 block discarded – undo
3093 3556
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3094 3557
 			}
3095 3558
 			
3096
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3559
+			if ($globalDebug) {
3560
+				echo '-> countAllHours...'."\n";
3561
+			}
3097 3562
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3098 3563
 			foreach ($alldata as $number) {
3099 3564
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3100 3565
 			}
3101 3566
 
3102 3567
 			// Stats by filters
3103
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3568
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3569
+				$globalStatsFilters = array();
3570
+			}
3104 3571
 			foreach ($globalStatsFilters as $name => $filter) {
3105 3572
 				if (!empty($filter)) {
3106 3573
 					//$filter_name = $filter['name'];
@@ -3108,7 +3575,9 @@  discard block
 block discarded – undo
3108 3575
 					$reset = false;
3109 3576
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
3110 3577
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
3111
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3578
+						if ($globalDebug) {
3579
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3580
+						}
3112 3581
 						$this->deleteOldStats($filter_name);
3113 3582
 						unset($last_update);
3114 3583
 					}
@@ -3125,39 +3594,55 @@  discard block
 block discarded – undo
3125 3594
 						$reset = true;
3126 3595
 					}
3127 3596
 					// Count by filter
3128
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3597
+					if ($globalDebug) {
3598
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3599
+					}
3129 3600
 					$Spotter = new Spotter($this->db);
3130
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3601
+					if ($globalDebug) {
3602
+						echo 'Count all aircraft types...'."\n";
3603
+					}
3131 3604
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3132 3605
 					foreach ($alldata as $number) {
3133 3606
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3134 3607
 					}
3135
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3608
+					if ($globalDebug) {
3609
+						echo 'Count all airlines...'."\n";
3610
+					}
3136 3611
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3137 3612
 					foreach ($alldata as $number) {
3138 3613
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3139 3614
 					}
3140
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3615
+					if ($globalDebug) {
3616
+						echo 'Count all aircraft registrations...'."\n";
3617
+					}
3141 3618
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3142 3619
 					foreach ($alldata as $number) {
3143 3620
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3144 3621
 					}
3145
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3622
+					if ($globalDebug) {
3623
+						echo 'Count all callsigns...'."\n";
3624
+					}
3146 3625
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3147 3626
 					foreach ($alldata as $number) {
3148 3627
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3149 3628
 					}
3150
-					if ($globalDebug) echo 'Count all owners...'."\n";
3629
+					if ($globalDebug) {
3630
+						echo 'Count all owners...'."\n";
3631
+					}
3151 3632
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3152 3633
 					foreach ($alldata as $number) {
3153 3634
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3154 3635
 					}
3155
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3636
+					if ($globalDebug) {
3637
+						echo 'Count all pilots...'."\n";
3638
+					}
3156 3639
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3157 3640
 					foreach ($alldata as $number) {
3158 3641
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3159 3642
 					}
3160
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3643
+					if ($globalDebug) {
3644
+						echo 'Count departure airports...'."\n";
3645
+					}
3161 3646
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3162 3647
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3163 3648
 					$alldata = array();
@@ -3169,7 +3654,9 @@  discard block
 block discarded – undo
3169 3654
 						$icao = $value['airport_departure_icao'];
3170 3655
 						if (isset($alldata[$icao])) {
3171 3656
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
3172
-						} else $alldata[$icao] = $value;
3657
+						} else {
3658
+							$alldata[$icao] = $value;
3659
+						}
3173 3660
 					}
3174 3661
 					$count = array();
3175 3662
 					foreach ($alldata as $key => $row) {
@@ -3179,7 +3666,9 @@  discard block
 block discarded – undo
3179 3666
 					foreach ($alldata as $number) {
3180 3667
 						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);
3181 3668
 					}
3182
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3669
+					if ($globalDebug) {
3670
+						echo 'Count all arrival airports...'."\n";
3671
+					}
3183 3672
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3184 3673
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3185 3674
 					$alldata = array();
@@ -3191,7 +3680,9 @@  discard block
 block discarded – undo
3191 3680
 						$icao = $value['airport_arrival_icao'];
3192 3681
 						if (isset($alldata[$icao])) {
3193 3682
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
3194
-						} else $alldata[$icao] = $value;
3683
+						} else {
3684
+							$alldata[$icao] = $value;
3685
+						}
3195 3686
 					}
3196 3687
 					$count = array();
3197 3688
 					foreach ($alldata as $key => $row) {
@@ -3201,35 +3692,49 @@  discard block
 block discarded – undo
3201 3692
 					foreach ($alldata as $number) {
3202 3693
 						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);
3203 3694
 					}
3204
-					if ($globalDebug) echo 'Count all months...'."\n";
3695
+					if ($globalDebug) {
3696
+						echo 'Count all months...'."\n";
3697
+					}
3205 3698
 					$Spotter = new Spotter($this->db);
3206 3699
 					$alldata = $Spotter->countAllMonths($filter);
3207 3700
 					$lastyear = false;
3208 3701
 					foreach ($alldata as $number) {
3209
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3702
+						if ($number['year_name'] != date('Y')) {
3703
+							$lastyear = true;
3704
+						}
3210 3705
 						$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);
3211 3706
 					}
3212
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3707
+					if ($globalDebug) {
3708
+						echo 'Count all owners by months...'."\n";
3709
+					}
3213 3710
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3214 3711
 					foreach ($alldata as $number) {
3215 3712
 						$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);
3216 3713
 					}
3217
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3714
+					if ($globalDebug) {
3715
+						echo 'Count all pilots by months...'."\n";
3716
+					}
3218 3717
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3219 3718
 					foreach ($alldata as $number) {
3220 3719
 						$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);
3221 3720
 					}
3222
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3721
+					if ($globalDebug) {
3722
+						echo 'Count all military by months...'."\n";
3723
+					}
3223 3724
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3224 3725
 					foreach ($alldata as $number) {
3225 3726
 						$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);
3226 3727
 					}
3227
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3728
+					if ($globalDebug) {
3729
+						echo 'Count all aircrafts by months...'."\n";
3730
+					}
3228 3731
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3229 3732
 				    	foreach ($alldata as $number) {
3230 3733
 			    			$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);
3231 3734
 					}
3232
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3735
+					if ($globalDebug) {
3736
+						echo 'Count all real arrivals by months...'."\n";
3737
+					}
3233 3738
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3234 3739
 					foreach ($alldata as $number) {
3235 3740
 						$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.
install/class.update_schema.php 1 patch
Braces   +479 added lines, -176 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2255,8 +2407,11 @@  discard block
 block discarded – undo
2255 2407
 			if ($Connection->tableExists('aircraft')) {
2256 2408
 				if (!$Connection->tableExists('config')) {
2257 2409
 					$version = '1';
2258
-					if ($update) return self::update_from_1();
2259
-					else return $version;
2410
+					if ($update) {
2411
+						return self::update_from_1();
2412
+					} else {
2413
+						return $version;
2414
+					}
2260 2415
 				} else {
2261 2416
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2262 2417
 					try {
@@ -2269,199 +2424,347 @@  discard block
 block discarded – undo
2269 2424
 					if ($update) {
2270 2425
 						if ($result['value'] == '2') {
2271 2426
 							$error = self::update_from_2();
2272
-							if ($error != '') return $error;
2273
-							else return self::check_version(true);
2427
+							if ($error != '') {
2428
+								return $error;
2429
+							} else {
2430
+								return self::check_version(true);
2431
+							}
2274 2432
 						} elseif ($result['value'] == '3') {
2275 2433
 							$error = self::update_from_3();
2276
-							if ($error != '') return $error;
2277
-							else return self::check_version(true);
2434
+							if ($error != '') {
2435
+								return $error;
2436
+							} else {
2437
+								return self::check_version(true);
2438
+							}
2278 2439
 						} elseif ($result['value'] == '4') {
2279 2440
 							$error = self::update_from_4();
2280
-							if ($error != '') return $error;
2281
-							else return self::check_version(true);
2441
+							if ($error != '') {
2442
+								return $error;
2443
+							} else {
2444
+								return self::check_version(true);
2445
+							}
2282 2446
 						} elseif ($result['value'] == '5') {
2283 2447
 							$error = self::update_from_5();
2284
-							if ($error != '') return $error;
2285
-							else return self::check_version(true);
2448
+							if ($error != '') {
2449
+								return $error;
2450
+							} else {
2451
+								return self::check_version(true);
2452
+							}
2286 2453
 						} elseif ($result['value'] == '6') {
2287 2454
 							$error = self::update_from_6();
2288
-							if ($error != '') return $error;
2289
-							else return self::check_version(true);
2455
+							if ($error != '') {
2456
+								return $error;
2457
+							} else {
2458
+								return self::check_version(true);
2459
+							}
2290 2460
 						} elseif ($result['value'] == '7') {
2291 2461
 							$error = self::update_from_7();
2292
-							if ($error != '') return $error;
2293
-							else return self::check_version(true);
2462
+							if ($error != '') {
2463
+								return $error;
2464
+							} else {
2465
+								return self::check_version(true);
2466
+							}
2294 2467
 						} elseif ($result['value'] == '8') {
2295 2468
 							$error = self::update_from_8();
2296
-							if ($error != '') return $error;
2297
-							else return self::check_version(true);
2469
+							if ($error != '') {
2470
+								return $error;
2471
+							} else {
2472
+								return self::check_version(true);
2473
+							}
2298 2474
 						} elseif ($result['value'] == '9') {
2299 2475
 							$error = self::update_from_9();
2300
-							if ($error != '') return $error;
2301
-							else return self::check_version(true);
2476
+							if ($error != '') {
2477
+								return $error;
2478
+							} else {
2479
+								return self::check_version(true);
2480
+							}
2302 2481
 						} elseif ($result['value'] == '10') {
2303 2482
 							$error = self::update_from_10();
2304
-							if ($error != '') return $error;
2305
-							else return self::check_version(true);
2483
+							if ($error != '') {
2484
+								return $error;
2485
+							} else {
2486
+								return self::check_version(true);
2487
+							}
2306 2488
 						} elseif ($result['value'] == '11') {
2307 2489
 							$error = self::update_from_11();
2308
-							if ($error != '') return $error;
2309
-							else return self::check_version(true);
2490
+							if ($error != '') {
2491
+								return $error;
2492
+							} else {
2493
+								return self::check_version(true);
2494
+							}
2310 2495
 						} elseif ($result['value'] == '12') {
2311 2496
 							$error = self::update_from_12();
2312
-							if ($error != '') return $error;
2313
-							else return self::check_version(true);
2497
+							if ($error != '') {
2498
+								return $error;
2499
+							} else {
2500
+								return self::check_version(true);
2501
+							}
2314 2502
 						} elseif ($result['value'] == '13') {
2315 2503
 							$error = self::update_from_13();
2316
-							if ($error != '') return $error;
2317
-							else return self::check_version(true);
2504
+							if ($error != '') {
2505
+								return $error;
2506
+							} else {
2507
+								return self::check_version(true);
2508
+							}
2318 2509
 						} elseif ($result['value'] == '14') {
2319 2510
 							$error = self::update_from_14();
2320
-							if ($error != '') return $error;
2321
-							else return self::check_version(true);
2511
+							if ($error != '') {
2512
+								return $error;
2513
+							} else {
2514
+								return self::check_version(true);
2515
+							}
2322 2516
 						} elseif ($result['value'] == '15') {
2323 2517
 							$error = self::update_from_15();
2324
-							if ($error != '') return $error;
2325
-							else return self::check_version(true);
2518
+							if ($error != '') {
2519
+								return $error;
2520
+							} else {
2521
+								return self::check_version(true);
2522
+							}
2326 2523
 						} elseif ($result['value'] == '16') {
2327 2524
 							$error = self::update_from_16();
2328
-							if ($error != '') return $error;
2329
-							else return self::check_version(true);
2525
+							if ($error != '') {
2526
+								return $error;
2527
+							} else {
2528
+								return self::check_version(true);
2529
+							}
2330 2530
 						} elseif ($result['value'] == '17') {
2331 2531
 							$error = self::update_from_17();
2332
-							if ($error != '') return $error;
2333
-							else return self::check_version(true);
2532
+							if ($error != '') {
2533
+								return $error;
2534
+							} else {
2535
+								return self::check_version(true);
2536
+							}
2334 2537
 						} elseif ($result['value'] == '18') {
2335 2538
 							$error = self::update_from_18();
2336
-							if ($error != '') return $error;
2337
-							else return self::check_version(true);
2539
+							if ($error != '') {
2540
+								return $error;
2541
+							} else {
2542
+								return self::check_version(true);
2543
+							}
2338 2544
 						} elseif ($result['value'] == '19') {
2339 2545
 							$error = self::update_from_19();
2340
-							if ($error != '') return $error;
2341
-							else return self::check_version(true);
2546
+							if ($error != '') {
2547
+								return $error;
2548
+							} else {
2549
+								return self::check_version(true);
2550
+							}
2342 2551
 						} elseif ($result['value'] == '20') {
2343 2552
 							$error = self::update_from_20();
2344
-							if ($error != '') return $error;
2345
-							else return self::check_version(true);
2553
+							if ($error != '') {
2554
+								return $error;
2555
+							} else {
2556
+								return self::check_version(true);
2557
+							}
2346 2558
 						} elseif ($result['value'] == '21') {
2347 2559
 							$error = self::update_from_21();
2348
-							if ($error != '') return $error;
2349
-							else return self::check_version(true);
2560
+							if ($error != '') {
2561
+								return $error;
2562
+							} else {
2563
+								return self::check_version(true);
2564
+							}
2350 2565
 						} elseif ($result['value'] == '22') {
2351 2566
 							$error = self::update_from_22();
2352
-							if ($error != '') return $error;
2353
-							else return self::check_version(true);
2567
+							if ($error != '') {
2568
+								return $error;
2569
+							} else {
2570
+								return self::check_version(true);
2571
+							}
2354 2572
 						} elseif ($result['value'] == '23') {
2355 2573
 							$error = self::update_from_23();
2356
-							if ($error != '') return $error;
2357
-							else return self::check_version(true);
2574
+							if ($error != '') {
2575
+								return $error;
2576
+							} else {
2577
+								return self::check_version(true);
2578
+							}
2358 2579
 						} elseif ($result['value'] == '24') {
2359 2580
 							$error = self::update_from_24();
2360
-							if ($error != '') return $error;
2361
-							else return self::check_version(true);
2581
+							if ($error != '') {
2582
+								return $error;
2583
+							} else {
2584
+								return self::check_version(true);
2585
+							}
2362 2586
 						} elseif ($result['value'] == '25') {
2363 2587
 							$error = self::update_from_25();
2364
-							if ($error != '') return $error;
2365
-							else return self::check_version(true);
2588
+							if ($error != '') {
2589
+								return $error;
2590
+							} else {
2591
+								return self::check_version(true);
2592
+							}
2366 2593
 						} elseif ($result['value'] == '26') {
2367 2594
 							$error = self::update_from_26();
2368
-							if ($error != '') return $error;
2369
-							else return self::check_version(true);
2595
+							if ($error != '') {
2596
+								return $error;
2597
+							} else {
2598
+								return self::check_version(true);
2599
+							}
2370 2600
 						} elseif ($result['value'] == '27') {
2371 2601
 							$error = self::update_from_27();
2372
-							if ($error != '') return $error;
2373
-							else return self::check_version(true);
2602
+							if ($error != '') {
2603
+								return $error;
2604
+							} else {
2605
+								return self::check_version(true);
2606
+							}
2374 2607
 						} elseif ($result['value'] == '28') {
2375 2608
 							$error = self::update_from_28();
2376
-							if ($error != '') return $error;
2377
-							else return self::check_version(true);
2609
+							if ($error != '') {
2610
+								return $error;
2611
+							} else {
2612
+								return self::check_version(true);
2613
+							}
2378 2614
 						} elseif ($result['value'] == '29') {
2379 2615
 							$error = self::update_from_29();
2380
-							if ($error != '') return $error;
2381
-							else return self::check_version(true);
2616
+							if ($error != '') {
2617
+								return $error;
2618
+							} else {
2619
+								return self::check_version(true);
2620
+							}
2382 2621
 						} elseif ($result['value'] == '30') {
2383 2622
 							$error = self::update_from_30();
2384
-							if ($error != '') return $error;
2385
-							else return self::check_version(true);
2623
+							if ($error != '') {
2624
+								return $error;
2625
+							} else {
2626
+								return self::check_version(true);
2627
+							}
2386 2628
 						} elseif ($result['value'] == '31') {
2387 2629
 							$error = self::update_from_31();
2388
-							if ($error != '') return $error;
2389
-							else return self::check_version(true);
2630
+							if ($error != '') {
2631
+								return $error;
2632
+							} else {
2633
+								return self::check_version(true);
2634
+							}
2390 2635
 						} elseif ($result['value'] == '32') {
2391 2636
 							$error = self::update_from_32();
2392
-							if ($error != '') return $error;
2393
-							else return self::check_version(true);
2637
+							if ($error != '') {
2638
+								return $error;
2639
+							} else {
2640
+								return self::check_version(true);
2641
+							}
2394 2642
 						} elseif ($result['value'] == '33') {
2395 2643
 							$error = self::update_from_33();
2396
-							if ($error != '') return $error;
2397
-							else return self::check_version(true);
2644
+							if ($error != '') {
2645
+								return $error;
2646
+							} else {
2647
+								return self::check_version(true);
2648
+							}
2398 2649
 						} elseif ($result['value'] == '34') {
2399 2650
 							$error = self::update_from_34();
2400
-							if ($error != '') return $error;
2401
-							else return self::check_version(true);
2651
+							if ($error != '') {
2652
+								return $error;
2653
+							} else {
2654
+								return self::check_version(true);
2655
+							}
2402 2656
 						} elseif ($result['value'] == '35') {
2403 2657
 							$error = self::update_from_35();
2404
-							if ($error != '') return $error;
2405
-							else return self::check_version(true);
2658
+							if ($error != '') {
2659
+								return $error;
2660
+							} else {
2661
+								return self::check_version(true);
2662
+							}
2406 2663
 						} elseif ($result['value'] == '36') {
2407 2664
 							$error = self::update_from_36();
2408
-							if ($error != '') return $error;
2409
-							else return self::check_version(true);
2665
+							if ($error != '') {
2666
+								return $error;
2667
+							} else {
2668
+								return self::check_version(true);
2669
+							}
2410 2670
 						} elseif ($result['value'] == '37') {
2411 2671
 							$error = self::update_from_37();
2412
-							if ($error != '') return $error;
2413
-							else return self::check_version(true);
2672
+							if ($error != '') {
2673
+								return $error;
2674
+							} else {
2675
+								return self::check_version(true);
2676
+							}
2414 2677
 						} elseif ($result['value'] == '38') {
2415 2678
 							$error = self::update_from_38();
2416
-							if ($error != '') return $error;
2417
-							else return self::check_version(true);
2679
+							if ($error != '') {
2680
+								return $error;
2681
+							} else {
2682
+								return self::check_version(true);
2683
+							}
2418 2684
 						} elseif ($result['value'] == '39') {
2419 2685
 							$error = self::update_from_39();
2420
-							if ($error != '') return $error;
2421
-							else return self::check_version(true);
2686
+							if ($error != '') {
2687
+								return $error;
2688
+							} else {
2689
+								return self::check_version(true);
2690
+							}
2422 2691
 						} elseif ($result['value'] == '40') {
2423 2692
 							$error = self::update_from_40();
2424
-							if ($error != '') return $error;
2425
-							else return self::check_version(true);
2693
+							if ($error != '') {
2694
+								return $error;
2695
+							} else {
2696
+								return self::check_version(true);
2697
+							}
2426 2698
 						} elseif ($result['value'] == '41') {
2427 2699
 							$error = self::update_from_41();
2428
-							if ($error != '') return $error;
2429
-							else return self::check_version(true);
2700
+							if ($error != '') {
2701
+								return $error;
2702
+							} else {
2703
+								return self::check_version(true);
2704
+							}
2430 2705
 						} elseif ($result['value'] == '42') {
2431 2706
 							$error = self::update_from_42();
2432
-							if ($error != '') return $error;
2433
-							else return self::check_version(true);
2707
+							if ($error != '') {
2708
+								return $error;
2709
+							} else {
2710
+								return self::check_version(true);
2711
+							}
2434 2712
 						} elseif ($result['value'] == '43') {
2435 2713
 							$error = self::update_from_43();
2436
-							if ($error != '') return $error;
2437
-							else return self::check_version(true);
2714
+							if ($error != '') {
2715
+								return $error;
2716
+							} else {
2717
+								return self::check_version(true);
2718
+							}
2438 2719
 						} elseif ($result['value'] == '44') {
2439 2720
 							$error = self::update_from_44();
2440
-							if ($error != '') return $error;
2441
-							else return self::check_version(true);
2721
+							if ($error != '') {
2722
+								return $error;
2723
+							} else {
2724
+								return self::check_version(true);
2725
+							}
2442 2726
 						} elseif ($result['value'] == '45') {
2443 2727
 							$error = self::update_from_45();
2444
-							if ($error != '') return $error;
2445
-							else return self::check_version(true);
2728
+							if ($error != '') {
2729
+								return $error;
2730
+							} else {
2731
+								return self::check_version(true);
2732
+							}
2446 2733
 						} elseif ($result['value'] == '46') {
2447 2734
 							$error = self::update_from_46();
2448
-							if ($error != '') return $error;
2449
-							else return self::check_version(true);
2735
+							if ($error != '') {
2736
+								return $error;
2737
+							} else {
2738
+								return self::check_version(true);
2739
+							}
2450 2740
 						} elseif ($result['value'] == '47') {
2451 2741
 							$error = self::update_from_47();
2452
-							if ($error != '') return $error;
2453
-							else return self::check_version(true);
2742
+							if ($error != '') {
2743
+								return $error;
2744
+							} else {
2745
+								return self::check_version(true);
2746
+							}
2454 2747
 						} elseif ($result['value'] == '48') {
2455 2748
 							$error = self::update_from_48();
2456
-							if ($error != '') return $error;
2457
-							else return self::check_version(true);
2458
-						} else return '';
2749
+							if ($error != '') {
2750
+								return $error;
2751
+							} else {
2752
+								return self::check_version(true);
2753
+							}
2754
+						} else {
2755
+							return '';
2756
+						}
2459 2757
 					} else {
2460
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2461
-						else return 0;
2758
+						if (isset($result['value']) && $result['value'] != '') {
2759
+							return $result['value'];
2760
+						} else {
2761
+							return 0;
2762
+						}
2462 2763
 					}
2463 2764
 				}
2464
-			} else return $version;
2765
+			} else {
2766
+				return $version;
2767
+			}
2465 2768
 		}
2466 2769
 	}
2467 2770
 }
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -277,8 +302,9 @@  discard block
 block discarded – undo
277 302
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 303
 <?php
279 304
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
-	if (count($tracker_array) == 0) print _("No data available");
281
-	else {
305
+	if (count($tracker_array) == 0) {
306
+		print _("No data available");
307
+	} else {
282 308
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 309
 		$tracker_data = '';
284 310
 		foreach($tracker_array as $tracker_item) {
@@ -322,8 +348,9 @@  discard block
 block discarded – undo
322 348
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323 349
 <?php
324 350
 		$owner_array = $Satellite->countAllOwners(true);
325
-		if (count($owner_array) == 0) print _("No data available");
326
-		else {
351
+		if (count($owner_array) == 0) {
352
+			print _("No data available");
353
+		} else {
327 354
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 355
 			$owner_data = '';
329 356
 			foreach($owner_array as $owner_item) {
@@ -342,7 +369,10 @@  discard block
 block discarded – undo
342 369
 ?>
343 370
                <!--
344 371
                 <div class="more">
345
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
373
+	echo '/'.$airline_icao;
374
+}
375
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
346 376
                 </div>
347 377
                 -->
348 378
             </div>
@@ -351,8 +381,9 @@  discard block
 block discarded – undo
351 381
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 382
 <?php
353 383
 		$countries_array = $Satellite->countAllCountriesOwners(true);
354
-		if (count($countries_array) == 0) print _("No data available");
355
-		else {
384
+		if (count($countries_array) == 0) {
385
+			print _("No data available");
386
+		} else {
356 387
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 388
 			$owner_data = '';
358 389
 			foreach($countries_array as $owner_item) {
@@ -371,7 +402,10 @@  discard block
 block discarded – undo
371 402
 ?>
372 403
 	    <!--
373 404
                 <div class="more">
374
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
405
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
406
+	echo '/'.$airline_icao;
407
+}
408
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
375 409
                 </div>
376 410
                 -->
377 411
             </div>
@@ -383,8 +417,9 @@  discard block
 block discarded – undo
383 417
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384 418
 <?php
385 419
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
-		if (count($launch_site_array) == 0) print _("No data available");
387
-		else {
420
+		if (count($launch_site_array) == 0) {
421
+			print _("No data available");
422
+		} else {
388 423
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 424
 			$launch_site_data = '';
390 425
 			foreach($launch_site_array as $launch_site_item) {
@@ -403,7 +438,10 @@  discard block
 block discarded – undo
403 438
 ?>
404 439
                <!--
405 440
                 <div class="more">
406
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
441
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
442
+	echo '/'.$airline_icao;
443
+}
444
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
407 445
                 </div>
408 446
                 -->
409 447
             </div>
@@ -426,8 +464,9 @@  discard block
 block discarded – undo
426 464
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 465
 <?php
428 466
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
-		if (count($pilot_array) == 0) print _("No data available");
430
-		else {
467
+		if (count($pilot_array) == 0) {
468
+			print _("No data available");
469
+		} else {
431 470
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 471
 			$pilot_data = '';
433 472
 			foreach($pilot_array as $pilot_item) {
@@ -445,7 +484,9 @@  discard block
 block discarded – undo
445 484
 		}
446 485
 		print '<div class="more">';
447 486
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
487
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
488
+			echo '/'.$airline_icao;
489
+		}
449 490
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450 491
 		print '</div>';
451 492
 ?>
@@ -461,8 +502,9 @@  discard block
 block discarded – undo
461 502
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 503
 <?php
463 504
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
-		if (count($owner_array) == 0) print _("No data available");
465
-		else {
505
+		if (count($owner_array) == 0) {
506
+			print _("No data available");
507
+		} else {
466 508
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 509
 			$owner_data = '';
468 510
 			foreach($owner_array as $owner_item) {
@@ -480,7 +522,10 @@  discard block
 block discarded – undo
480 522
 		}
481 523
 ?>
482 524
                 <div class="more">
483
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
526
+	echo '/'.$airline_icao;
527
+}
528
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
484 529
                 </div>
485 530
             </div>
486 531
         
@@ -493,8 +538,9 @@  discard block
 block discarded – undo
493 538
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494 539
 <?php
495 540
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
-		if (count($flightover_array) == 0) print _("No data available");
497
-		else {
541
+		if (count($flightover_array) == 0) {
542
+			print _("No data available");
543
+		} else {
498 544
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 545
 			print 'var series = [';
500 546
 			$flightover_data = '';
@@ -536,7 +582,10 @@  discard block
 block discarded – undo
536 582
 		}
537 583
 ?>
538 584
                 <div class="more">
539
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
585
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
586
+	echo '/'.$airline_icao;
587
+}
588
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
540 589
                 </div>
541 590
             </div>
542 591
 <?php
@@ -554,8 +603,9 @@  discard block
 block discarded – undo
554 603
 	<div class="col-md-6">
555 604
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556 605
 <?php
557
-	if (count($flightover_array) == 0) print _("No data available");
558
-	else {
606
+	if (count($flightover_array) == 0) {
607
+		print _("No data available");
608
+	} else {
559 609
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 610
 		print 'var series = [';
561 611
 		$flightover_data = '';
@@ -612,8 +662,9 @@  discard block
 block discarded – undo
612 662
 	<div class="col-md-6">
613 663
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614 664
 <?php
615
-	if (count($flightover_array) == 0) print _("No data available");
616
-	else {
665
+	if (count($flightover_array) == 0) {
666
+		print _("No data available");
667
+	} else {
617 668
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 669
 		print 'var series = [';
619 670
 		$flightover_data = '';
@@ -719,7 +770,9 @@  discard block
 block discarded – undo
719 770
 		});";
720 771
 		print '</script>';
721 772
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
773
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+			echo '/'.$airline_icao;
775
+		}
723 776
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724 777
 	}
725 778
 ?>
@@ -783,7 +836,9 @@  discard block
 block discarded – undo
783 836
 		});";
784 837
 		print '</script>';
785 838
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
786
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
839
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
840
+			echo '/'.$airline_icao;
841
+		}
787 842
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
788 843
 	}
789 844
 ?>
@@ -802,8 +857,9 @@  discard block
 block discarded – undo
802 857
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
803 858
 <?php
804 859
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
805
-		if (count($year_array) == 0) print _("No data available");
806
-		else {
860
+		if (count($year_array) == 0) {
861
+			print _("No data available");
862
+		} else {
807 863
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
808 864
 			$year_data = '';
809 865
 			$year_cnt = '';
@@ -822,7 +878,10 @@  discard block
 block discarded – undo
822 878
 		}
823 879
 ?>
824 880
                 <div class="more">
825
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
881
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
882
+	echo '/'.$airline_icao;
883
+}
884
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
826 885
                 </div>
827 886
             </div>
828 887
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -830,8 +889,9 @@  discard block
 block discarded – undo
830 889
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
831 890
 <?php
832 891
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
833
-		if (count($month_array) == 0) print _("No data available");
834
-		else {
892
+		if (count($month_array) == 0) {
893
+			print _("No data available");
894
+		} else {
835 895
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
836 896
 			$month_data = '';
837 897
 			$month_cnt = '';
@@ -850,7 +910,10 @@  discard block
 block discarded – undo
850 910
 		}
851 911
 ?>
852 912
                 <div class="more">
853
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
913
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
914
+	echo '/'.$airline_icao;
915
+}
916
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
854 917
                 </div>
855 918
             </div>
856 919
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -859,8 +922,9 @@  discard block
 block discarded – undo
859 922
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
860 923
 <?php
861 924
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
862
-		if (empty($date_array)) print _("No data available");
863
-		else {
925
+		if (empty($date_array)) {
926
+			print _("No data available");
927
+		} else {
864 928
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
865 929
 			$date_data = '';
866 930
 			$date_cnt = '';
@@ -879,7 +943,10 @@  discard block
 block discarded – undo
879 943
 		}
880 944
 ?>
881 945
                 <div class="more">
882
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
946
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
947
+	echo '/'.$airline_icao;
948
+}
949
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
883 950
                 </div>
884 951
             </div>
885 952
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -887,8 +954,9 @@  discard block
 block discarded – undo
887 954
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
888 955
 <?php
889 956
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
890
-		if (empty($hour_array)) print _("No data available");
891
-		else {
957
+		if (empty($hour_array)) {
958
+			print _("No data available");
959
+		} else {
892 960
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
893 961
 			$hour_data = '';
894 962
 			$hour_cnt = '';
@@ -907,7 +975,10 @@  discard block
 block discarded – undo
907 975
 		}
908 976
 ?>
909 977
                 <div class="more">
910
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
978
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
979
+	echo '/'.$airline_icao;
980
+}
981
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911 982
                 </div>
912 983
             </div>
913 984
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -927,8 +998,9 @@  discard block
 block discarded – undo
927 998
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
928 999
 <?php
929 1000
 		$year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name);
930
-		if (count($year_array) == 0) print _("No data available");
931
-		else {
1001
+		if (count($year_array) == 0) {
1002
+			print _("No data available");
1003
+		} else {
932 1004
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
933 1005
 			$year_data = '';
934 1006
 			$year_cnt = '';
@@ -956,8 +1028,9 @@  discard block
 block discarded – undo
956 1028
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
957 1029
 <?php
958 1030
 		$month_array = $Stats->countAllMarineDatesLastMonth($filter_name);
959
-		if (count($month_array) == 0) print _("No data available");
960
-		else {
1031
+		if (count($month_array) == 0) {
1032
+			print _("No data available");
1033
+		} else {
961 1034
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
962 1035
 			$month_data = '';
963 1036
 			$month_cnt = '';
@@ -985,8 +1058,9 @@  discard block
 block discarded – undo
985 1058
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
986 1059
 <?php
987 1060
 		$date_array = $Stats->countAllMarineDatesLast7Days($filter_name);
988
-		if (empty($date_array)) print _("No data available");
989
-		else {
1061
+		if (empty($date_array)) {
1062
+			print _("No data available");
1063
+		} else {
990 1064
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
991 1065
 			$date_data = '';
992 1066
 			$date_cnt = '';
@@ -1013,8 +1087,9 @@  discard block
 block discarded – undo
1013 1087
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1014 1088
 <?php
1015 1089
 		$hour_array = $Stats->countAllMarineHours('hour',true,$filter_name);
1016
-		if (empty($hour_array)) print _("No data available");
1017
-		else {
1090
+		if (empty($hour_array)) {
1091
+			print _("No data available");
1092
+		} else {
1018 1093
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1019 1094
 			$hour_data = '';
1020 1095
 			$hour_cnt = '';
@@ -1053,8 +1128,9 @@  discard block
 block discarded – undo
1053 1128
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1054 1129
 <?php
1055 1130
 		$year_array = $Stats->countAllTrackerMonthsLastYear(true);
1056
-		if (count($year_array) == 0) print _("No data available");
1057
-		else {
1131
+		if (count($year_array) == 0) {
1132
+			print _("No data available");
1133
+		} else {
1058 1134
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1059 1135
 			$year_data = '';
1060 1136
 			$year_cnt = '';
@@ -1082,8 +1158,9 @@  discard block
 block discarded – undo
1082 1158
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1083 1159
 <?php
1084 1160
 		$month_array = $Stats->countAllTrackerDatesLastMonth();
1085
-		if (count($month_array) == 0) print _("No data available");
1086
-		else {
1161
+		if (count($month_array) == 0) {
1162
+			print _("No data available");
1163
+		} else {
1087 1164
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1088 1165
 			$month_data = '';
1089 1166
 			$month_cnt = '';
@@ -1111,8 +1188,9 @@  discard block
 block discarded – undo
1111 1188
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1112 1189
 <?php
1113 1190
 		$date_array = $Stats->countAllTrackerDatesLast7Days();
1114
-		if (empty($date_array)) print _("No data available");
1115
-		else {
1191
+		if (empty($date_array)) {
1192
+			print _("No data available");
1193
+		} else {
1116 1194
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1117 1195
 			$date_data = '';
1118 1196
 			$date_cnt = '';
@@ -1139,8 +1217,9 @@  discard block
 block discarded – undo
1139 1217
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1140 1218
 <?php
1141 1219
 		$hour_array = $Stats->countAllTrackerHours('hour',true);
1142
-		if (empty($hour_array)) print _("No data available");
1143
-		else {
1220
+		if (empty($hour_array)) {
1221
+			print _("No data available");
1222
+		} else {
1144 1223
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1145 1224
 			$hour_data = '';
1146 1225
 			$hour_cnt = '';
@@ -1179,8 +1258,9 @@  discard block
 block discarded – undo
1179 1258
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1180 1259
 <?php
1181 1260
 		$year_array = $Satellite->countAllMonthsLastYear();
1182
-		if (count($year_array) == 0) print _("No data available");
1183
-		else {
1261
+		if (count($year_array) == 0) {
1262
+			print _("No data available");
1263
+		} else {
1184 1264
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1185 1265
 			$year_data = '';
1186 1266
 			$year_cnt = '';
@@ -1210,8 +1290,9 @@  discard block
 block discarded – undo
1210 1290
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1211 1291
 <?php
1212 1292
 		$year_array = $Satellite->countAllYears();
1213
-		if (count($year_array) == 0) print _("No data available");
1214
-		else {
1293
+		if (count($year_array) == 0) {
1294
+			print _("No data available");
1295
+		} else {
1215 1296
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1216 1297
 			$year_data = '';
1217 1298
 			$year_cnt = '';
@@ -1253,8 +1334,9 @@  discard block
 block discarded – undo
1253 1334
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1254 1335
 <?php
1255 1336
 		$year_array = $Stats->countFatalitiesByYear();
1256
-		if (count($year_array) == 0) print _("No data available");
1257
-		else {
1337
+		if (count($year_array) == 0) {
1338
+			print _("No data available");
1339
+		} else {
1258 1340
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1259 1341
 			$year_data = '';
1260 1342
 			$year_cnt = '';
@@ -1283,8 +1365,9 @@  discard block
 block discarded – undo
1283 1365
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1284 1366
 <?php
1285 1367
 		$year_array = $Stats->countFatalitiesLast12Months();
1286
-		if (count($year_array) == 0) print _("No data available");
1287
-		else {
1368
+		if (count($year_array) == 0) {
1369
+			print _("No data available");
1370
+		} else {
1288 1371
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1289 1372
 			$year_data = '';
1290 1373
 			$year_cnt = '';
@@ -1355,8 +1438,11 @@  discard block
 block discarded – undo
1355 1438
 					$distance = $distance;
1356 1439
 					$unit = 'km';
1357 1440
 				}
1358
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1359
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1441
+				if (!isset($polar_data)) {
1442
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1443
+				} else {
1444
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1445
+				}
1360 1446
 			}
1361 1447
 ?>
1362 1448
             <div class="col-md-6">
@@ -1420,9 +1506,12 @@  discard block
 block discarded – undo
1420 1506
 		foreach ($msg as $eachmsg) {
1421 1507
 			//$eachmsg = $msg[0];
1422 1508
 			$data = $eachmsg['source_data'];
1423
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1424
-			else $max = 500;
1425
-?>
1509
+			if ($data > 500) {
1510
+				$max = (round(($data+100)/100))*100;
1511
+			} else {
1512
+				$max = 500;
1513
+			}
1514
+			?>
1426 1515
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1427 1516
         	<script>
1428 1517
 		      var g = new JustGage({
Please login to merge, or discard this patch.