Completed
Push — master ( ea1d88...da5902 )
by Yannick
05:59
created
require/class.Stats.php 1 patch
Braces   +389 added lines, -135 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);
@@ -128,9 +138,14 @@  discard block
 block discarded – undo
128 138
 
129 139
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
130 140
 		global $globalStatsFilters;
131
-		if ($filter_name == '') $filter_name = $this->filter_name;
132
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
133
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
141
+		if ($filter_name == '') {
142
+			$filter_name = $this->filter_name;
143
+		}
144
+		if ($limit) {
145
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
146
+		} else {
147
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
148
+		}
134 149
                  try {
135 150
                         $sth = $this->db->prepare($query);
136 151
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -150,9 +165,14 @@  discard block
 block discarded – undo
150 165
 	}
151 166
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 167
 		global $globalStatsFilters;
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
-		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";
155
-		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";
168
+		if ($filter_name == '') {
169
+			$filter_name = $this->filter_name;
170
+		}
171
+		if ($limit) {
172
+			$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";
173
+		} else {
174
+			$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";
175
+		}
156 176
                  try {
157 177
                         $sth = $this->db->prepare($query);
158 178
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -172,9 +192,14 @@  discard block
 block discarded – undo
172 192
 	}
173 193
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 194
 		global $globalStatsFilters;
