Completed
Push — master ( 34a40a...b282d7 )
by Yannick
06:06
created
require/class.Stats.php 1 patch
Braces   +449 added lines, -155 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
160
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
175
+			if ($limit) {
176
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
177
+			} else {
178
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
208
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
237
+			if ($limit) {
238
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
239
+			} else {
240
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,10 +321,15 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
280
-			else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
328
+			if ($limit) {
329
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
330
+			} else {
331
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
332
+			}
281 333
 			try {
282 334
 				$sth = $this->db->prepare($query);
283 335
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -285,7 +337,9 @@  discard block
 block discarded – undo
285 337
 				echo "error : ".$e->getMessage();
286 338
 			}
287 339
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-		} else $all = array();
340
+		} else {
341
+			$all = array();
342
+		}
289 343
                 if (empty($all)) {
290 344
 	                $Spotter = new Spotter($this->db);
291 345
             		$filters = array();
@@ -299,10 +353,15 @@  discard block
 block discarded – undo
299 353
 	}
300 354
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 355
 		global $globalStatsFilters;
302
-		if ($filter_name == '') $filter_name = $this->filter_name;
356
+		if ($filter_name == '') {
357
+			$filter_name = $this->filter_name;
358
+		}
303 359
 		if ($year == '' && $month == '') {
304
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
305
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
360
+			if ($limit) {
361
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
362
+			} else {
363
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
364
+			}
306 365
 			try {
307 366
 				$sth = $this->db->prepare($query);
308 367
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -310,7 +369,9 @@  discard block
 block discarded – undo
310 369
 				echo "error : ".$e->getMessage();
311 370
 			}
312 371
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313
-		} else $all = array();
372
+		} else {
373
+			$all = array();
374
+		}
314 375
                 if (empty($all)) {
315 376
 			$filters = array('airlines' => array($stats_airline));
316 377
 			if ($filter_name != '') {
@@ -323,10 +384,15 @@  discard block
 block discarded – undo
323 384
 	}
324 385
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 386
 		global $globalStatsFilters;
326
-		if ($filter_name == '') $filter_name = $this->filter_name;
387
+		if ($filter_name == '') {
388
+			$filter_name = $this->filter_name;
389
+		}
327 390
 		if ($year == '' && $month == '') {
328
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
329
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
391
+			if ($limit) {
392
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
393
+			} else {
394
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
395
+			}
330 396
 			 try {
331 397
 				$sth = $this->db->prepare($query);
332 398
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -334,7 +400,9 @@  discard block
 block discarded – undo
334 400
 				echo "error : ".$e->getMessage();
335 401
 			}
336 402
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
337
-		} else $all = array();
403
+		} else {
404
+			$all = array();
405
+		}
338 406
 		if (empty($all)) {
339 407
 			$filters = array('airlines' => array($stats_airline));
340 408
 			if ($filter_name != '') {
@@ -347,11 +415,16 @@  discard block
 block discarded – undo
347 415
 	}
348 416
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
349 417
 		$Connection = new Connection();
350
-		if ($filter_name == '') $filter_name = $this->filter_name;
418
+		if ($filter_name == '') {
419
+			$filter_name = $this->filter_name;
420
+		}
351 421
 		if ($Connection->tableExists('countries')) {
352 422
 			if ($year == '' && $month == '') {
353
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
354
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
423
+				if ($limit) {
424
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
425
+				} else {
426
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
427
+				}
355 428
 				 try {
356 429
 					$sth = $this->db->prepare($query);
357 430
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -366,17 +439,24 @@  discard block
 block discarded – undo
366 439
                 }
367 440
                 */
368 441
 				return $all;
369
-			} else return array();
442
+			} else {
443
+				return array();
444
+			}
370 445
 		} else {
371 446
 			return array();
372 447
 		}
373 448
 	}
374 449
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
375 450
 		global $globalStatsFilters;
