Completed
Push — master ( 9321a3...c66f20 )
by Yannick
05:39
created
require/class.Stats.php 1 patch
Braces   +386 added lines, -134 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
         }
@@ -59,7 +61,9 @@  discard block
 block discarded – undo
59 61
                 }
60 62
         }
61 63
 	public function getAllAirlineNames($filter_name = '') {
62
-		if ($filter_name == '') $filter_name = $this->filter_name;
64
+		if ($filter_name == '') {
65
+			$filter_name = $this->filter_name;
66
+		}
63 67
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
64 68
                  try {
65 69
                         $sth = $this->db->prepare($query);
@@ -71,7 +75,9 @@  discard block
 block discarded – undo
71 75
                 return $all;
72 76
         }
73 77
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
74
-		if ($filter_name == '') $filter_name = $this->filter_name;
78
+		if ($filter_name == '') {
79
+			$filter_name = $this->filter_name;
80
+		}
75 81
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
76 82
                  try {
77 83
                         $sth = $this->db->prepare($query);
@@ -83,7 +89,9 @@  discard block
 block discarded – undo
83 89
                 return $all;
84 90
         }
85 91
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
86
-		if ($filter_name == '') $filter_name = $this->filter_name;
92
+		if ($filter_name == '') {
93
+			$filter_name = $this->filter_name;
94
+		}
87 95
                 $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";
88 96
                  try {
89 97
                         $sth = $this->db->prepare($query);
@@ -95,7 +103,9 @@  discard block
 block discarded – undo
95 103
                 return $all;
96 104
         }
97 105
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
98
-		if ($filter_name == '') $filter_name = $this->filter_name;
106
+		if ($filter_name == '') {
107
+			$filter_name = $this->filter_name;
108
+		}
99 109
                 $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";
100 110
                  try {
101 111
                         $sth = $this->db->prepare($query);
@@ -110,9 +120,14 @@  discard block
 block discarded – undo
110 120
 
111 121
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
112 122
 		global $globalStatsFilters;
113
-		if ($filter_name == '') $filter_name = $this->filter_name;
114
-		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";
115
-		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";
123
+		if ($filter_name == '') {
124
+			$filter_name = $this->filter_name;
125
+		}
126
+		if ($limit) {
127
+			$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";
128
+		} else {
129
+			$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";
130
+		}
116 131
                  try {
117 132
                         $sth = $this->db->prepare($query);
118 133
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -132,9 +147,14 @@  discard block
 block discarded – undo
132 147
 	}
133 148
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
134 149
 		global $globalStatsFilters;
135
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
-		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";
137
-		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";
150
+		if ($filter_name == '') {
151
+			$filter_name = $this->filter_name;
152
+		}
153
+		if ($limit) {
154
+			$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 {
156
+			$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";
157
+		}
138 158
                  try {
139 159
                         $sth = $this->db->prepare($query);
140 160
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -154,9 +174,14 @@  discard block
 block discarded – undo
154 174
 	}
155 175
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
156 176
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
-		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";
159
-		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";
177
+		if ($filter_name == '') {
178
+			$filter_name = $this->filter_name;
179
+		}
180
+		if ($limit) {
181
+			$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";
182
+		} else {
183
+			$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";
184
+		}
160 185
                  try {
161 186
                         $sth = $this->db->prepare($query);
162 187
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -177,9 +202,14 @@  discard block
 block discarded – undo
177 202
 
178 203
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
179 204
 		global $globalStatsFilters;
180
-		if ($filter_name == '') $filter_name = $this->filter_name;
181
-		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";
182
-		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";
205
+		if ($filter_name == '') {
206
+			$filter_name = $this->filter_name;
207
+		}
208
+		if ($limit) {
209
+			$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";
210
+		} else {
211
+			$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";
212
+		}
183 213
                  try {
184 214
                         $sth = $this->db->prepare($query);
185 215
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -199,9 +229,14 @@  discard block
 block discarded – undo
199 229
 	}
200 230
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
201 231
 		global $globalStatsFilters;
202
-		if ($filter_name == '') $filter_name = $this->filter_name;
203
-		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";
204
-		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";
232
+		if ($filter_name == '') {
233
+			$filter_name = $this->filter_name;
234
+		}
235
+		if ($limit) {
236
+			$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";
237
+		} else {
238
+			$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";
239
+		}
205 240
                  try {
206 241
                         $sth = $this->db->prepare($query);
207 242
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -222,9 +257,14 @@  discard block
 block discarded – undo
222 257
 
223 258
 	public function countAllAirlines($limit = true,$filter_name = '') {
224 259
 		global $globalStatsFilters;
225
-		if ($filter_name == '') $filter_name = $this->filter_name;
226
-		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";
227
-		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";
260
+		if ($filter_name == '') {
261
+			$filter_name = $this->filter_name;
262
+		}
263
+		if ($limit) {
264
+			$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";
265
+		} else {
266
+			$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";
267
+		}
228 268
                  try {
229 269
                         $sth = $this->db->prepare($query);
230 270
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -245,9 +285,14 @@  discard block
 block discarded – undo
245 285
 	}
246 286
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
247 287
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
249
-		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";
250
-		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";
288
+		if ($filter_name == '') {
289
+			$filter_name = $this->filter_name;
290
+		}
291
+		if ($limit) {
292
+			$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";
293
+		} else {
294
+			$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";
295
+		}
251 296
                  try {
252 297
                         $sth = $this->db->prepare($query);
253 298
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -267,9 +312,14 @@  discard block
 block discarded – undo
267 312
 	}
268 313
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
269 314
 		global $globalStatsFilters;
270
-		if ($filter_name == '') $filter_name = $this->filter_name;
271
-		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";
272
-		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";
315
+		if ($filter_name == '') {
316
+			$filter_name = $this->filter_name;
317
+		}
318
+		if ($limit) {
319
+			$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";
320
+		} else {
321
+			$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";
322
+		}
273 323
 		 try {
274 324
 			$sth = $this->db->prepare($query);
275 325
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -289,10 +339,15 @@  discard block
 block discarded – undo
289 339
 	}
290 340
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
291 341
 		$Connection = new Connection();
292
-		if ($filter_name == '') $filter_name = $this->filter_name;
342
+		if ($filter_name == '') {
343
+			$filter_name = $this->filter_name;
344
+		}
293 345
 		if ($Connection->tableExists('countries')) {
294
-			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";
295
-			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";
346
+			if ($limit) {
347
+				$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";
348
+			} else {
349
+				$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";
350
+			}
296 351
 			 try {
297 352
 				$sth = $this->db->prepare($query);
298 353
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -313,9 +368,14 @@  discard block
 block discarded – undo
313 368
 	}
314 369
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
315 370
 		global $globalStatsFilters;
316
-		if ($filter_name == '') $filter_name = $this->filter_name;
317
-		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";
318
-		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";
371
+		if ($filter_name == '') {
372
+			$filter_name = $this->filter_name;
373
+		}
374
+		if ($limit) {
375
+			$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";
376
+		} else {
377
+			$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";
378
+		}
319 379
                  try {
320 380
                         $sth = $this->db->prepare($query);
321 381
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -335,9 +395,14 @@  discard block
 block discarded – undo
335 395
 	}
336 396
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
337 397
 		global $globalStatsFilters;
338
-		if ($filter_name == '') $filter_name = $this->filter_name;
339
-		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";
340
-		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";
398
+		if ($filter_name == '') {
399
+			$filter_name = $this->filter_name;
400
+		}
401
+		if ($limit) {
402
+			$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";
403
+		} else {
404
+			$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";
405
+		}
341 406
                  try {
342 407
                         $sth = $this->db->prepare($query);
343 408
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -357,9 +422,14 @@  discard block
 block discarded – undo
357 422
 	}
358 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
359 424
 		global $globalStatsFilters;
360
-		if ($filter_name == '') $filter_name = $this->filter_name;
361
-		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";
362
-		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";
425
+		if ($filter_name == '') {
426
+			$filter_name = $this->filter_name;
427
+		}
428
+		if ($limit) {
429
+			$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";
430
+		} else {
431
+			$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";
432
+		}
363 433
                  try {
364 434
                         $sth = $this->db->prepare($query);
365 435
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -385,7 +455,9 @@  discard block
 block discarded – undo
385 455
         			$icao = $value['airport_departure_icao'];
386 456
         			if (isset($all[$icao])) {
387 457
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
388
-        			} else $all[$icao] = $value;
458
+        			} else {
459
+        				$all[$icao] = $value;
460
+        			}
389 461
         		}
390 462
         		$count = array();
391 463
         		foreach ($all as $key => $row) {
@@ -397,9 +469,14 @@  discard block
 block discarded – undo
397 469
 	}
398 470
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
399 471
 		global $globalStatsFilters;
400
-		if ($filter_name == '') $filter_name = $this->filter_name;
401
-		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";
402
-		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";
472
+		if ($filter_name == '') {
473
+			$filter_name = $this->filter_name;
474
+		}
475
+		if ($limit) {
476
+			$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";
477
+		} else {
478
+			$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";
479
+		}
403 480
 		try {
404 481
 			$sth = $this->db->prepare($query);
405 482
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -425,7 +502,9 @@  discard block
 block discarded – undo
425 502
         			$icao = $value['airport_arrival_icao'];
426 503
         			if (isset($all[$icao])) {
427 504
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
428
-        			} else $all[$icao] = $value;
505
+        			} else {
506
+        				$all[$icao] = $value;
507
+        			}
429 508
         		}
430 509
         		$count = array();
431 510
         		foreach ($all as $key => $row) {
@@ -438,13 +517,21 @@  discard block
 block discarded – undo
438 517
 	}
439 518
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
440 519
 		global $globalDBdriver, $globalStatsFilters;
441
-		if ($filter_name == '') $filter_name = $this->filter_name;
520
+		if ($filter_name == '') {
521
+			$filter_name = $this->filter_name;
522
+		}
442 523
 		if ($globalDBdriver == 'mysql') {
443
-			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";
444
-			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";
524
+			if ($limit) {
525
+				$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";
526
+			} else {
527
+				$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";
528
+			}
445 529
 		} else {
446
-			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";
447
-			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";
530
+			if ($limit) {
531
+				$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";
532
+			} else {
533
+				$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";
534
+			}
448 535
 		}
449 536
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
450 537
                  try {
@@ -468,7 +555,9 @@  discard block
 block discarded – undo
468 555
 	
469 556
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
470 557
 		global $globalStatsFilters;
471
-		if ($filter_name == '') $filter_name = $this->filter_name;
558
+		if ($filter_name == '') {
559
+			$filter_name = $this->filter_name;
560
+		}
472 561
 		$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";
473 562
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
474 563
                  try {
@@ -490,7 +579,9 @@  discard block
 block discarded – undo
490 579
 	}
491 580
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
492 581
 		global $globalDBdriver, $globalStatsFilters;
493
-		if ($filter_name == '') $filter_name = $this->filter_name;
582
+		if ($filter_name == '') {
583
+			$filter_name = $this->filter_name;
584
+		}
494 585
 		if ($globalDBdriver == 'mysql') {
495 586
 			$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";
496 587
 		} else {
@@ -516,7 +607,9 @@  discard block
 block discarded – undo
516 607
 	}
517 608
 	public function countAllDates($stats_airline = '',$filter_name = '') {
518 609
 		global $globalStatsFilters;
519
-		if ($filter_name == '') $filter_name = $this->filter_name;
610
+		if ($filter_name == '') {
611
+			$filter_name = $this->filter_name;
612
+		}
520 613
 		$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";
521 614
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
522 615
                  try {
@@ -538,7 +631,9 @@  discard block
 block discarded – undo
538 631
 	}
539 632
 	public function countAllDatesByAirlines($filter_name = '') {
540 633
 		global $globalStatsFilters;
541
-		if ($filter_name == '') $filter_name = $this->filter_name;
634
+		if ($filter_name == '') {
635
+			$filter_name = $this->filter_name;
636
+		}
542 637
 		$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";
543 638
 		$query_data = array('filter_name' => $filter_name);
544 639
                  try {
@@ -560,7 +655,9 @@  discard block
 block discarded – undo
560 655
 	}
561 656
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
562 657
 		global $globalStatsFilters;
563
-		if ($filter_name == '') $filter_name = $this->filter_name;
658
+		if ($filter_name == '') {
659
+			$filter_name = $this->filter_name;
660
+		}
564 661
 	    	$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";
565 662
                  try {
566 663
                         $sth = $this->db->prepare($query);
@@ -581,7 +678,9 @@  discard block
 block discarded – undo
581 678
 	}
582 679
 	public function countAllMilitaryMonths($filter_name = '') {
583 680
 		global $globalStatsFilters;
584
-		if ($filter_name == '') $filter_name = $this->filter_name;
681
+		if ($filter_name == '') {
682
+			$filter_name = $this->filter_name;
683
+		}
585 684
 	    	$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";
586 685
                  try {
587 686
                         $sth = $this->db->prepare($query);
@@ -602,9 +701,14 @@  discard block
 block discarded – undo
602 701
 	}
603 702
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
604 703
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
605
-		if ($filter_name == '') $filter_name = $this->filter_name;
606
-		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";
607
-		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";
704
+		if ($filter_name == '') {
705
+			$filter_name = $this->filter_name;
706
+		}
707
+		if ($limit) {
708
+			$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";
709
+		} else {
710
+			$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";
711
+		}
608 712
 		if ($orderby == 'hour') {
609 713
 			/*
610 714
 			if ($globalDBdriver == 'mysql') {
@@ -613,7 +717,9 @@  discard block
 block discarded – undo
613 717
 			*/
614 718
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
615 719
 		}
616
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
720
+		if ($orderby == 'count') {
721
+			$query .= " ORDER BY hour_count DESC";
722
+		}
617 723
                  try {
618 724
                         $sth = $this->db->prepare($query);
619 725
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -634,7 +740,9 @@  discard block
 block discarded – undo
634 740
 	
635 741
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
636 742
 		global $globalStatsFilters;
637
-		if ($filter_name == '') $filter_name = $this->filter_name;
743
+		if ($filter_name == '') {
744
+			$filter_name = $this->filter_name;
745
+		}
638 746
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
639 747
 		if (empty($all)) {
640 748
 			$filters = array('airlines' => array($stats_airline));
@@ -648,7 +756,9 @@  discard block
 block discarded – undo
648 756
 	}
649 757
 	public function countOverallMilitaryFlights($filter_name = '') {
650 758
 		global $globalStatsFilters;
651
-		if ($filter_name == '') $filter_name = $this->filter_name;
759
+		if ($filter_name == '') {
760
+			$filter_name = $this->filter_name;
761
+		}
652 762
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
653 763
 		if (empty($all)) {
654 764
 		        $filters = array();
@@ -662,7 +772,9 @@  discard block
 block discarded – undo
662 772
 	}
663 773
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
664 774
 		global $globalStatsFilters;
665
-		if ($filter_name == '') $filter_name = $this->filter_name;
775
+		if ($filter_name == '') {
776
+			$filter_name = $this->filter_name;
777
+		}
666 778
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
667 779
 		if (empty($all)) {
668 780
 			$filters = array('airlines' => array($stats_airline));
@@ -676,7 +788,9 @@  discard block
 block discarded – undo
676 788
 	}
677 789
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
678 790
 		global $globalStatsFilters;
679
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
+		if ($filter_name == '') {
792
+			$filter_name = $this->filter_name;
793
+		}
680 794
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
681 795
 		if (empty($all)) {
682 796
 			$filters = array('airlines' => array($stats_airline));
@@ -690,7 +804,9 @@  discard block
 block discarded – undo
690 804
 	}
691 805
 	public function countOverallAirlines($filter_name = '') {
692 806
 		global $globalStatsFilters;
693
-		if ($filter_name == '') $filter_name = $this->filter_name;
807
+		if ($filter_name == '') {
808
+			$filter_name = $this->filter_name;
809
+		}
694 810
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
695 811
                  try {
696 812
                         $sth = $this->db->prepare($query);
@@ -713,7 +829,9 @@  discard block
 block discarded – undo
713 829
 	}
714 830
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
715 831
 		global $globalStatsFilters;
716
-		if ($filter_name == '') $filter_name = $this->filter_name;
832
+		if ($filter_name == '') {
833
+			$filter_name = $this->filter_name;
834
+		}
717 835
 		/*
718 836
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
719 837
                  try {
@@ -738,7 +856,9 @@  discard block
 block discarded – undo
738 856
 	}
739 857
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
740 858
 		global $globalStatsFilters;
741
-		if ($filter_name == '') $filter_name = $this->filter_name;
859
+		if ($filter_name == '') {
860
+			$filter_name = $this->filter_name;
861
+		}
742 862
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
743 863
 		if (empty($all)) {
744 864
 			$filters = array('airlines' => array($stats_airline));
@@ -752,7 +872,9 @@  discard block
 block discarded – undo
752 872
 	}
753 873
 
754 874
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
755
-		if ($filter_name == '') $filter_name = $this->filter_name;
875
+		if ($filter_name == '') {
876
+			$filter_name = $this->filter_name;
877
+		}
756 878
 		$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";
757 879
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
758 880
                  try {
@@ -765,7 +887,9 @@  discard block
 block discarded – undo
765 887
                 return $all;
766 888
 	}
767 889
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
768
-		if ($filter_name == '') $filter_name = $this->filter_name;
890
+		if ($filter_name == '') {
891
+			$filter_name = $this->filter_name;
892
+		}
769 893
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
770 894
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
771 895
                  try {
@@ -778,7 +902,9 @@  discard block
 block discarded – undo
778 902
                 return $all;
779 903
         }
780 904
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
781
-		if ($filter_name == '') $filter_name = $this->filter_name;
905
+		if ($filter_name == '') {
906
+			$filter_name = $this->filter_name;
907
+		}
782 908
     		global $globalArchiveMonths, $globalDBdriver;
783 909
     		if ($globalDBdriver == 'mysql') {
784 910
 	                $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";
@@ -797,7 +923,9 @@  discard block
 block discarded – undo
797 923
         }
798 924
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
799 925
     		global $globalArchiveMonths, $globalDBdriver;
800
-		if ($filter_name == '') $filter_name = $this->filter_name;
926
+		if ($filter_name == '') {
927
+			$filter_name = $this->filter_name;
928
+		}
801 929
     		if ($globalDBdriver == 'mysql') {
802 930
 			$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";
803 931
 		} else {
@@ -815,7 +943,9 @@  discard block
 block discarded – undo
815 943
         }
816 944
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
817 945
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
946
+		if ($filter_name == '') {
947
+			$filter_name = $this->filter_name;
948
+		}
819 949
     		if ($globalDBdriver == 'mysql') {
820 950
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
821 951
                 } else {
@@ -832,7 +962,9 @@  discard block
 block discarded – undo
832 962
         }
833 963
 	public function getStatsAirlineTotal($filter_name = '') {
834 964
     		global $globalArchiveMonths, $globalDBdriver;
835
-		if ($filter_name == '') $filter_name = $this->filter_name;
965
+		if ($filter_name == '') {
966
+			$filter_name = $this->filter_name;
967
+		}
836 968
     		if ($globalDBdriver == 'mysql') {
837 969
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
838 970
                 } else {
@@ -849,7 +981,9 @@  discard block
 block discarded – undo
849 981
         }
850 982
 	public function getStatsOwnerTotal($filter_name = '') {
851 983
     		global $globalArchiveMonths, $globalDBdriver;
852
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
853 987
     		if ($globalDBdriver == 'mysql') {
854 988
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
855 989
 		} else {
@@ -866,7 +1000,9 @@  discard block
 block discarded – undo
866 1000
         }
867 1001
 	public function getStatsPilotTotal($filter_name = '') {
868 1002
     		global $globalArchiveMonths, $globalDBdriver;
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1003
+		if ($filter_name == '') {
1004
+			$filter_name = $this->filter_name;
1005
+		}
870 1006
     		if ($globalDBdriver == 'mysql') {
871 1007
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
872 1008
             	} else {
@@ -884,7 +1020,9 @@  discard block
 block discarded – undo
884 1020
 
885 1021
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
886 1022
 		global $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1023
+		if ($filter_name == '') {
1024
+			$filter_name = $this->filter_name;
1025
+		}
888 1026
 		if ($globalDBdriver == 'mysql') {
889 1027
 			$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";
890 1028
                 } else {
@@ -900,7 +1038,9 @@  discard block
 block discarded – undo
900 1038
         }
901 1039
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
902 1040
 		global $globalDBdriver;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
904 1044
 		if ($globalDBdriver == 'mysql') {
905 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+:cnt, stats_date = :date";
906 1046
 		} else {
@@ -1383,47 +1523,69 @@  discard block
 block discarded – undo
1383 1523
 			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1384 1524
 		} else {
1385 1525
 		*/
1386
-			if ($globalDebug) echo 'Update stats !'."\n";
1387
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1526
+			if ($globalDebug) {
1527
+				echo 'Update stats !'."\n";
1528
+			}
1529
+			if ($globalDebug) {
1530
+				echo 'Count all aircraft types...'."\n";
1531
+			}
1388 1532
 			if (isset($last_update[0]['value'])) {
1389 1533
 				$last_update_day = $last_update[0]['value'];
1390
-			} else $last_update_day = '2012-12-12 12:12:12';
1534
+			} else {
1535
+				$last_update_day = '2012-12-12 12:12:12';
1536
+			}
1391 1537
 			$Spotter = new Spotter($this->db);
1392 1538
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1393 1539
 			foreach ($alldata as $number) {
1394 1540
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1395 1541
 			}
1396
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1542
+			if ($globalDebug) {
1543
+				echo 'Count all airlines...'."\n";
1544
+			}
1397 1545
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1398 1546
 			foreach ($alldata as $number) {
1399 1547
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1400 1548
 			}
1401
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1549
+			if ($globalDebug) {
1550
+				echo 'Count all registrations...'."\n";
1551
+			}
1402 1552
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1403 1553
 			foreach ($alldata as $number) {
1404 1554
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1405 1555
 			}
1406
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1556
+			if ($globalDebug) {
1557
+				echo 'Count all callsigns...'."\n";
1558
+			}
1407 1559
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1408 1560
 			foreach ($alldata as $number) {
1409 1561
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1410 1562
 			}
1411
-			if ($globalDebug) echo 'Count all owners...'."\n";
1563
+			if ($globalDebug) {
1564
+				echo 'Count all owners...'."\n";
1565
+			}
1412 1566
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1413 1567
 			foreach ($alldata as $number) {
1414 1568
 				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1415 1569
 			}
1416
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1570
+			if ($globalDebug) {
1571
+				echo 'Count all pilots...'."\n";
1572
+			}
1417 1573
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1418 1574
 			foreach ($alldata as $number) {
1419 1575
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);
1420 1576
 			}
1421 1577
 			
1422
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1578
+			if ($globalDebug) {
1579
+				echo 'Count all departure airports...'."\n";
1580
+			}
1423 1581
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1424
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1582
+			if ($globalDebug) {
1583
+				echo 'Count all detected departure airports...'."\n";
1584
+			}
1425 1585
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1426
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1586
+			if ($globalDebug) {
1587
+				echo 'Order departure airports...'."\n";
1588
+			}
1427 1589
 	        	$alldata = array();
1428 1590
 	        	
1429 1591
     			foreach ($pall as $value) {
@@ -1434,7 +1596,9 @@  discard block
 block discarded – undo
1434 1596
     				$icao = $value['airport_departure_icao'];
1435 1597
         			if (isset($alldata[$icao])) {
1436 1598
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1437
-        			} else $alldata[$icao] = $value;
1599
+        			} else {
1600
+        				$alldata[$icao] = $value;
1601
+        			}
1438 1602
 			}
1439 1603
     			$count = array();
1440 1604
     			foreach ($alldata as $key => $row) {
@@ -1444,11 +1608,17 @@  discard block
 block discarded – undo
1444 1608
 			foreach ($alldata as $number) {
1445 1609
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1446 1610
 			}
1447
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1611
+			if ($globalDebug) {
1612
+				echo 'Count all arrival airports...'."\n";
1613
+			}
1448 1614
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1449
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1615
+			if ($globalDebug) {
1616
+				echo 'Count all detected arrival airports...'."\n";
1617
+			}
1450 1618
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1451
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1619
+			if ($globalDebug) {
1620
+				echo 'Order arrival airports...'."\n";
1621
+			}
1452 1622
 	        	$alldata = array();
1453 1623
     			foreach ($pall as $value) {
1454 1624
 	        		$icao = $value['airport_arrival_icao'];
@@ -1458,7 +1628,9 @@  discard block
 block discarded – undo
1458 1628
     				$icao = $value['airport_arrival_icao'];
1459 1629
         			if (isset($alldata[$icao])) {
1460 1630
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1461
-	        		} else $alldata[$icao] = $value;
1631
+	        		} else {
1632
+	        			$alldata[$icao] = $value;
1633
+	        		}
1462 1634
     			}
1463 1635
         		$count = array();
1464 1636
         		foreach ($alldata as $key => $row) {
@@ -1469,7 +1641,9 @@  discard block
 block discarded – undo
1469 1641
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1470 1642
 			}
1471 1643
 			if ($Connection->tableExists('countries')) {
1472
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1644
+				if ($globalDebug) {
1645
+					echo 'Count all flights by countries...'."\n";
1646
+				}
1473 1647
 				$SpotterArchive = new SpotterArchive();
1474 1648
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1475 1649
 				foreach ($alldata as $number) {
@@ -1481,46 +1655,66 @@  discard block
 block discarded – undo
1481 1655
 			// Add by month using getstat if month finish...
1482 1656
 
1483 1657
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1484
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1658
+			if ($globalDebug) {
1659
+				echo 'Count all flights by months...'."\n";
1660
+			}
1485 1661
 			$Spotter = new Spotter($this->db);
1486 1662
 			$alldata = $Spotter->countAllMonths();
1487 1663
 			$lastyear = false;
1488 1664
 			foreach ($alldata as $number) {
1489
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1665
+				if ($number['year_name'] != date('Y')) {
1666
+					$lastyear = true;
1667
+				}
1490 1668
 				$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'])));
1491 1669
 			}
1492
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1670
+			if ($globalDebug) {
1671
+				echo 'Count all military flights by months...'."\n";
1672
+			}
1493 1673
 			$alldata = $Spotter->countAllMilitaryMonths();
1494 1674
 			foreach ($alldata as $number) {
1495 1675
 				$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'])));
1496 1676
 			}
1497
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1677
+			if ($globalDebug) {
1678
+				echo 'Count all owners by months...'."\n";
1679
+			}
1498 1680
 			$alldata = $Spotter->countAllMonthsOwners();
1499 1681
 			foreach ($alldata as $number) {
1500 1682
 				$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'])));
1501 1683
 			}
1502
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1684
+			if ($globalDebug) {
1685
+				echo 'Count all pilots by months...'."\n";
1686
+			}
1503 1687
 			$alldata = $Spotter->countAllMonthsPilots();
1504 1688
 			foreach ($alldata as $number) {
1505 1689
 				$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'])));
1506 1690
 			}
1507
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1691
+			if ($globalDebug) {
1692
+				echo 'Count all airlines by months...'."\n";
1693
+			}
1508 1694
 			$alldata = $Spotter->countAllMonthsAirlines();
1509 1695
 			foreach ($alldata as $number) {
1510 1696
 				$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'])));
1511 1697
 			}
1512
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1698
+			if ($globalDebug) {
1699
+				echo 'Count all aircrafts by months...'."\n";
1700
+			}
1513 1701
 			$alldata = $Spotter->countAllMonthsAircrafts();
1514 1702
 			foreach ($alldata as $number) {
1515 1703
 				$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'])));
1516 1704
 			}
1517
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1705
+			if ($globalDebug) {
1706
+				echo 'Count all real arrivals by months...'."\n";
1707
+			}
1518 1708
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1519 1709
 			foreach ($alldata as $number) {
1520 1710
 				$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'])));
1521 1711
 			}
1522
-			if ($globalDebug) echo 'Airports data...'."\n";
1523
-			if ($globalDebug) echo '...Departure'."\n";
1712
+			if ($globalDebug) {
1713
+				echo 'Airports data...'."\n";
1714
+			}
1715
+			if ($globalDebug) {
1716
+				echo '...Departure'."\n";
1717
+			}
1524 1718
 			$this->deleteStatAirport('daily');
1525 1719
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1526 1720
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1640,37 +1834,53 @@  discard block
 block discarded – undo
1640 1834
 
1641 1835
 			// Count by airlines
1642 1836
 			echo '--- Stats by airlines ---'."\n";
1643
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1837
+			if ($globalDebug) {
1838
+				echo 'Count all aircraft types by airlines...'."\n";
1839
+			}
1644 1840
 			$Spotter = new Spotter($this->db);
1645 1841
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1646 1842
 			foreach ($alldata as $number) {
1647 1843
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1648 1844
 			}
1649
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1845
+			if ($globalDebug) {
1846
+				echo 'Count all aircraft registrations by airlines...'."\n";
1847
+			}
1650 1848
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1651 1849
 			foreach ($alldata as $number) {
1652 1850
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1653 1851
 			}
1654
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1852
+			if ($globalDebug) {
1853
+				echo 'Count all callsigns by airlines...'."\n";
1854
+			}
1655 1855
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1656 1856
 			foreach ($alldata as $number) {
1657 1857
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1658 1858
 			}
1659
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1859
+			if ($globalDebug) {
1860
+				echo 'Count all owners by airlines...'."\n";
1861
+			}
1660 1862
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1661 1863
 			foreach ($alldata as $number) {
1662 1864
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1663 1865
 			}
1664
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1866
+			if ($globalDebug) {
1867
+				echo 'Count all pilots by airlines...'."\n";
1868
+			}
1665 1869
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1666 1870
 			foreach ($alldata as $number) {
1667 1871
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);
1668 1872
 			}
1669
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1873
+			if ($globalDebug) {
1874
+				echo 'Count all departure airports by airlines...'."\n";
1875
+			}
1670 1876
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1671
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1877
+			if ($globalDebug) {
1878
+				echo 'Count all detected departure airports by airlines...'."\n";
1879
+			}
1672 1880
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1673
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1881
+			if ($globalDebug) {
1882
+				echo 'Order detected departure airports by airlines...'."\n";
1883
+			}
1674 1884
 	        	//$alldata = array();
1675 1885
     			foreach ($dall as $value) {
1676 1886
     				$icao = $value['airport_departure_icao'];
@@ -1691,11 +1901,17 @@  discard block
 block discarded – undo
1691 1901
 			foreach ($alldata as $number) {
1692 1902
 				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']);
1693 1903
 			}
1694
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1904
+			if ($globalDebug) {
1905
+				echo 'Count all arrival airports by airlines...'."\n";
1906
+			}
1695 1907
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1696
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1908
+			if ($globalDebug) {
1909
+				echo 'Count all detected arrival airports by airlines...'."\n";
1910
+			}
1697 1911
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1698
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1912
+			if ($globalDebug) {
1913
+				echo 'Order arrival airports by airlines...'."\n";
1914
+			}
1699 1915
 	        	//$alldata = array();
1700 1916
     			foreach ($dall as $value) {
1701 1917
     				$icao = $value['airport_arrival_icao'];
@@ -1716,35 +1932,49 @@  discard block
 block discarded – undo
1716 1932
                         foreach ($alldata as $number) {
1717 1933
 				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']);
1718 1934
 			}
1719
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo 'Count all flights by months by airlines...'."\n";
1937
+			}
1720 1938
 			$Spotter = new Spotter($this->db);
1721 1939
 			$alldata = $Spotter->countAllMonthsByAirlines();
1722 1940
 			$lastyear = false;
1723 1941
 			foreach ($alldata as $number) {
1724
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1942
+				if ($number['year_name'] != date('Y')) {
1943
+					$lastyear = true;
1944
+				}
1725 1945
 				$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']);
1726 1946
 			}
1727
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1947
+			if ($globalDebug) {
1948
+				echo 'Count all owners by months by airlines...'."\n";
1949
+			}
1728 1950
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1729 1951
 			foreach ($alldata as $number) {
1730 1952
 				$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']);
1731 1953
 			}
1732
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1954
+			if ($globalDebug) {
1955
+				echo 'Count all pilots by months by airlines...'."\n";
1956
+			}
1733 1957
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1734 1958
 			foreach ($alldata as $number) {
1735 1959
 				$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']);
1736 1960
 			}
1737
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1961
+			if ($globalDebug) {
1962
+				echo 'Count all aircrafts by months by airlines...'."\n";
1963
+			}
1738 1964
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1739 1965
 			foreach ($alldata as $number) {
1740 1966
 				$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']);
1741 1967
 			}
1742
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1968
+			if ($globalDebug) {
1969
+				echo 'Count all real arrivals by months by airlines...'."\n";
1970
+			}
1743 1971
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1744 1972
 			foreach ($alldata as $number) {
1745 1973
 				$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']);
1746 1974
 			}
1747
-			if ($globalDebug) echo '...Departure'."\n";
1975
+			if ($globalDebug) {
1976
+				echo '...Departure'."\n";
1977
+			}
1748 1978
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1749 1979
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1750 1980
     			foreach ($dall as $value) {
@@ -1767,7 +1997,9 @@  discard block
 block discarded – undo
1767 1997
 			foreach ($alldata as $number) {
1768 1998
 				$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']);
1769 1999
 			}
1770
-			if ($globalDebug) echo '...Arrival'."\n";
2000
+			if ($globalDebug) {
2001
+				echo '...Arrival'."\n";
2002
+			}
1771 2003
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1772 2004
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1773 2005
     			foreach ($dall as $value) {
@@ -1791,13 +2023,19 @@  discard block
 block discarded – undo
1791 2023
 				$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']);
1792 2024
 			}
1793 2025
 
1794
-			if ($globalDebug) echo 'Flights data...'."\n";
1795
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2026
+			if ($globalDebug) {
2027
+				echo 'Flights data...'."\n";
2028
+			}
2029
+			if ($globalDebug) {
2030
+				echo '-> countAllDatesLastMonth...'."\n";
2031
+			}
1796 2032
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1797 2033
 			foreach ($alldata as $number) {
1798 2034
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1799 2035
 			}
1800
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2036
+			if ($globalDebug) {
2037
+				echo '-> countAllDates...'."\n";
2038
+			}
1801 2039
 			//$previousdata = $this->countAllDatesByAirlines();
1802 2040
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1803 2041
 			$values = array();
@@ -1810,14 +2048,18 @@  discard block
 block discarded – undo
1810 2048
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1811 2049
 			}
1812 2050
 			
1813
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2051
+			if ($globalDebug) {
2052
+				echo '-> countAllHours...'."\n";
2053
+			}
1814 2054
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1815 2055
 			foreach ($alldata as $number) {
1816 2056
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1817 2057
 			}
1818 2058
 			
1819 2059
 
1820
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2060
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2061
+				$globalStatsFilters = array();
2062
+			}
1821 2063
 			foreach ($globalStatsFilters as $name => $filter) {
1822 2064
 				//$filter_name = $filter['name'];
1823 2065
 				$filter_name = $name;
@@ -1825,10 +2067,14 @@  discard block
 block discarded – undo
1825 2067
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1826 2068
 				if (isset($last_update[0]['value'])) {
1827 2069
 					$last_update_day = $last_update[0]['value'];
1828
-				} else $last_update_day = '2012-12-12 12:12:12';
2070
+				} else {
2071
+					$last_update_day = '2012-12-12 12:12:12';
2072
+				}
1829 2073
 
1830 2074
 				// Count by filter
1831
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2075
+				if ($globalDebug) {
2076
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2077
+				}
1832 2078
 				$Spotter = new Spotter($this->db);
1833 2079
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1834 2080
 				foreach ($alldata as $number) {
@@ -1866,7 +2112,9 @@  discard block
 block discarded – undo
1866 2112
 	    				$icao = $value['airport_departure_icao'];
1867 2113
         				if (isset($alldata[$icao])) {
1868 2114
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1869
-        				} else $alldata[$icao] = $value;
2115
+        				} else {
2116
+        					$alldata[$icao] = $value;
2117
+        				}
1870 2118
 				}
1871 2119
 	    			$count = array();
1872 2120
     				foreach ($alldata as $key => $row) {
@@ -1887,7 +2135,9 @@  discard block
 block discarded – undo
1887 2135
 	    				$icao = $value['airport_arrival_icao'];
1888 2136
         				if (isset($alldata[$icao])) {
1889 2137
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1890
-		        		} else $alldata[$icao] = $value;
2138
+		        		} else {
2139
+		        			$alldata[$icao] = $value;
2140
+		        		}
1891 2141
 	    			}
1892 2142
         			$count = array();
1893 2143
         			foreach ($alldata as $key => $row) {
@@ -1901,7 +2151,9 @@  discard block
 block discarded – undo
1901 2151
 				$alldata = $Spotter->countAllMonths($filter);
1902 2152
 				$lastyear = false;
1903 2153
 				foreach ($alldata as $number) {
1904
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2154
+					if ($number['year_name'] != date('Y')) {
2155
+						$lastyear = true;
2156
+					}
1905 2157
 					$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);
1906 2158
 				}
1907 2159
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.