175
-		if ($filter_name == '') $filter_name = $this->filter_name;
176
-		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";
177
-		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";
195
+		if ($filter_name == '') {
196
+			$filter_name = $this->filter_name;
197
+		}
198
+		if ($limit) {
199
+			$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";
200
+		} else {
201
+			$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";
202
+		}
178 203
                  try {
179 204
                         $sth = $this->db->prepare($query);
180 205
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -195,9 +220,14 @@  discard block
 block discarded – undo
195 220
 
196 221
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
197 222
 		global $globalStatsFilters;
198
-		if ($filter_name == '') $filter_name = $this->filter_name;
199
-		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";
200
-		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";
223
+		if ($filter_name == '') {
224
+			$filter_name = $this->filter_name;
225
+		}
226
+		if ($limit) {
227
+			$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";
228
+		} else {
229
+			$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";
230
+		}
201 231
                  try {
202 232
                         $sth = $this->db->prepare($query);
203 233
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -217,9 +247,14 @@  discard block
 block discarded – undo
217 247
 	}
218 248
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 249
 		global $globalStatsFilters;
220
-		if ($filter_name == '') $filter_name = $this->filter_name;
221
-		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";
222
-		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";
250
+		if ($filter_name == '') {
251
+			$filter_name = $this->filter_name;
252
+		}
253
+		if ($limit) {
254
+			$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";
255
+		} else {
256
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
+		}
223 258
                  try {
224 259
                         $sth = $this->db->prepare($query);
225 260
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -240,9 +275,14 @@  discard block
 block discarded – undo
240 275
 
241 276
 	public function countAllAirlines($limit = true,$filter_name = '') {
242 277
 		global $globalStatsFilters;
243
-		if ($filter_name == '') $filter_name = $this->filter_name;
244
-		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";
245
-		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";
278
+		if ($filter_name == '') {
279
+			$filter_name = $this->filter_name;
280
+		}
281
+		if ($limit) {
282
+			$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";
283
+		} else {
284
+			$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";
285
+		}
246 286
                  try {
247 287
                         $sth = $this->db->prepare($query);
248 288
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -263,9 +303,14 @@  discard block
 block discarded – undo
263 303
 	}
264 304
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 305
 		global $globalStatsFilters;
266
-		if ($filter_name == '') $filter_name = $this->filter_name;
267
-		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";
268
-		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306
+		if ($filter_name == '') {
307
+			$filter_name = $this->filter_name;
308
+		}
309
+		if ($limit) {
310
+			$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";
311
+		} else {
312
+			$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";
313
+		}
269 314
                  try {
270 315
                         $sth = $this->db->prepare($query);
271 316
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -285,9 +330,14 @@  discard block
 block discarded – undo
285 330
 	}
286 331
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 332
 		global $globalStatsFilters;
288
-		if ($filter_name == '') $filter_name = $this->filter_name;
289
-		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";
290
-		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";
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
336
+		if ($limit) {
337
+			$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";
338
+		} else {
339
+			$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";
340
+		}
291 341
 		 try {
292 342
 			$sth = $this->db->prepare($query);
293 343
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -307,10 +357,15 @@  discard block
 block discarded – undo
307 357
 	}
308 358
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
309 359
 		$Connection = new Connection();
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
360
+		if ($filter_name == '') {
361
+			$filter_name = $this->filter_name;
362
+		}
311 363
 		if ($Connection->tableExists('countries')) {
312
-			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";
313
-			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";
364
+			if ($limit) {
365
+				$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";
366
+			} else {
367
+				$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";
368
+			}
314 369
 			 try {
315 370
 				$sth = $this->db->prepare($query);
316 371
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -331,9 +386,14 @@  discard block
 block discarded – undo
331 386
 	}
332 387
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
333 388
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
335
-		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";
336
-		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";
389
+		if ($filter_name == '') {
390
+			$filter_name = $this->filter_name;
391
+		}
392
+		if ($limit) {
393
+			$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";
394
+		} else {
395
+			$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";
396
+		}
337 397
                  try {
338 398
                         $sth = $this->db->prepare($query);
339 399
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -353,9 +413,14 @@  discard block
 block discarded – undo
353 413
 	}
354 414
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 415
 		global $globalStatsFilters;
356
-		if ($filter_name == '') $filter_name = $this->filter_name;
357
-		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";
358
-		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";
416
+		if ($filter_name == '') {
417
+			$filter_name = $this->filter_name;
418
+		}
419
+		if ($limit) {
420
+			$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";
421
+		} else {
422
+			$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";
423
+		}
359 424
                  try {
360 425
                         $sth = $this->db->prepare($query);
361 426
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -375,9 +440,14 @@  discard block
 block discarded – undo
375 440
 	}
376 441
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 442
 		global $globalStatsFilters;
378
-		if ($filter_name == '') $filter_name = $this->filter_name;
379
-		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";
380
-		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";
443
+		if ($filter_name == '') {
444
+			$filter_name = $this->filter_name;
445
+		}
446
+		if ($limit) {
447
+			$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";
448
+		} else {
449
+			$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";
450
+		}
381 451
                  try {
382 452
                         $sth = $this->db->prepare($query);
383 453
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -403,7 +473,9 @@  discard block
 block discarded – undo
403 473
         			$icao = $value['airport_departure_icao'];
404 474
         			if (isset($all[$icao])) {
405 475
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
476
+        			} else {
477
+        				$all[$icao] = $value;
478
+        			}
407 479
         		}
408 480
         		$count = array();
409 481
         		foreach ($all as $key => $row) {
@@ -415,9 +487,14 @@  discard block
 block discarded – undo
415 487
 	}
416 488
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 489
 		global $globalStatsFilters;
418
-		if ($filter_name == '') $filter_name = $this->filter_name;
419
-		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";
420
-		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";
490
+		if ($filter_name == '') {
491
+			$filter_name = $this->filter_name;
492
+		}
493
+		if ($limit) {
494
+			$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";
495
+		} else {
496
+			$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";
497
+		}
421 498
 		try {
422 499
 			$sth = $this->db->prepare($query);
423 500
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -443,7 +520,9 @@  discard block
 block discarded – undo
443 520
         			$icao = $value['airport_arrival_icao'];
444 521
         			if (isset($all[$icao])) {
445 522
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
523
+        			} else {
524
+        				$all[$icao] = $value;
525
+        			}
447 526
         		}
448 527
         		$count = array();
449 528
         		foreach ($all as $key => $row) {
@@ -456,13 +535,21 @@  discard block
 block discarded – undo
456 535
 	}
457 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 537
 		global $globalDBdriver, $globalStatsFilters;
459
-		if ($filter_name == '') $filter_name = $this->filter_name;
538
+		if ($filter_name == '') {
539
+			$filter_name = $this->filter_name;
540
+		}
460 541
 		if ($globalDBdriver == 'mysql') {
461
-			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";
462
-			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";
542
+			if ($limit) {
543
+				$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";
544
+			} else {
545
+				$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";
546
+			}
463 547
 		} else {
464
-			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";
465
-			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";
548
+			if ($limit) {
549
+				$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";
550
+			} else {
551
+				$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";
552
+			}
466 553
 		}
467 554
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468 555
                  try {
@@ -486,7 +573,9 @@  discard block
 block discarded – undo
486 573
 	
487 574
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
488 575
 		global $globalStatsFilters;
489
-		if ($filter_name == '') $filter_name = $this->filter_name;
576
+		if ($filter_name == '') {
577
+			$filter_name = $this->filter_name;
578
+		}
490 579
 		$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";
491 580
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492 581
                  try {
@@ -508,7 +597,9 @@  discard block
 block discarded – undo
508 597
 	}
509 598
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 599
 		global $globalDBdriver, $globalStatsFilters;
511
-		if ($filter_name == '') $filter_name = $this->filter_name;
600
+		if ($filter_name == '') {
601
+			$filter_name = $this->filter_name;
602
+		}
512 603
 		if ($globalDBdriver == 'mysql') {
513 604
 			$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";
514 605
 		} else {
@@ -534,7 +625,9 @@  discard block
 block discarded – undo
534 625
 	}
535 626
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 627
 		global $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
628
+		if ($filter_name == '') {
629
+			$filter_name = $this->filter_name;
630
+		}
538 631
 		$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";
539 632
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540 633
                  try {
@@ -556,7 +649,9 @@  discard block
 block discarded – undo
556 649
 	}
557 650
 	public function countAllDatesByAirlines($filter_name = '') {
558 651
 		global $globalStatsFilters;
559
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
560 655
 		$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";
561 656
 		$query_data = array('filter_name' => $filter_name);
562 657
                  try {
@@ -578,7 +673,9 @@  discard block
 block discarded – undo
578 673
 	}
579 674
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 675
 		global $globalStatsFilters;
581
-		if ($filter_name == '') $filter_name = $this->filter_name;
676
+		if ($filter_name == '') {
677
+			$filter_name = $this->filter_name;
678
+		}
582 679
 	    	$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";
583 680
                  try {
584 681
                         $sth = $this->db->prepare($query);
@@ -599,7 +696,9 @@  discard block
 block discarded – undo
599 696
 	}
600 697
 	public function countAllMilitaryMonths($filter_name = '') {
601 698
 		global $globalStatsFilters;
602
-		if ($filter_name == '') $filter_name = $this->filter_name;
699
+		if ($filter_name == '') {
700
+			$filter_name = $this->filter_name;
701
+		}
603 702
 	    	$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";
604 703
                  try {
605 704
                         $sth = $this->db->prepare($query);
@@ -620,9 +719,14 @@  discard block
 block discarded – undo
620 719
 	}
621 720
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 721
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
624
-		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";
625
-		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";
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
725
+		if ($limit) {
726
+			$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";
727
+		} else {
728
+			$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";
729
+		}
626 730
 		if ($orderby == 'hour') {
627 731
 			/*
628 732
 			if ($globalDBdriver == 'mysql') {
@@ -631,7 +735,9 @@  discard block
 block discarded – undo
631 735
 			*/
632 736
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 737
 		}
634
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
738
+		if ($orderby == 'count') {
739
+			$query .= " ORDER BY hour_count DESC";
740
+		}
635 741
                  try {
636 742
                         $sth = $this->db->prepare($query);
637 743
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -652,7 +758,9 @@  discard block
 block discarded – undo
652 758
 	
653 759
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
654 760
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
761
+		if ($filter_name == '') {
762
+			$filter_name = $this->filter_name;
763
+		}
656 764
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
657 765
 		if (empty($all)) {
658 766
 			$filters = array('airlines' => array($stats_airline));
@@ -666,7 +774,9 @@  discard block
 block discarded – undo
666 774
 	}
667 775
 	public function countOverallMilitaryFlights($filter_name = '') {
668 776
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
777
+		if ($filter_name == '') {
778
+			$filter_name = $this->filter_name;
779
+		}
670 780
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 781
 		if (empty($all)) {
672 782
 		        $filters = array();
@@ -680,7 +790,9 @@  discard block
 block discarded – undo
680 790
 	}
681 791
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
682 792
 		global $globalStatsFilters;
683
-		if ($filter_name == '') $filter_name = $this->filter_name;
793
+		if ($filter_name == '') {
794
+			$filter_name = $this->filter_name;
795
+		}
684 796
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
685 797
 		if (empty($all)) {
686 798
 			$filters = array('airlines' => array($stats_airline));
@@ -694,7 +806,9 @@  discard block
 block discarded – undo
694 806
 	}
695 807
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
696 808
 		global $globalStatsFilters;
697
-		if ($filter_name == '') $filter_name = $this->filter_name;
809
+		if ($filter_name == '') {
810
+			$filter_name = $this->filter_name;
811
+		}
698 812
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
699 813
 		if (empty($all)) {
700 814
 			$filters = array('airlines' => array($stats_airline));
@@ -708,7 +822,9 @@  discard block
 block discarded – undo
708 822
 	}
709 823
 	public function countOverallAirlines($filter_name = '') {
710 824
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
825
+		if ($filter_name == '') {
826
+			$filter_name = $this->filter_name;
827
+		}
712 828
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713 829
                  try {
714 830
                         $sth = $this->db->prepare($query);
@@ -731,7 +847,9 @@  discard block
 block discarded – undo
731 847
 	}
732 848
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
733 849
 		global $globalStatsFilters;
734
-		if ($filter_name == '') $filter_name = $this->filter_name;
850
+		if ($filter_name == '') {
851
+			$filter_name = $this->filter_name;
852
+		}
735 853
 		/*
736 854
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
737 855
                  try {
@@ -756,7 +874,9 @@  discard block
 block discarded – undo
756 874
 	}
757 875
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
758 876
 		global $globalStatsFilters;
759
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
760 880
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
761 881
 		if (empty($all)) {
762 882
 			$filters = array('airlines' => array($stats_airline));
@@ -770,7 +890,9 @@  discard block
 block discarded – undo
770 890
 	}
771 891
 
772 892
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
773
-		if ($filter_name == '') $filter_name = $this->filter_name;
893
+		if ($filter_name == '') {
894
+			$filter_name = $this->filter_name;
895
+		}
774 896
 		$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";
775 897
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776 898
                  try {
@@ -783,7 +905,9 @@  discard block
 block discarded – undo
783 905
                 return $all;
784 906
 	}
785 907
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
908
+		if ($filter_name == '') {
909
+			$filter_name = $this->filter_name;
910
+		}
787 911
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788 912
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789 913
                  try {
@@ -796,7 +920,9 @@  discard block
 block discarded – undo
796 920
                 return $all;
797 921
         }
798 922
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799
-		if ($filter_name == '') $filter_name = $this->filter_name;
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
800 926
     		global $globalArchiveMonths, $globalDBdriver;
801 927
     		if ($globalDBdriver == 'mysql') {
802 928
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -815,7 +941,9 @@  discard block
 block discarded – undo
815 941
         }
816 942
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817 943
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
944
+		if ($filter_name == '') {
945
+			$filter_name = $this->filter_name;
946
+		}
819 947
     		if ($globalDBdriver == 'mysql') {
820 948
 			$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";
821 949
 		} else {
@@ -833,7 +961,9 @@  discard block
 block discarded – undo
833 961
         }
834 962
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835 963
     		global $globalArchiveMonths, $globalDBdriver;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
837 967
     		if ($globalDBdriver == 'mysql') {
838 968
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839 969
                 } else {
@@ -850,7 +980,9 @@  discard block
 block discarded – undo
850 980
         }
851 981
 	public function getStatsAirlineTotal($filter_name = '') {
852 982
     		global $globalArchiveMonths, $globalDBdriver;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
983
+		if ($filter_name == '') {
984
+			$filter_name = $this->filter_name;
985
+		}
854 986
     		if ($globalDBdriver == 'mysql') {
855 987
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856 988
                 } else {
@@ -867,7 +999,9 @@  discard block
 block discarded – undo
867 999
         }
868 1000
 	public function getStatsOwnerTotal($filter_name = '') {
869 1001
     		global $globalArchiveMonths, $globalDBdriver;
870
-		if ($filter_name == '') $filter_name = $this->filter_name;
1002
+		if ($filter_name == '') {
1003
+			$filter_name = $this->filter_name;
1004
+		}
871 1005
     		if ($globalDBdriver == 'mysql') {
872 1006
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 1007
 		} else {
@@ -884,7 +1018,9 @@  discard block
 block discarded – undo
884 1018
         }
885 1019
 	public function getStatsPilotTotal($filter_name = '') {
886 1020
     		global $globalArchiveMonths, $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1021
+		if ($filter_name == '') {
1022
+			$filter_name = $this->filter_name;
1023
+		}
888 1024
     		if ($globalDBdriver == 'mysql') {
889 1025
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890 1026
             	} else {
@@ -902,7 +1038,9 @@  discard block
 block discarded – undo
902 1038
 
903 1039
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 1040
 		global $globalDBdriver;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
906 1044
 		if ($globalDBdriver == 'mysql') {
907 1045
 			$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";
908 1046
                 } else {
@@ -918,7 +1056,9 @@  discard block
 block discarded – undo
918 1056
         }
919 1057
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 1058
 		global $globalDBdriver;
921
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
922 1062
 		if ($globalDBdriver == 'mysql') {
923 1063
 			$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";
924 1064
 		} else {
@@ -1259,10 +1399,14 @@  discard block
 block discarded – undo
1259 1399
     		$Connection = new Connection();
1260 1400
     		date_default_timezone_set('UTC');
1261 1401
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1262
-			if ($globalDebug) echo 'Update stats !'."\n";
1402
+			if ($globalDebug) {
1403
+				echo 'Update stats !'."\n";
1404
+			}
1263 1405
 			if (isset($last_update[0]['value'])) {
1264 1406
 				$last_update_day = $last_update[0]['value'];
1265
-			} else $last_update_day = '2012-12-12 12:12:12';
1407
+			} else {
1408
+				$last_update_day = '2012-12-12 12:12:12';
1409
+			}
1266 1410
 			$reset = false;
1267 1411
 			if ($globalStatsResetYear) {
1268 1412
 				$reset = true;
@@ -1270,42 +1414,60 @@  discard block
 block discarded – undo
1270 1414
 			}
1271 1415
 			$Spotter = new Spotter($this->db);
1272 1416
 
1273
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1417
+			if ($globalDebug) {
1418
+				echo 'Count all aircraft types...'."\n";
1419
+			}
1274 1420
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1275 1421
 			foreach ($alldata as $number) {
1276 1422
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1277 1423
 			}
1278
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1424
+			if ($globalDebug) {
1425
+				echo 'Count all airlines...'."\n";
1426
+			}
1279 1427
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1280 1428
 			foreach ($alldata as $number) {
1281 1429
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1282 1430
 			}
1283
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1431
+			if ($globalDebug) {
1432
+				echo 'Count all registrations...'."\n";
1433
+			}
1284 1434
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1285 1435
 			foreach ($alldata as $number) {
1286 1436
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1287 1437
 			}
1288
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1438
+			if ($globalDebug) {
1439
+				echo 'Count all callsigns...'."\n";
1440
+			}
1289 1441
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1290 1442
 			foreach ($alldata as $number) {
1291 1443
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1292 1444
 			}
1293
-			if ($globalDebug) echo 'Count all owners...'."\n";
1445
+			if ($globalDebug) {
1446
+				echo 'Count all owners...'."\n";
1447
+			}
1294 1448
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1295 1449
 			foreach ($alldata as $number) {
1296 1450
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1297 1451
 			}
1298
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1452
+			if ($globalDebug) {
1453
+				echo 'Count all pilots...'."\n";
1454
+			}
1299 1455
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1300 1456
 			foreach ($alldata as $number) {
1301 1457
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1302 1458
 			}
1303 1459
 			
1304
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1460
+			if ($globalDebug) {
1461
+				echo 'Count all departure airports...'."\n";
1462
+			}
1305 1463
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1306
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1464
+			if ($globalDebug) {
1465
+				echo 'Count all detected departure airports...'."\n";
1466
+			}
1307 1467
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1308
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1468
+			if ($globalDebug) {
1469
+				echo 'Order departure airports...'."\n";
1470
+			}
1309 1471
 	        	$alldata = array();
1310 1472
 	        	
1311 1473
     			foreach ($pall as $value) {
@@ -1316,7 +1478,9 @@  discard block
 block discarded – undo
1316 1478
     				$icao = $value['airport_departure_icao'];
1317 1479
         			if (isset($alldata[$icao])) {
1318 1480
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1319
-        			} else $alldata[$icao] = $value;
1481
+        			} else {
1482
+        				$alldata[$icao] = $value;
1483
+        			}
1320 1484
 			}
1321 1485
     			$count = array();
1322 1486
     			foreach ($alldata as $key => $row) {
@@ -1326,11 +1490,17 @@  discard block
 block discarded – undo
1326 1490
 			foreach ($alldata as $number) {
1327 1491
 				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);
1328 1492
 			}
1329
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1493
+			if ($globalDebug) {
1494
+				echo 'Count all arrival airports...'."\n";
1495
+			}
1330 1496
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1331
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1497
+			if ($globalDebug) {
1498
+				echo 'Count all detected arrival airports...'."\n";
1499
+			}
1332 1500
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1333
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501
+			if ($globalDebug) {
1502
+				echo 'Order arrival airports...'."\n";
1503
+			}
1334 1504
 	        	$alldata = array();
1335 1505
     			foreach ($pall as $value) {
1336 1506
 	        		$icao = $value['airport_arrival_icao'];
@@ -1340,7 +1510,9 @@  discard block
 block discarded – undo
1340 1510
     				$icao = $value['airport_arrival_icao'];
1341 1511
         			if (isset($alldata[$icao])) {
1342 1512
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1343
-	        		} else $alldata[$icao] = $value;
1513
+	        		} else {
1514
+	        			$alldata[$icao] = $value;
1515
+	        		}
1344 1516
     			}
1345 1517
         		$count = array();
1346 1518
         		foreach ($alldata as $key => $row) {
@@ -1351,7 +1523,9 @@  discard block
 block discarded – undo
1351 1523
 				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);
1352 1524
 			}
1353 1525
 			if ($Connection->tableExists('countries')) {
1354
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1526
+				if ($globalDebug) {
1527
+					echo 'Count all flights by countries...'."\n";
1528
+				}
1355 1529
 				$SpotterArchive = new SpotterArchive();
1356 1530
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1357 1531
 				foreach ($alldata as $number) {
@@ -1363,46 +1537,66 @@  discard block
 block discarded – undo
1363 1537
 			// Add by month using getstat if month finish...
1364 1538
 
1365 1539
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1366
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1540
+			if ($globalDebug) {
1541
+				echo 'Count all flights by months...'."\n";
1542
+			}
1367 1543
 			$Spotter = new Spotter($this->db);
1368 1544
 			$alldata = $Spotter->countAllMonths();
1369 1545
 			$lastyear = false;
1370 1546
 			foreach ($alldata as $number) {
1371
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1547
+				if ($number['year_name'] != date('Y')) {
1548
+					$lastyear = true;
1549
+				}
1372 1550
 				$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'])));
1373 1551
 			}
1374
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1552
+			if ($globalDebug) {
1553
+				echo 'Count all military flights by months...'."\n";
1554
+			}
1375 1555
 			$alldata = $Spotter->countAllMilitaryMonths();
1376 1556
 			foreach ($alldata as $number) {
1377 1557
 				$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'])));
1378 1558
 			}
1379
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1559
+			if ($globalDebug) {
1560
+				echo 'Count all owners by months...'."\n";
1561
+			}
1380 1562
 			$alldata = $Spotter->countAllMonthsOwners();
1381 1563
 			foreach ($alldata as $number) {
1382 1564
 				$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'])));
1383 1565
 			}
1384
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1566
+			if ($globalDebug) {
1567
+				echo 'Count all pilots by months...'."\n";
1568
+			}
1385 1569
 			$alldata = $Spotter->countAllMonthsPilots();
1386 1570
 			foreach ($alldata as $number) {
1387 1571
 				$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'])));
1388 1572
 			}
1389
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1573
+			if ($globalDebug) {
1574
+				echo 'Count all airlines by months...'."\n";
1575
+			}
1390 1576
 			$alldata = $Spotter->countAllMonthsAirlines();
1391 1577
 			foreach ($alldata as $number) {
1392 1578
 				$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'])));
1393 1579
 			}
1394
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1580
+			if ($globalDebug) {
1581
+				echo 'Count all aircrafts by months...'."\n";
1582
+			}
1395 1583
 			$alldata = $Spotter->countAllMonthsAircrafts();
1396 1584
 			foreach ($alldata as $number) {
1397 1585
 				$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'])));
1398 1586
 			}
1399
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1587
+			if ($globalDebug) {
1588
+				echo 'Count all real arrivals by months...'."\n";
1589
+			}
1400 1590
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1401 1591
 			foreach ($alldata as $number) {
1402 1592
 				$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'])));
1403 1593
 			}
1404
-			if ($globalDebug) echo 'Airports data...'."\n";
1405
-			if ($globalDebug) echo '...Departure'."\n";
1594
+			if ($globalDebug) {
1595
+				echo 'Airports data...'."\n";
1596
+			}
1597
+			if ($globalDebug) {
1598
+				echo '...Departure'."\n";
1599
+			}
1406 1600
 			$this->deleteStatAirport('daily');
1407 1601
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1408 1602
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1522,37 +1716,53 @@  discard block
 block discarded – undo
1522 1716
 
1523 1717
 			// Count by airlines
1524 1718
 			echo '--- Stats by airlines ---'."\n";
1525
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1719
+			if ($globalDebug) {
1720
+				echo 'Count all aircraft types by airlines...'."\n";
1721
+			}
1526 1722
 			$Spotter = new Spotter($this->db);
1527 1723
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1528 1724
 			foreach ($alldata as $number) {
1529 1725
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1530 1726
 			}
1531
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Count all aircraft registrations by airlines...'."\n";
1729
+			}
1532 1730
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1533 1731
 			foreach ($alldata as $number) {
1534 1732
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1535 1733
 			}
1536
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1734
+			if ($globalDebug) {
1735
+				echo 'Count all callsigns by airlines...'."\n";
1736
+			}
1537 1737
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1538 1738
 			foreach ($alldata as $number) {
1539 1739
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1540 1740
 			}
1541
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1741
+			if ($globalDebug) {
1742
+				echo 'Count all owners by airlines...'."\n";
1743
+			}
1542 1744
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1543 1745
 			foreach ($alldata as $number) {
1544 1746
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1545 1747
 			}
1546
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1748
+			if ($globalDebug) {
1749
+				echo 'Count all pilots by airlines...'."\n";
1750
+			}
1547 1751
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1548 1752
 			foreach ($alldata as $number) {
1549 1753
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1550 1754
 			}
1551
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1755
+			if ($globalDebug) {
1756
+				echo 'Count all departure airports by airlines...'."\n";
1757
+			}
1552 1758
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1553
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1759
+			if ($globalDebug) {
1760
+				echo 'Count all detected departure airports by airlines...'."\n";
1761
+			}
1554 1762
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1555
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1763
+			if ($globalDebug) {
1764
+				echo 'Order detected departure airports by airlines...'."\n";
1765
+			}
1556 1766
 	        	//$alldata = array();
1557 1767
     			foreach ($dall as $value) {
1558 1768
     				$icao = $value['airport_departure_icao'];
@@ -1573,11 +1783,17 @@  discard block
 block discarded – undo
1573 1783
 			foreach ($alldata as $number) {
1574 1784
 				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);
1575 1785
 			}
1576
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1786
+			if ($globalDebug) {
1787
+				echo 'Count all arrival airports by airlines...'."\n";
1788
+			}
1577 1789
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1578
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1790
+			if ($globalDebug) {
1791
+				echo 'Count all detected arrival airports by airlines...'."\n";
1792
+			}
1579 1793
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1580
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1794
+			if ($globalDebug) {
1795
+				echo 'Order arrival airports by airlines...'."\n";
1796
+			}
1581 1797
 	        	//$alldata = array();
1582 1798
     			foreach ($dall as $value) {
1583 1799
     				$icao = $value['airport_arrival_icao'];
@@ -1596,37 +1812,53 @@  discard block
 block discarded – undo
1596 1812
     			}
1597 1813
     			$alldata = $pall;
1598 1814
                         foreach ($alldata as $number) {
1599
-				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);
1815
+				if ($number['airline_icao'] != '') {
1816
+					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);
1817
+				}
1818
+			}
1819
+			if ($globalDebug) {
1820
+				echo 'Count all flights by months by airlines...'."\n";
1600 1821
 			}
1601
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1602 1822
 			$Spotter = new Spotter($this->db);
1603 1823
 			$alldata = $Spotter->countAllMonthsByAirlines();
1604 1824
 			$lastyear = false;
1605 1825
 			foreach ($alldata as $number) {
1606
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1826
+				if ($number['year_name'] != date('Y')) {
1827
+					$lastyear = true;
1828
+				}
1607 1829
 				$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']);
1608 1830
 			}
1609
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1831
+			if ($globalDebug) {
1832
+				echo 'Count all owners by months by airlines...'."\n";
1833
+			}
1610 1834
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1611 1835
 			foreach ($alldata as $number) {
1612 1836
 				$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']);
1613 1837
 			}
1614
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1838
+			if ($globalDebug) {
1839
+				echo 'Count all pilots by months by airlines...'."\n";
1840
+			}
1615 1841
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1616 1842
 			foreach ($alldata as $number) {
1617 1843
 				$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']);
1618 1844
 			}
1619
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1845
+			if ($globalDebug) {
1846
+				echo 'Count all aircrafts by months by airlines...'."\n";
1847
+			}
1620 1848
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1621 1849
 			foreach ($alldata as $number) {
1622 1850
 				$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']);
1623 1851
 			}
1624
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1852
+			if ($globalDebug) {
1853
+				echo 'Count all real arrivals by months by airlines...'."\n";
1854
+			}
1625 1855
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1626 1856
 			foreach ($alldata as $number) {
1627 1857
 				$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']);
1628 1858
 			}
1629
-			if ($globalDebug) echo '...Departure'."\n";
1859
+			if ($globalDebug) {
1860
+				echo '...Departure'."\n";
1861
+			}
1630 1862
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1631 1863
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1632 1864
     			foreach ($dall as $value) {
@@ -1649,7 +1881,9 @@  discard block
 block discarded – undo
1649 1881
 			foreach ($alldata as $number) {
1650 1882
 				$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']);
1651 1883
 			}
1652
-			if ($globalDebug) echo '...Arrival'."\n";
1884
+			if ($globalDebug) {
1885
+				echo '...Arrival'."\n";
1886
+			}
1653 1887
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1654 1888
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1655 1889
     			foreach ($dall as $value) {
@@ -1673,13 +1907,19 @@  discard block
 block discarded – undo
1673 1907
 				$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']);
1674 1908
 			}
1675 1909
 
1676
-			if ($globalDebug) echo 'Flights data...'."\n";
1677
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1910
+			if ($globalDebug) {
1911
+				echo 'Flights data...'."\n";
1912
+			}
1913
+			if ($globalDebug) {
1914
+				echo '-> countAllDatesLastMonth...'."\n";
1915
+			}
1678 1916
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1679 1917
 			foreach ($alldata as $number) {
1680 1918
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1681 1919
 			}
1682
-			if ($globalDebug) echo '-> countAllDates...'."\n";
1920
+			if ($globalDebug) {
1921
+				echo '-> countAllDates...'."\n";
1922
+			}
1683 1923
 			//$previousdata = $this->countAllDatesByAirlines();
1684 1924
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1685 1925
 			$values = array();
@@ -1692,7 +1932,9 @@  discard block
 block discarded – undo
1692 1932
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1693 1933
 			}
1694 1934
 			
1695
-			if ($globalDebug) echo '-> countAllHours...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo '-> countAllHours...'."\n";
1937
+			}
1696 1938
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1697 1939
 			foreach ($alldata as $number) {
1698 1940
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1700,7 +1942,9 @@  discard block
 block discarded – undo
1700 1942
 			
1701 1943
 
1702 1944
 			// Stats by filters
1703
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
1945
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
1946
+				$globalStatsFilters = array();
1947
+			}
1704 1948
 			foreach ($globalStatsFilters as $name => $filter) {
1705 1949
 				//$filter_name = $filter['name'];
1706 1950
 				$filter_name = $name;
@@ -1708,11 +1952,15 @@  discard block
 block discarded – undo
1708 1952
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1709 1953
 				if (isset($last_update[0]['value'])) {
1710 1954
 					$last_update_day = $last_update[0]['value'];
1711
-				} else $last_update_day = '2012-12-12 12:12:12';
1955
+				} else {
1956
+					$last_update_day = '2012-12-12 12:12:12';
1957
+				}
1712 1958
 				$reset = false;
1713 1959
 
1714 1960
 				// Count by filter
1715
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1961
+				if ($globalDebug) {
1962
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
1963
+				}
1716 1964
 				$Spotter = new Spotter($this->db);
1717 1965
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1718 1966
 				foreach ($alldata as $number) {
@@ -1749,7 +1997,9 @@  discard block
 block discarded – undo
1749 1997
 	    				$icao = $value['airport_departure_icao'];
1750 1998
         				if (isset($alldata[$icao])) {
1751 1999
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1752
-        				} else $alldata[$icao] = $value;
2000
+        				} else {
2001
+        					$alldata[$icao] = $value;
2002
+        				}
1753 2003
 				}
1754 2004
 	    			$count = array();
1755 2005
     				foreach ($alldata as $key => $row) {
@@ -1770,7 +2020,9 @@  discard block
 block discarded – undo
1770 2020
 	    				$icao = $value['airport_arrival_icao'];
1771 2021
         				if (isset($alldata[$icao])) {
1772 2022
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1773
-		        		} else $alldata[$icao] = $value;
2023
+		        		} else {
2024
+		        			$alldata[$icao] = $value;
2025
+		        		}
1774 2026
 	    			}
1775 2027
         			$count = array();
1776 2028
         			foreach ($alldata as $key => $row) {
@@ -1784,7 +2036,9 @@  discard block
 block discarded – undo
1784 2036
 				$alldata = $Spotter->countAllMonths($filter);
1785 2037
 				$lastyear = false;
1786 2038
 				foreach ($alldata as $number) {
1787
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2039
+					if ($number['year_name'] != date('Y')) {
2040
+						$lastyear = true;
2041
+					}
1788 2042
 					$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);
1789 2043
 				}
1790 2044
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.