376
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
377 454
 		if ($year == '' && $month == '') {
378
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
379
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
455
+			if ($limit) {
456
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
457
+			} else {
458
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
459
+			}
380 460
 			try {
381 461
 				$sth = $this->db->prepare($query);
382 462
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -384,7 +464,9 @@  discard block
 block discarded – undo
384 464
 				echo "error : ".$e->getMessage();
385 465
 			}
386 466
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
387
-		} else $all = array();
467
+		} else {
468
+			$all = array();
469
+		}
388 470
 		if (empty($all)) {
389 471
 			$filters = array('airlines' => array($stats_airline));
390 472
 			if ($filter_name != '') {
@@ -398,10 +480,15 @@  discard block
 block discarded – undo
398 480
 
399 481
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
400 482
 		global $globalStatsFilters;
401
-		if ($filter_name == '') $filter_name = $this->filter_name;
483
+		if ($filter_name == '') {
484
+			$filter_name = $this->filter_name;
485
+		}
402 486
 		if ($year == '' && $month == '') {
403
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
404
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
487
+			if ($limit) {
488
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
489
+			} else {
490
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
491
+			}
405 492
 			try {
406 493
 				$sth = $this->db->prepare($query);
407 494
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -409,7 +496,9 @@  discard block
 block discarded – undo
409 496
 				echo "error : ".$e->getMessage();
410 497
 			}
411 498
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412
-		} else $all = array();
499
+		} else {
500
+			$all = array();
501
+		}
413 502
                 if (empty($all)) {
414 503
 			$filters = array('airlines' => array($stats_airline));
415 504
 			if ($filter_name != '') {
@@ -422,10 +511,15 @@  discard block
 block discarded – undo
422 511
 	}
423 512
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 513
 		global $globalStatsFilters;
425
-		if ($filter_name == '') $filter_name = $this->filter_name;
514
+		if ($filter_name == '') {
515
+			$filter_name = $this->filter_name;
516
+		}
426 517
 		if ($year == '' && $month == '') {
427
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
428
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
518
+			if ($limit) {
519
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
520
+			} else {
521
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
522
+			}
429 523
 			try {
430 524
 				$sth = $this->db->prepare($query);
431 525
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -433,7 +527,9 @@  discard block
 block discarded – undo
433 527
 				echo "error : ".$e->getMessage();
434 528
 			}
435 529
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436
-		} else $all = array();
530
+		} else {
531
+			$all = array();
532
+		}
437 533
                 if (empty($all)) {
438 534
 			$filters = array('airlines' => array($stats_airline));
439 535
             		if ($filter_name != '') {
@@ -452,7 +548,9 @@  discard block
 block discarded – undo
452 548
         			$icao = $value['airport_departure_icao'];
453 549
         			if (isset($all[$icao])) {
454 550
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
551
+        			} else {
552
+        				$all[$icao] = $value;
553
+        			}
456 554
         		}
457 555
         		$count = array();
458 556
         		foreach ($all as $key => $row) {
@@ -464,10 +562,15 @@  discard block
 block discarded – undo
464 562
 	}
465 563
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 564
 		global $globalStatsFilters;
467
-		if ($filter_name == '') $filter_name = $this->filter_name;
565
+		if ($filter_name == '') {
566
+			$filter_name = $this->filter_name;
567
+		}
468 568
 		if ($year == '' && $month == '') {
469
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
470
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
569
+			if ($limit) {
570
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
571
+			} else {
572
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
573
+			}
471 574
 			try {
472 575
 				$sth = $this->db->prepare($query);
473 576
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -475,7 +578,9 @@  discard block
 block discarded – undo
475 578
 				echo "error : ".$e->getMessage();
476 579
 			}
477 580
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
478
-		} else $all = array();
581
+		} else {
582
+			$all = array();
583
+		}
479 584
 		if (empty($all)) {
480 585
 			$filters = array('airlines' => array($stats_airline));
481 586
 			if ($filter_name != '') {
@@ -494,7 +599,9 @@  discard block
 block discarded – undo
494 599
         			$icao = $value['airport_arrival_icao'];
495 600
         			if (isset($all[$icao])) {
496 601
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
602
+        			} else {
603
+        				$all[$icao] = $value;
604
+        			}
498 605
         		}
499 606
         		$count = array();
500 607
         		foreach ($all as $key => $row) {
@@ -507,13 +614,21 @@  discard block
 block discarded – undo
507 614
 	}
508 615
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 616
 		global $globalDBdriver, $globalStatsFilters;
510
-		if ($filter_name == '') $filter_name = $this->filter_name;
617
+		if ($filter_name == '') {
618
+			$filter_name = $this->filter_name;
619
+		}
511 620
 		if ($globalDBdriver == 'mysql') {
512
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
513
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
621
+			if ($limit) {
622
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
623
+			} else {
624
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
625
+			}
514 626
 		} else {
515
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
627
+			if ($limit) {
628
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
629
+			} else {
630
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
631
+			}
517 632
 		}
518 633
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519 634
                  try {
@@ -537,7 +652,9 @@  discard block
 block discarded – undo
537 652
 	
538 653
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
539 654
 		global $globalStatsFilters;
540
-		if ($filter_name == '') $filter_name = $this->filter_name;
655
+		if ($filter_name == '') {
656
+			$filter_name = $this->filter_name;
657
+		}
541 658
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542 659
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543 660
                  try {
@@ -559,7 +676,9 @@  discard block
 block discarded – undo
559 676
 	}
560 677
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 678
 		global $globalDBdriver, $globalStatsFilters;
562
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
563 682
 		if ($globalDBdriver == 'mysql') {
564 683
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
565 684
 		} else {
@@ -585,7 +704,9 @@  discard block
 block discarded – undo
585 704
 	}
586 705
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 706
 		global $globalStatsFilters;
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
+		if ($filter_name == '') {
708
+			$filter_name = $this->filter_name;
709
+		}
589 710
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590 711
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591 712
                  try {
@@ -607,7 +728,9 @@  discard block
 block discarded – undo
607 728
 	}
608 729
 	public function countAllDatesByAirlines($filter_name = '') {
609 730
 		global $globalStatsFilters;
610
-		if ($filter_name == '') $filter_name = $this->filter_name;
731
+		if ($filter_name == '') {
732
+			$filter_name = $this->filter_name;
733
+		}
611 734
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
612 735
 		$query_data = array('filter_name' => $filter_name);
613 736
                  try {
@@ -629,7 +752,9 @@  discard block
 block discarded – undo
629 752
 	}
630 753
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 754
 		global $globalStatsFilters;
632
-		if ($filter_name == '') $filter_name = $this->filter_name;
755
+		if ($filter_name == '') {
756
+			$filter_name = $this->filter_name;
757
+		}
633 758
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 759
                  try {
635 760
                         $sth = $this->db->prepare($query);
@@ -652,7 +777,9 @@  discard block
 block discarded – undo
652 777
 	}
653 778
 	public function countAllMilitaryMonths($filter_name = '') {
654 779
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
656 783
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
657 784
                  try {
658 785
                         $sth = $this->db->prepare($query);
@@ -673,9 +800,14 @@  discard block
 block discarded – undo
673 800
 	}
674 801
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 802
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676
-		if ($filter_name == '') $filter_name = $this->filter_name;
677
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
678
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
+		if ($filter_name == '') {
804
+			$filter_name = $this->filter_name;
805
+		}
806
+		if ($limit) {
807
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
808
+		} else {
809
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
810
+		}
679 811
 		if ($orderby == 'hour') {
680 812
 			/*
681 813
 			if ($globalDBdriver == 'mysql') {
@@ -684,7 +816,9 @@  discard block
 block discarded – undo
684 816
 			*/
685 817
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 818
 		}
687
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
819
+		if ($orderby == 'count') {
820
+			$query .= " ORDER BY hour_count DESC";
821
+		}
688 822
                  try {
689 823
                         $sth = $this->db->prepare($query);
690 824
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -705,8 +839,12 @@  discard block
 block discarded – undo
705 839
 	
706 840
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
707 841
 		global $globalStatsFilters;
708
-		if ($filter_name == '') $filter_name = $this->filter_name;
709
-		if ($year == '') $year = date('Y');
842
+		if ($filter_name == '') {
843
+			$filter_name = $this->filter_name;
844
+		}
845
+		if ($year == '') {
846
+			$year = date('Y');
847
+		}
710 848
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
711 849
 		if (empty($all)) {
712 850
 			$filters = array('airlines' => array($stats_airline));
@@ -720,8 +858,12 @@  discard block
 block discarded – undo
720 858
 	}
721 859
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
722 860
 		global $globalStatsFilters;
723
-		if ($filter_name == '') $filter_name = $this->filter_name;
724
-		if ($year == '') $year = date('Y');
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
864
+		if ($year == '') {
865
+			$year = date('Y');
866
+		}
725 867
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 868
 		if (empty($all)) {
727 869
 		        $filters = array();
@@ -735,8 +877,12 @@  discard block
 block discarded – undo
735 877
 	}
736 878
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
737 879
 		global $globalStatsFilters;
738
-		if ($filter_name == '') $filter_name = $this->filter_name;
739
-		if ($year == '') $year = date('Y');
880
+		if ($filter_name == '') {
881
+			$filter_name = $this->filter_name;
882
+		}
883
+		if ($year == '') {
884
+			$year = date('Y');
885
+		}
740 886
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
741 887
 		if (empty($all)) {
742 888
 			$filters = array('airlines' => array($stats_airline));
@@ -750,7 +896,9 @@  discard block
 block discarded – undo
750 896
 	}
751 897
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
752 898
 		global $globalStatsFilters;
753
-		if ($filter_name == '') $filter_name = $this->filter_name;
899
+		if ($filter_name == '') {
900
+			$filter_name = $this->filter_name;
901
+		}
754 902
 		if ($year == '' && $month == '') {
755 903
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
756 904
 			try {
@@ -761,7 +909,9 @@  discard block
 block discarded – undo
761 909
 			}
762 910
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
763 911
 			$all = $result[0]['nb'];
764
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
912
+		} else {
913
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
914
+		}
765 915
 		if (empty($all)) {
766 916
 			$filters = array('airlines' => array($stats_airline));
767 917
 			if ($filter_name != '') {
@@ -774,7 +924,9 @@  discard block
 block discarded – undo
774 924
 	}
775 925
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
776 926
 		global $globalStatsFilters;
777
-		if ($filter_name == '') $filter_name = $this->filter_name;
927
+		if ($filter_name == '') {
928
+			$filter_name = $this->filter_name;
929
+		}
778 930
 		if ($year == '' && $month == '') {
779 931
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
780 932
 			try {
@@ -785,7 +937,9 @@  discard block
 block discarded – undo
785 937
 			}
786 938
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
787 939
 			$all = $result[0]['nb_airline'];
788
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
940
+		} else {
941
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
942
+		}
789 943
 		if (empty($all)) {
790 944
             		$filters = array();
791 945
             		if ($filter_name != '') {
@@ -798,7 +952,9 @@  discard block
 block discarded – undo
798 952
 	}
799 953
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
800 954
 		global $globalStatsFilters;
801
-		if ($filter_name == '') $filter_name = $this->filter_name;
955
+		if ($filter_name == '') {
956
+			$filter_name = $this->filter_name;
957
+		}
802 958
 		if ($year == '' && $month == '') {
803 959
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
804 960
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -825,7 +981,9 @@  discard block
 block discarded – undo
825 981
 	}
826 982
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
827 983
 		global $globalStatsFilters;
828
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
829 987
 		//if ($year == '') $year = date('Y');
830 988
 		if ($year == '' && $month == '') {
831 989
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -853,7 +1011,9 @@  discard block
 block discarded – undo
853 1011
 	}
854 1012
 
855 1013
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
856
-		if ($filter_name == '') $filter_name = $this->filter_name;
1014
+		if ($filter_name == '') {
1015
+			$filter_name = $this->filter_name;
1016
+		}
857 1017
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
858 1018
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859 1019
                  try {
@@ -866,7 +1026,9 @@  discard block
 block discarded – undo
866 1026
                 return $all;
867 1027
 	}
868 1028
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1029
+		if ($filter_name == '') {
1030
+			$filter_name = $this->filter_name;
1031
+		}
870 1032
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871 1033
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872 1034
                  try {
@@ -879,7 +1041,9 @@  discard block
 block discarded – undo
879 1041
                 return $all;
880 1042
         }
881 1043
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882
-		if ($filter_name == '') $filter_name = $this->filter_name;
1044
+		if ($filter_name == '') {
1045
+			$filter_name = $this->filter_name;
1046
+		}
883 1047
     		global $globalArchiveMonths, $globalDBdriver;
884 1048
     		if ($globalDBdriver == 'mysql') {
885 1049
     			if ($month == '') {
@@ -909,7 +1073,9 @@  discard block
 block discarded – undo
909 1073
         }
910 1074
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911 1075
     		global $globalArchiveMonths, $globalDBdriver;
912
-		if ($filter_name == '') $filter_name = $this->filter_name;
1076
+		if ($filter_name == '') {
1077
+			$filter_name = $this->filter_name;
1078
+		}
913 1079
     		if ($globalDBdriver == 'mysql') {
914 1080
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
915 1081
 		} else {
@@ -927,7 +1093,9 @@  discard block
 block discarded – undo
927 1093
         }
928 1094
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929 1095
     		global $globalArchiveMonths, $globalDBdriver;
930
-		if ($filter_name == '') $filter_name = $this->filter_name;
1096
+		if ($filter_name == '') {
1097
+			$filter_name = $this->filter_name;
1098
+		}
931 1099
     		if ($globalDBdriver == 'mysql') {
932 1100
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933 1101
                 } else {
@@ -944,7 +1112,9 @@  discard block
 block discarded – undo
944 1112
         }
945 1113
 	public function getStatsAirlineTotal($filter_name = '') {
946 1114
     		global $globalArchiveMonths, $globalDBdriver;
947
-		if ($filter_name == '') $filter_name = $this->filter_name;
1115
+		if ($filter_name == '') {
1116
+			$filter_name = $this->filter_name;
1117
+		}
948 1118
     		if ($globalDBdriver == 'mysql') {
949 1119
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950 1120
                 } else {
@@ -961,7 +1131,9 @@  discard block
 block discarded – undo
961 1131
         }
962 1132
 	public function getStatsOwnerTotal($filter_name = '') {
963 1133
     		global $globalArchiveMonths, $globalDBdriver;
964
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
965 1137
     		if ($globalDBdriver == 'mysql') {
966 1138
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 1139
 		} else {
@@ -978,7 +1150,9 @@  discard block
 block discarded – undo
978 1150
         }
979 1151
 	public function getStatsPilotTotal($filter_name = '') {
980 1152
     		global $globalArchiveMonths, $globalDBdriver;
981
-		if ($filter_name == '') $filter_name = $this->filter_name;
1153
+		if ($filter_name == '') {
1154
+			$filter_name = $this->filter_name;
1155
+		}
982 1156
     		if ($globalDBdriver == 'mysql') {
983 1157
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
984 1158
             	} else {
@@ -996,7 +1170,9 @@  discard block
 block discarded – undo
996 1170
 
997 1171
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
998 1172
 		global $globalDBdriver;
999
-		if ($filter_name == '') $filter_name = $this->filter_name;
1173
+		if ($filter_name == '') {
1174
+			$filter_name = $this->filter_name;
1175
+		}
1000 1176
 		if ($globalDBdriver == 'mysql') {
1001 1177
 			$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";
1002 1178
                 } else {
@@ -1012,7 +1188,9 @@  discard block
 block discarded – undo
1012 1188
         }
1013 1189
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1014 1190
 		global $globalDBdriver;
1015
-		if ($filter_name == '') $filter_name = $this->filter_name;
1191
+		if ($filter_name == '') {
1192
+			$filter_name = $this->filter_name;
1193
+		}
1016 1194
 		if ($globalDBdriver == 'mysql') {
1017 1195
 			$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";
1018 1196
 		} else {
@@ -1398,10 +1576,14 @@  discard block
 block discarded – undo
1398 1576
     		$Connection = new Connection();
1399 1577
     		date_default_timezone_set('UTC');
1400 1578
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1401
-			if ($globalDebug) echo 'Update stats !'."\n";
1579
+			if ($globalDebug) {
1580
+				echo 'Update stats !'."\n";
1581
+			}
1402 1582
 			if (isset($last_update[0]['value'])) {
1403 1583
 				$last_update_day = $last_update[0]['value'];
1404
-			} else $last_update_day = '2012-12-12 12:12:12';
1584
+			} else {
1585
+				$last_update_day = '2012-12-12 12:12:12';
1586
+			}
1405 1587
 			$reset = false;
1406 1588
 			if ($globalStatsResetYear) {
1407 1589
 				$reset = true;
@@ -1409,42 +1591,60 @@  discard block
 block discarded – undo
1409 1591
 			}
1410 1592
 			$Spotter = new Spotter($this->db);
1411 1593
 
1412
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1594
+			if ($globalDebug) {
1595
+				echo 'Count all aircraft types...'."\n";
1596
+			}
1413 1597
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1414 1598
 			foreach ($alldata as $number) {
1415 1599
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1416 1600
 			}
1417
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1601
+			if ($globalDebug) {
1602
+				echo 'Count all airlines...'."\n";
1603
+			}
1418 1604
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1419 1605
 			foreach ($alldata as $number) {
1420 1606
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1421 1607
 			}
1422
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1608
+			if ($globalDebug) {
1609
+				echo 'Count all registrations...'."\n";
1610
+			}
1423 1611
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1424 1612
 			foreach ($alldata as $number) {
1425 1613
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1426 1614
 			}
1427
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1615
+			if ($globalDebug) {
1616
+				echo 'Count all callsigns...'."\n";
1617
+			}
1428 1618
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1429 1619
 			foreach ($alldata as $number) {
1430 1620
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1431 1621
 			}
1432
-			if ($globalDebug) echo 'Count all owners...'."\n";
1622
+			if ($globalDebug) {
1623
+				echo 'Count all owners...'."\n";
1624
+			}
1433 1625
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1434 1626
 			foreach ($alldata as $number) {
1435 1627
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1436 1628
 			}
1437
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1629
+			if ($globalDebug) {
1630
+				echo 'Count all pilots...'."\n";
1631
+			}
1438 1632
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1439 1633
 			foreach ($alldata as $number) {
1440 1634
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1441 1635
 			}
1442 1636
 			
1443
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1637
+			if ($globalDebug) {
1638
+				echo 'Count all departure airports...'."\n";
1639
+			}
1444 1640
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1445
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1641
+			if ($globalDebug) {
1642
+				echo 'Count all detected departure airports...'."\n";
1643
+			}
1446 1644
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1447
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1645
+			if ($globalDebug) {
1646
+				echo 'Order departure airports...'."\n";
1647
+			}
1448 1648
 	        	$alldata = array();
1449 1649
 	        	
1450 1650
     			foreach ($pall as $value) {
@@ -1455,7 +1655,9 @@  discard block
 block discarded – undo
1455 1655
     				$icao = $value['airport_departure_icao'];
1456 1656
         			if (isset($alldata[$icao])) {
1457 1657
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1458
-        			} else $alldata[$icao] = $value;
1658
+        			} else {
1659
+        				$alldata[$icao] = $value;
1660
+        			}
1459 1661
 			}
1460 1662
     			$count = array();
1461 1663
     			foreach ($alldata as $key => $row) {
@@ -1465,11 +1667,17 @@  discard block
 block discarded – undo
1465 1667
 			foreach ($alldata as $number) {
1466 1668
 				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);
1467 1669
 			}
1468
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1670
+			if ($globalDebug) {
1671
+				echo 'Count all arrival airports...'."\n";
1672
+			}
1469 1673
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1470
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1674
+			if ($globalDebug) {
1675
+				echo 'Count all detected arrival airports...'."\n";
1676
+			}
1471 1677
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1472
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1678
+			if ($globalDebug) {
1679
+				echo 'Order arrival airports...'."\n";
1680
+			}
1473 1681
 	        	$alldata = array();
1474 1682
     			foreach ($pall as $value) {
1475 1683
 	        		$icao = $value['airport_arrival_icao'];
@@ -1479,7 +1687,9 @@  discard block
 block discarded – undo
1479 1687
     				$icao = $value['airport_arrival_icao'];
1480 1688
         			if (isset($alldata[$icao])) {
1481 1689
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1482
-	        		} else $alldata[$icao] = $value;
1690
+	        		} else {
1691
+	        			$alldata[$icao] = $value;
1692
+	        		}
1483 1693
     			}
1484 1694
         		$count = array();
1485 1695
         		foreach ($alldata as $key => $row) {
@@ -1490,7 +1700,9 @@  discard block
 block discarded – undo
1490 1700
 				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);
1491 1701
 			}
1492 1702
 			if ($Connection->tableExists('countries')) {
1493
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1703
+				if ($globalDebug) {
1704
+					echo 'Count all flights by countries...'."\n";
1705
+				}
1494 1706
 				$SpotterArchive = new SpotterArchive();
1495 1707
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1496 1708
 				foreach ($alldata as $number) {
@@ -1502,46 +1714,66 @@  discard block
 block discarded – undo
1502 1714
 			// Add by month using getstat if month finish...
1503 1715
 
1504 1716
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1505
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1717
+			if ($globalDebug) {
1718
+				echo 'Count all flights by months...'."\n";
1719
+			}
1506 1720
 			$Spotter = new Spotter($this->db);
1507 1721
 			$alldata = $Spotter->countAllMonths();
1508 1722
 			$lastyear = false;
1509 1723
 			foreach ($alldata as $number) {
1510
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1724
+				if ($number['year_name'] != date('Y')) {
1725
+					$lastyear = true;
1726
+				}
1511 1727
 				$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'])));
1512 1728
 			}
1513
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1729
+			if ($globalDebug) {
1730
+				echo 'Count all military flights by months...'."\n";
1731
+			}
1514 1732
 			$alldata = $Spotter->countAllMilitaryMonths();
1515 1733
 			foreach ($alldata as $number) {
1516 1734
 				$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'])));
1517 1735
 			}
1518
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1736
+			if ($globalDebug) {
1737
+				echo 'Count all owners by months...'."\n";
1738
+			}
1519 1739
 			$alldata = $Spotter->countAllMonthsOwners();
1520 1740
 			foreach ($alldata as $number) {
1521 1741
 				$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'])));
1522 1742
 			}
1523
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1743
+			if ($globalDebug) {
1744
+				echo 'Count all pilots by months...'."\n";
1745
+			}
1524 1746
 			$alldata = $Spotter->countAllMonthsPilots();
1525 1747
 			foreach ($alldata as $number) {
1526 1748
 				$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'])));
1527 1749
 			}
1528
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1750
+			if ($globalDebug) {
1751
+				echo 'Count all airlines by months...'."\n";
1752
+			}
1529 1753
 			$alldata = $Spotter->countAllMonthsAirlines();
1530 1754
 			foreach ($alldata as $number) {
1531 1755
 				$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'])));
1532 1756
 			}
1533
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1757
+			if ($globalDebug) {
1758
+				echo 'Count all aircrafts by months...'."\n";
1759
+			}
1534 1760
 			$alldata = $Spotter->countAllMonthsAircrafts();
1535 1761
 			foreach ($alldata as $number) {
1536 1762
 				$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'])));
1537 1763
 			}
1538
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1764
+			if ($globalDebug) {
1765
+				echo 'Count all real arrivals by months...'."\n";
1766
+			}
1539 1767
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1540 1768
 			foreach ($alldata as $number) {
1541 1769
 				$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'])));
1542 1770
 			}
1543
-			if ($globalDebug) echo 'Airports data...'."\n";
1544
-			if ($globalDebug) echo '...Departure'."\n";
1771
+			if ($globalDebug) {
1772
+				echo 'Airports data...'."\n";
1773
+			}
1774
+			if ($globalDebug) {
1775
+				echo '...Departure'."\n";
1776
+			}
1545 1777
 			$this->deleteStatAirport('daily');
1546 1778
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1547 1779
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1662,44 +1894,62 @@  discard block
 block discarded – undo
1662 1894
 			// Count by airlines
1663 1895
 			echo '--- Stats by airlines ---'."\n";
1664 1896
 			if ($Connection->tableExists('countries')) {
1665
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1897
+				if ($globalDebug) {
1898
+					echo 'Count all flights by countries by airlines...'."\n";
1899
+				}
1666 1900
 				$SpotterArchive = new SpotterArchive();
1667 1901
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1668 1902
 				foreach ($alldata as $number) {
1669 1903
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1670 1904
 				}
1671 1905
 			}
1672
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1906
+			if ($globalDebug) {
1907
+				echo 'Count all aircraft types by airlines...'."\n";
1908
+			}
1673 1909
 			$Spotter = new Spotter($this->db);
1674 1910
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1675 1911
 			foreach ($alldata as $number) {
1676 1912
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1677 1913
 			}
1678
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1914
+			if ($globalDebug) {
1915
+				echo 'Count all aircraft registrations by airlines...'."\n";
1916
+			}
1679 1917
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1680 1918
 			foreach ($alldata as $number) {
1681 1919
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1682 1920
 			}
1683
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1921
+			if ($globalDebug) {
1922
+				echo 'Count all callsigns by airlines...'."\n";
1923
+			}
1684 1924
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1685 1925
 			foreach ($alldata as $number) {
1686 1926
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1687 1927
 			}
1688
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1928
+			if ($globalDebug) {
1929
+				echo 'Count all owners by airlines...'."\n";
1930
+			}
1689 1931
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1690 1932
 			foreach ($alldata as $number) {
1691 1933
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1692 1934
 			}
1693
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo 'Count all pilots by airlines...'."\n";
1937
+			}
1694 1938
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1695 1939
 			foreach ($alldata as $number) {
1696 1940
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1697 1941
 			}
1698
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1942
+			if ($globalDebug) {
1943
+				echo 'Count all departure airports by airlines...'."\n";
1944
+			}
1699 1945
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1700
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1946
+			if ($globalDebug) {
1947
+				echo 'Count all detected departure airports by airlines...'."\n";
1948
+			}
1701 1949
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1702
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1950
+			if ($globalDebug) {
1951
+				echo 'Order detected departure airports by airlines...'."\n";
1952
+			}
1703 1953
 	        	//$alldata = array();
1704 1954
     			foreach ($dall as $value) {
1705 1955
     				$icao = $value['airport_departure_icao'];
@@ -1720,11 +1970,17 @@  discard block
 block discarded – undo
1720 1970
 			foreach ($alldata as $number) {
1721 1971
 				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);
1722 1972
 			}
1723
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1973
+			if ($globalDebug) {
1974
+				echo 'Count all arrival airports by airlines...'."\n";
1975
+			}
1724 1976
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1725
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1977
+			if ($globalDebug) {
1978
+				echo 'Count all detected arrival airports by airlines...'."\n";
1979
+			}
1726 1980
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1727
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Order arrival airports by airlines...'."\n";
1983
+			}
1728 1984
 	        	//$alldata = array();
1729 1985
     			foreach ($dall as $value) {
1730 1986
     				$icao = $value['airport_arrival_icao'];
@@ -1743,37 +1999,53 @@  discard block
 block discarded – undo
1743 1999
     			}
1744 2000
     			$alldata = $pall;
1745 2001
                         foreach ($alldata as $number) {
1746
-				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);
2002
+				if ($number['airline_icao'] != '') {
2003
+					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);
2004
+				}
2005
+			}
2006
+			if ($globalDebug) {
2007
+				echo 'Count all flights by months by airlines...'."\n";
1747 2008
 			}
1748
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1749 2009
 			$Spotter = new Spotter($this->db);
1750 2010
 			$alldata = $Spotter->countAllMonthsByAirlines();
1751 2011
 			$lastyear = false;
1752 2012
 			foreach ($alldata as $number) {
1753
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2013
+				if ($number['year_name'] != date('Y')) {
2014
+					$lastyear = true;
2015
+				}
1754 2016
 				$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']);
1755 2017
 			}
1756
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2018
+			if ($globalDebug) {
2019
+				echo 'Count all owners by months by airlines...'."\n";
2020
+			}
1757 2021
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1758 2022
 			foreach ($alldata as $number) {
1759 2023
 				$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']);
1760 2024
 			}
1761
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2025
+			if ($globalDebug) {
2026
+				echo 'Count all pilots by months by airlines...'."\n";
2027
+			}
1762 2028
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1763 2029
 			foreach ($alldata as $number) {
1764 2030
 				$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']);
1765 2031
 			}
1766
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2032
+			if ($globalDebug) {
2033
+				echo 'Count all aircrafts by months by airlines...'."\n";
2034
+			}
1767 2035
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1768 2036
 			foreach ($alldata as $number) {
1769 2037
 				$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']);
1770 2038
 			}
1771
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2039
+			if ($globalDebug) {
2040
+				echo 'Count all real arrivals by months by airlines...'."\n";
2041
+			}
1772 2042
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1773 2043
 			foreach ($alldata as $number) {
1774 2044
 				$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']);
1775 2045
 			}
1776
-			if ($globalDebug) echo '...Departure'."\n";
2046
+			if ($globalDebug) {
2047
+				echo '...Departure'."\n";
2048
+			}
1777 2049
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1778 2050
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1779 2051
     			foreach ($dall as $value) {
@@ -1796,7 +2068,9 @@  discard block
 block discarded – undo
1796 2068
 			foreach ($alldata as $number) {
1797 2069
 				$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']);
1798 2070
 			}
1799
-			if ($globalDebug) echo '...Arrival'."\n";
2071
+			if ($globalDebug) {
2072
+				echo '...Arrival'."\n";
2073
+			}
1800 2074
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1801 2075
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1802 2076
     			foreach ($dall as $value) {
@@ -1820,13 +2094,19 @@  discard block
 block discarded – undo
1820 2094
 				$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']);
1821 2095
 			}
1822 2096
 
1823
-			if ($globalDebug) echo 'Flights data...'."\n";
1824
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2097
+			if ($globalDebug) {
2098
+				echo 'Flights data...'."\n";
2099
+			}
2100
+			if ($globalDebug) {
2101
+				echo '-> countAllDatesLastMonth...'."\n";
2102
+			}
1825 2103
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1826 2104
 			foreach ($alldata as $number) {
1827 2105
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1828 2106
 			}
1829
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2107
+			if ($globalDebug) {
2108
+				echo '-> countAllDates...'."\n";
2109
+			}
1830 2110
 			//$previousdata = $this->countAllDatesByAirlines();
1831 2111
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1832 2112
 			$values = array();
@@ -1839,7 +2119,9 @@  discard block
 block discarded – undo
1839 2119
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1840 2120
 			}
1841 2121
 			
1842
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2122
+			if ($globalDebug) {
2123
+				echo '-> countAllHours...'."\n";
2124
+			}
1843 2125
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1844 2126
 			foreach ($alldata as $number) {
1845 2127
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1847,7 +2129,9 @@  discard block
 block discarded – undo
1847 2129
 			
1848 2130
 
1849 2131
 			// Stats by filters
1850
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2132
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2133
+				$globalStatsFilters = array();
2134
+			}
1851 2135
 			foreach ($globalStatsFilters as $name => $filter) {
1852 2136
 				//$filter_name = $filter['name'];
1853 2137
 				$filter_name = $name;
@@ -1855,11 +2139,15 @@  discard block
 block discarded – undo
1855 2139
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1856 2140
 				if (isset($last_update[0]['value'])) {
1857 2141
 					$last_update_day = $last_update[0]['value'];
1858
-				} else $last_update_day = '2012-12-12 12:12:12';
2142
+				} else {
2143
+					$last_update_day = '2012-12-12 12:12:12';
2144
+				}
1859 2145
 				$reset = false;
1860 2146
 
1861 2147
 				// Count by filter
1862
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2148
+				if ($globalDebug) {
2149
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2150
+				}
1863 2151
 				$Spotter = new Spotter($this->db);
1864 2152
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1865 2153
 				foreach ($alldata as $number) {
@@ -1896,7 +2184,9 @@  discard block
 block discarded – undo
1896 2184
 	    				$icao = $value['airport_departure_icao'];
1897 2185
         				if (isset($alldata[$icao])) {
1898 2186
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1899
-        				} else $alldata[$icao] = $value;
2187
+        				} else {
2188
+        					$alldata[$icao] = $value;
2189
+        				}
1900 2190
 				}
1901 2191
 	    			$count = array();
1902 2192
     				foreach ($alldata as $key => $row) {
@@ -1917,7 +2207,9 @@  discard block
 block discarded – undo
1917 2207
 	    				$icao = $value['airport_arrival_icao'];
1918 2208
         				if (isset($alldata[$icao])) {
1919 2209
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1920
-		        		} else $alldata[$icao] = $value;
2210
+		        		} else {
2211
+		        			$alldata[$icao] = $value;
2212
+		        		}
1921 2213
 	    			}
1922 2214
         			$count = array();
1923 2215
         			foreach ($alldata as $key => $row) {
@@ -1931,7 +2223,9 @@  discard block
 block discarded – undo
1931 2223
 				$alldata = $Spotter->countAllMonths($filter);
1932 2224
 				$lastyear = false;
1933 2225
 				foreach ($alldata as $number) {
1934
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2226
+					if ($number['year_name'] != date('Y')) {
2227
+						$lastyear = true;
2228
+					}
1935 2229
 					$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);
1936 2230
 				}
1937 2231
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.