Completed
Push — master ( 9321a3...c66f20 )
by Yannick
05:39
created
require/class.Stats.php 1 patch
Spacing   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,43 +64,43 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute(array(':filter_name' => $filter_name));
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         echo "error : ".$e->getMessage();
69 69
                 }
70 70
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
71 71
                 return $all;
72 72
         }
73
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
73
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
74 74
 		if ($filter_name == '') $filter_name = $this->filter_name;
75 75
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
76 76
                  try {
77 77
                         $sth = $this->db->prepare($query);
78
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
78
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
79
+                } catch (PDOException $e) {
80 80
                         echo "error : ".$e->getMessage();
81 81
                 }
82 82
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
83 83
                 return $all;
84 84
         }
85
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
85
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
86 86
 		if ($filter_name == '') $filter_name = $this->filter_name;
87 87
                 $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 88
                  try {
89 89
                         $sth = $this->db->prepare($query);
90
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
91
-                } catch(PDOException $e) {
90
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
91
+                } catch (PDOException $e) {
92 92
                         echo "error : ".$e->getMessage();
93 93
                 }
94 94
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
95 95
                 return $all;
96 96
         }
97
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
97
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
98 98
 		if ($filter_name == '') $filter_name = $this->filter_name;
99 99
                 $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 100
                  try {
101 101
                         $sth = $this->db->prepare($query);
102
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
103
-                } catch(PDOException $e) {
102
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
103
+                } catch (PDOException $e) {
104 104
                         echo "error : ".$e->getMessage();
105 105
                 }
106 106
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 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";
116 116
                  try {
117 117
                         $sth = $this->db->prepare($query);
118
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
119
-                } catch(PDOException $e) {
118
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
119
+                } catch (PDOException $e) {
120 120
                         echo "error : ".$e->getMessage();
121 121
                 }
122 122
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
123 123
                 if (empty($all)) {
124 124
             	    $filters = array('airlines' => array($stats_airline));
125 125
             	    if ($filter_name != '') {
126
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
126
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
127 127
             	    }
128 128
             	    $Spotter = new Spotter($this->db);
129
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
129
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
130 130
                 }
131 131
                 return $all;
132 132
 	}
133
-	public function countAllAirlineCountries($limit = true,$filter_name = '') {
133
+	public function countAllAirlineCountries($limit = true, $filter_name = '') {
134 134
 		global $globalStatsFilters;
135 135
 		if ($filter_name == '') $filter_name = $this->filter_name;
136 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";
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                  try {
139 139
                         $sth = $this->db->prepare($query);
140 140
                         $sth->execute(array(':filter_name' => $filter_name));
141
-                } catch(PDOException $e) {
141
+                } catch (PDOException $e) {
142 142
                         echo "error : ".$e->getMessage();
143 143
                 }
144 144
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -146,28 +146,28 @@  discard block
 block discarded – undo
146 146
             		$Spotter = new Spotter($this->db);
147 147
             		$filters = array();
148 148
             		if ($filter_name != '') {
149
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
149
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
150 150
 			}
151
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
151
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
152 152
                 }
153 153
                 return $all;
154 154
 	}
155
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
155
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 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 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";
160 160
                  try {
161 161
                         $sth = $this->db->prepare($query);
162
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
163
-                } catch(PDOException $e) {
162
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
163
+                } catch (PDOException $e) {
164 164
                         echo "error : ".$e->getMessage();
165 165
                 }
166 166
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
167 167
                 if (empty($all)) {
168 168
             		$filters = array('airlines' => array($stats_airline));
169 169
             		if ($filter_name != '') {
170
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
170
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
171 171
 			}
172 172
             		$Spotter = new Spotter($this->db);
173 173
 			$all = $Spotter->countAllAircraftManufacturers($filters);
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 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";
183 183
                  try {
184 184
                         $sth = $this->db->prepare($query);
185
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
186
-                } catch(PDOException $e) {
185
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
186
+                } catch (PDOException $e) {
187 187
                         echo "error : ".$e->getMessage();
188 188
                 }
189 189
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
190 190
                 if (empty($all)) {
191 191
 			$filters = array('airlines' => array($stats_airline));
192 192
 			if ($filter_name != '') {
193
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
194 194
 			}
195 195
 			$Spotter = new Spotter($this->db);
196
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
196
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
197 197
                 }
198 198
                 return $all;
199 199
 	}
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 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";
205 205
                  try {
206 206
                         $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
208
-                } catch(PDOException $e) {
207
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
208
+                } catch (PDOException $e) {
209 209
                         echo "error : ".$e->getMessage();
210 210
                 }
211 211
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
212 212
                 if (empty($all)) {
213 213
 			$filters = array('airlines' => array($stats_airline));
214 214
 			if ($filter_name != '') {
215
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
215
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
216 216
 			}
217 217
 			$Spotter = new Spotter($this->db);
218 218
 			$all = $Spotter->countAllDepartureCountries($filters);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 return $all;
221 221
 	}
222 222
 
223
-	public function countAllAirlines($limit = true,$filter_name = '') {
223
+	public function countAllAirlines($limit = true, $filter_name = '') {
224 224
 		global $globalStatsFilters;
225 225
 		if ($filter_name == '') $filter_name = $this->filter_name;
226 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";
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                  try {
229 229
                         $sth = $this->db->prepare($query);
230 230
                         $sth->execute(array(':filter_name' => $filter_name));
231
-                } catch(PDOException $e) {
231
+                } catch (PDOException $e) {
232 232
                         echo "error : ".$e->getMessage();
233 233
                 }
234 234
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -236,58 +236,58 @@  discard block
 block discarded – undo
236 236
 	                $Spotter = new Spotter($this->db);
237 237
             		$filters = array();
238 238
             		if ($filter_name != '') {
239
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
239
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
240 240
 			}
241 241
 
242
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
242
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
243 243
                 }
244 244
                 return $all;
245 245
 	}
246
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
246
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') {
247 247
 		global $globalStatsFilters;
248 248
 		if ($filter_name == '') $filter_name = $this->filter_name;
249 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 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";
251 251
                  try {
252 252
                         $sth = $this->db->prepare($query);
253
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
254
-                } catch(PDOException $e) {
253
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
254
+                } catch (PDOException $e) {
255 255
                         echo "error : ".$e->getMessage();
256 256
                 }
257 257
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
258 258
                 if (empty($all)) {
259 259
 			$filters = array('airlines' => array($stats_airline));
260 260
 			if ($filter_name != '') {
261
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
261
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
262 262
 			}
263 263
 	                $Spotter = new Spotter($this->db);
264
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
264
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
265 265
                 }
266 266
                 return $all;
267 267
 	}
268
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
268
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') {
269 269
 		global $globalStatsFilters;
270 270
 		if ($filter_name == '') $filter_name = $this->filter_name;
271 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 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";
273 273
 		 try {
274 274
 			$sth = $this->db->prepare($query);
275
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
276
-		} catch(PDOException $e) {
275
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
276
+		} catch (PDOException $e) {
277 277
 			echo "error : ".$e->getMessage();
278 278
 		}
279 279
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
280 280
 		if (empty($all)) {
281 281
 			$filters = array('airlines' => array($stats_airline));
282 282
 			if ($filter_name != '') {
283
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
283
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
284 284
 			}
285 285
 			$Spotter = new Spotter($this->db);
286
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
286
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
287 287
 		}
288 288
 		return $all;
289 289
 	}
290
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
290
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') {
291 291
 		$Connection = new Connection();
292 292
 		if ($filter_name == '') $filter_name = $this->filter_name;
293 293
 		if ($Connection->tableExists('countries')) {
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 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";
296 296
 			 try {
297 297
 				$sth = $this->db->prepare($query);
298
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
299
-			} catch(PDOException $e) {
298
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
299
+			} catch (PDOException $e) {
300 300
 				echo "error : ".$e->getMessage();
301 301
 			}
302 302
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -311,70 +311,70 @@  discard block
 block discarded – undo
311 311
 			return array();
312 312
 		}
313 313
 	}
314
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
314
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') {
315 315
 		global $globalStatsFilters;
316 316
 		if ($filter_name == '') $filter_name = $this->filter_name;
317 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 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";
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
322
-                } catch(PDOException $e) {
321
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
322
+                } catch (PDOException $e) {
323 323
                         echo "error : ".$e->getMessage();
324 324
                 }
325 325
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
326 326
                 if (empty($all)) {
327 327
 			$filters = array('airlines' => array($stats_airline));
328 328
 			if ($filter_name != '') {
329
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
329
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
330 330
 			}
331 331
             		$Spotter = new Spotter($this->db);
332
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
332
+            		$all = $Spotter->countAllPilots($limit, 0, '', $filters);
333 333
                 }
334 334
                 return $all;
335 335
 	}
336
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
336
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') {
337 337
 		global $globalStatsFilters;
338 338
 		if ($filter_name == '') $filter_name = $this->filter_name;
339 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 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";
341 341
                  try {
342 342
                         $sth = $this->db->prepare($query);
343
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
344
-                } catch(PDOException $e) {
343
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
344
+                } catch (PDOException $e) {
345 345
                         echo "error : ".$e->getMessage();
346 346
                 }
347 347
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
348 348
                 if (empty($all)) {
349 349
 			$filters = array('airlines' => array($stats_airline));
350 350
 			if ($filter_name != '') {
351
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
351
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
352 352
 			}
353 353
             		$Spotter = new Spotter($this->db);
354
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
354
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
355 355
                 }
356 356
                 return $all;
357 357
 	}
358
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
358
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') {
359 359
 		global $globalStatsFilters;
360 360
 		if ($filter_name == '') $filter_name = $this->filter_name;
361 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 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";
363 363
                  try {
364 364
                         $sth = $this->db->prepare($query);
365
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
366
-                } catch(PDOException $e) {
365
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
366
+                } catch (PDOException $e) {
367 367
                         echo "error : ".$e->getMessage();
368 368
                 }
369 369
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
370 370
                 if (empty($all)) {
371 371
 			$filters = array('airlines' => array($stats_airline));
372 372
             		if ($filter_name != '') {
373
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
373
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
374 374
 			}
375 375
             		$Spotter = new Spotter($this->db);
376
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
377
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
376
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
377
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
378 378
         		$all = array();
379 379
         		foreach ($pall as $value) {
380 380
         			$icao = $value['airport_departure_icao'];
@@ -391,30 +391,30 @@  discard block
 block discarded – undo
391 391
         		foreach ($all as $key => $row) {
392 392
         			$count[$key] = $row['airport_departure_icao_count'];
393 393
         		}
394
-        		array_multisort($count,SORT_DESC,$all);
394
+        		array_multisort($count, SORT_DESC, $all);
395 395
                 }
396 396
                 return $all;
397 397
 	}
398
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
398
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') {
399 399
 		global $globalStatsFilters;
400 400
 		if ($filter_name == '') $filter_name = $this->filter_name;
401 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 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";
403 403
 		try {
404 404
 			$sth = $this->db->prepare($query);
405
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
406
-		} catch(PDOException $e) {
405
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
406
+		} catch (PDOException $e) {
407 407
 			echo "error : ".$e->getMessage();
408 408
 		}
409 409
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
410 410
 		if (empty($all)) {
411 411
 			$filters = array('airlines' => array($stats_airline));
412 412
 			if ($filter_name != '') {
413
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
413
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			$Spotter = new Spotter($this->db);
416
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
417
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
416
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
417
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
418 418
         		$all = array();
419 419
         		foreach ($pall as $value) {
420 420
         			$icao = $value['airport_arrival_icao'];
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
         		foreach ($all as $key => $row) {
432 432
         			$count[$key] = $row['airport_arrival_icao_count'];
433 433
         		}
434
-        		array_multisort($count,SORT_DESC,$all);
434
+        		array_multisort($count, SORT_DESC, $all);
435 435
                 }
436 436
  
437 437
                 return $all;
438 438
 	}
439
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
439
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
440 440
 		global $globalDBdriver, $globalStatsFilters;
441 441
 		if ($filter_name == '') $filter_name = $this->filter_name;
442 442
 		if ($globalDBdriver == 'mysql') {
@@ -446,18 +446,18 @@  discard block
 block discarded – undo
446 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 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";
448 448
 		}
449
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
449
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
450 450
                  try {
451 451
                         $sth = $this->db->prepare($query);
452 452
                         $sth->execute($query_data);
453
-                } catch(PDOException $e) {
453
+                } catch (PDOException $e) {
454 454
                         echo "error : ".$e->getMessage();
455 455
                 }
456 456
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
457 457
                 if (empty($all)) {
458 458
 			$filters = array('airlines' => array($stats_airline));
459 459
 			if ($filter_name != '') {
460
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
460
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
461 461
 			}
462 462
             		$Spotter = new Spotter($this->db);
463 463
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -466,29 +466,29 @@  discard block
 block discarded – undo
466 466
                 return $all;
467 467
 	}
468 468
 	
469
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
469
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
470 470
 		global $globalStatsFilters;
471 471
 		if ($filter_name == '') $filter_name = $this->filter_name;
472 472
 		$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
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
473
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
474 474
                  try {
475 475
                         $sth = $this->db->prepare($query);
476 476
                         $sth->execute($query_data);
477
-                } catch(PDOException $e) {
477
+                } catch (PDOException $e) {
478 478
                         echo "error : ".$e->getMessage();
479 479
                 }
480 480
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
481 481
                 if (empty($all)) {
482 482
 			$filters = array('airlines' => array($stats_airline));
483 483
 			if ($filter_name != '') {
484
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
484
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
485 485
 			}
486 486
             		$Spotter = new Spotter($this->db);
487 487
             		$all = $Spotter->countAllDatesLastMonth($filters);
488 488
                 }
489 489
                 return $all;
490 490
 	}
491
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
491
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
492 492
 		global $globalDBdriver, $globalStatsFilters;
493 493
 		if ($filter_name == '') $filter_name = $this->filter_name;
494 494
 		if ($globalDBdriver == 'mysql') {
@@ -496,40 +496,40 @@  discard block
 block discarded – undo
496 496
 		} else {
497 497
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
498 498
 		}
499
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
499
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
500 500
                  try {
501 501
                         $sth = $this->db->prepare($query);
502 502
                         $sth->execute($query_data);
503
-                } catch(PDOException $e) {
503
+                } catch (PDOException $e) {
504 504
                         echo "error : ".$e->getMessage();
505 505
                 }
506 506
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
507 507
                 if (empty($all)) {
508 508
 			$filters = array('airlines' => array($stats_airline));
509 509
 			if ($filter_name != '') {
510
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
510
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
511 511
 			}
512 512
             		$Spotter = new Spotter($this->db);
513 513
             		$all = $Spotter->countAllDatesLast7Days($filters);
514 514
                 }
515 515
                 return $all;
516 516
 	}
517
-	public function countAllDates($stats_airline = '',$filter_name = '') {
517
+	public function countAllDates($stats_airline = '', $filter_name = '') {
518 518
 		global $globalStatsFilters;
519 519
 		if ($filter_name == '') $filter_name = $this->filter_name;
520 520
 		$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
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
521
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
522 522
                  try {
523 523
                         $sth = $this->db->prepare($query);
524 524
                         $sth->execute($query_data);
525
-                } catch(PDOException $e) {
525
+                } catch (PDOException $e) {
526 526
                         echo "error : ".$e->getMessage();
527 527
                 }
528 528
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
529 529
                 if (empty($all)) {
530 530
 			$filters = array('airlines' => array($stats_airline));
531 531
 			if ($filter_name != '') {
532
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
532
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
533 533
 			}
534 534
             		$Spotter = new Spotter($this->db);
535 535
             		$all = $Spotter->countAllDates($filters);
@@ -544,35 +544,35 @@  discard block
 block discarded – undo
544 544
                  try {
545 545
                         $sth = $this->db->prepare($query);
546 546
                         $sth->execute($query_data);
547
-                } catch(PDOException $e) {
547
+                } catch (PDOException $e) {
548 548
                         echo "error : ".$e->getMessage();
549 549
                 }
550 550
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
551 551
                 if (empty($all)) {
552 552
             		$filters = array();
553 553
             		if ($filter_name != '') {
554
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
555 555
 			}
556 556
             		$Spotter = new Spotter($this->db);
557 557
             		$all = $Spotter->countAllDatesByAirlines($filters);
558 558
                 }
559 559
                 return $all;
560 560
 	}
561
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
561
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
562 562
 		global $globalStatsFilters;
563 563
 		if ($filter_name == '') $filter_name = $this->filter_name;
564 564
 	    	$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 565
                  try {
566 566
                         $sth = $this->db->prepare($query);
567 567
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
568
-                } catch(PDOException $e) {
568
+                } catch (PDOException $e) {
569 569
                         echo "error : ".$e->getMessage();
570 570
                 }
571 571
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
572 572
                 if (empty($all)) {
573 573
 			$filters = array('airlines' => array($stats_airline));
574 574
 			if ($filter_name != '') {
575
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
575
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
576 576
 			}
577 577
             		$Spotter = new Spotter($this->db);
578 578
             		$all = $Spotter->countAllMonths($filters);
@@ -586,21 +586,21 @@  discard block
 block discarded – undo
586 586
                  try {
587 587
                         $sth = $this->db->prepare($query);
588 588
                         $sth->execute(array(':filter_name' => $filter_name));
589
-                } catch(PDOException $e) {
589
+                } catch (PDOException $e) {
590 590
                         echo "error : ".$e->getMessage();
591 591
                 }
592 592
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
593 593
                 if (empty($all)) {
594 594
             		$filters = array();
595 595
             		if ($filter_name != '') {
596
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
596
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
597 597
 			}
598 598
             		$Spotter = new Spotter($this->db);
599 599
             		$all = $Spotter->countAllMilitaryMonths($filters);
600 600
                 }
601 601
                 return $all;
602 602
 	}
603
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
603
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
604 604
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
605 605
 		if ($filter_name == '') $filter_name = $this->filter_name;
606 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";
@@ -617,17 +617,17 @@  discard block
 block discarded – undo
617 617
                  try {
618 618
                         $sth = $this->db->prepare($query);
619 619
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
620
-                } catch(PDOException $e) {
620
+                } catch (PDOException $e) {
621 621
                         echo "error : ".$e->getMessage();
622 622
                 }
623 623
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
624 624
                 if (empty($all)) {
625 625
 			$filters = array('airlines' => array($stats_airline));
626 626
 			if ($filter_name != '') {
627
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
627
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
628 628
 			}
629 629
             		$Spotter = new Spotter($this->db);
630
-            		$all = $Spotter->countAllHours($orderby,$filters);
630
+            		$all = $Spotter->countAllHours($orderby, $filters);
631 631
                 }
632 632
                 return $all;
633 633
 	}
@@ -635,11 +635,11 @@  discard block
 block discarded – undo
635 635
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
636 636
 		global $globalStatsFilters;
637 637
 		if ($filter_name == '') $filter_name = $this->filter_name;
638
-		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
638
+		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name);
639 639
 		if (empty($all)) {
640 640
 			$filters = array('airlines' => array($stats_airline));
641 641
 			if ($filter_name != '') {
642
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
642
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
643 643
 			}
644 644
 			$Spotter = new Spotter($this->db);
645 645
 			$all = $Spotter->countOverallFlights($filters);
@@ -649,39 +649,39 @@  discard block
 block discarded – undo
649 649
 	public function countOverallMilitaryFlights($filter_name = '') {
650 650
 		global $globalStatsFilters;
651 651
 		if ($filter_name == '') $filter_name = $this->filter_name;
652
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
652
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name);
653 653
 		if (empty($all)) {
654 654
 		        $filters = array();
655 655
             		if ($filter_name != '') {
656
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
657 657
 			}
658 658
 			$Spotter = new Spotter($this->db);
659 659
 			$all = $Spotter->countOverallMilitaryFlights($filters);
660 660
 		}
661 661
 		return $all;
662 662
 	}
663
-	public function countOverallArrival($stats_airline = '',$filter_name = '') {
663
+	public function countOverallArrival($stats_airline = '', $filter_name = '') {
664 664
 		global $globalStatsFilters;
665 665
 		if ($filter_name == '') $filter_name = $this->filter_name;
666
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
666
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name);
667 667
 		if (empty($all)) {
668 668
 			$filters = array('airlines' => array($stats_airline));
669 669
 			if ($filter_name != '') {
670
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
670
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
671 671
 			}
672 672
 			$Spotter = new Spotter($this->db);
673 673
 			$all = $Spotter->countOverallArrival($filters);
674 674
 		}
675 675
 		return $all;
676 676
 	}
677
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
677
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '') {
678 678
 		global $globalStatsFilters;
679 679
 		if ($filter_name == '') $filter_name = $this->filter_name;
680
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
680
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name);
681 681
 		if (empty($all)) {
682 682
 			$filters = array('airlines' => array($stats_airline));
683 683
 			if ($filter_name != '') {
684
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
684
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
685 685
 			}
686 686
 			$Spotter = new Spotter($this->db);
687 687
 			$all = $Spotter->countOverallAircrafts($filters);
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                  try {
696 696
                         $sth = $this->db->prepare($query);
697 697
                         $sth->execute(array(':filter_name' => $filter_name));
698
-                } catch(PDOException $e) {
698
+                } catch (PDOException $e) {
699 699
                         echo "error : ".$e->getMessage();
700 700
                 }
701 701
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -704,14 +704,14 @@  discard block
 block discarded – undo
704 704
 		if (empty($all)) {
705 705
             		$filters = array();
706 706
             		if ($filter_name != '') {
707
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
707
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
708 708
 			}
709 709
 			$Spotter = new Spotter($this->db);
710 710
 			$all = $Spotter->countOverallAirlines($filters);
711 711
 		}
712 712
 		return $all;
713 713
 	}
714
-	public function countOverallOwners($stats_airline = '',$filter_name = '') {
714
+	public function countOverallOwners($stats_airline = '', $filter_name = '') {
715 715
 		global $globalStatsFilters;
716 716
 		if ($filter_name == '') $filter_name = $this->filter_name;
717 717
 		/*
@@ -725,25 +725,25 @@  discard block
 block discarded – undo
725 725
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
726 726
                 $all = $result[0]['nb_owner'];
727 727
                 */
728
-		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name);
728
+		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name);
729 729
 		if (empty($all)) {
730 730
 			$filters = array('airlines' => array($stats_airline));
731 731
 			if ($filter_name != '') {
732
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
732
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
733 733
 			}
734 734
 			$Spotter = new Spotter($this->db);
735 735
 			$all = $Spotter->countOverallOwners($filters);
736 736
 		}
737 737
 		return $all;
738 738
 	}
739
-	public function countOverallPilots($stats_airline = '',$filter_name = '') {
739
+	public function countOverallPilots($stats_airline = '', $filter_name = '') {
740 740
 		global $globalStatsFilters;
741 741
 		if ($filter_name == '') $filter_name = $this->filter_name;
742
-		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
742
+		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name);
743 743
 		if (empty($all)) {
744 744
 			$filters = array('airlines' => array($stats_airline));
745 745
 			if ($filter_name != '') {
746
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
746
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
747 747
 			}
748 748
 			$Spotter = new Spotter($this->db);
749 749
 			$all = $Spotter->countOverallPilots($filters);
@@ -751,33 +751,33 @@  discard block
 block discarded – undo
751 751
 		return $all;
752 752
 	}
753 753
 
754
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
754
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
755 755
 		if ($filter_name == '') $filter_name = $this->filter_name;
756 756
 		$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
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
757
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
758 758
                  try {
759 759
                         $sth = $this->db->prepare($query);
760 760
                         $sth->execute($query_values);
761
-                } catch(PDOException $e) {
761
+                } catch (PDOException $e) {
762 762
                         echo "error : ".$e->getMessage();
763 763
                 }
764 764
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
765 765
                 return $all;
766 766
 	}
767
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
767
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
768 768
 		if ($filter_name == '') $filter_name = $this->filter_name;
769 769
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
770
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
770
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
771 771
                  try {
772 772
                         $sth = $this->db->prepare($query);
773 773
                         $sth->execute($query_values);
774
-                } catch(PDOException $e) {
774
+                } catch (PDOException $e) {
775 775
                         echo "error : ".$e->getMessage();
776 776
                 }
777 777
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
778 778
                 return $all;
779 779
         }
780
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
780
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') {
781 781
 		if ($filter_name == '') $filter_name = $this->filter_name;
782 782
     		global $globalArchiveMonths, $globalDBdriver;
783 783
     		if ($globalDBdriver == 'mysql') {
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 	        } else {
786 786
             		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
787 787
                 }
788
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
788
+                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
789 789
                  try {
790 790
                         $sth = $this->db->prepare($query);
791 791
                         $sth->execute($query_values);
792
-                } catch(PDOException $e) {
792
+                } catch (PDOException $e) {
793 793
                         echo "error : ".$e->getMessage();
794 794
                 }
795 795
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
                  try {
808 808
                         $sth = $this->db->prepare($query);
809 809
                         $sth->execute($query_values);
810
-                } catch(PDOException $e) {
810
+                } catch (PDOException $e) {
811 811
                         echo "error : ".$e->getMessage();
812 812
                 }
813 813
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
                  try {
825 825
                         $sth = $this->db->prepare($query);
826 826
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
827
-                } catch(PDOException $e) {
827
+                } catch (PDOException $e) {
828 828
                         echo "error : ".$e->getMessage();
829 829
                 }
830 830
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
                  try {
842 842
                         $sth = $this->db->prepare($query);
843 843
                         $sth->execute(array(':filter_name' => $filter_name));
844
-                } catch(PDOException $e) {
844
+                } catch (PDOException $e) {
845 845
                         echo "error : ".$e->getMessage();
846 846
                 }
847 847
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
                  try {
859 859
                         $sth = $this->db->prepare($query);
860 860
                         $sth->execute(array(':filter_name' => $filter_name));
861
-                } catch(PDOException $e) {
861
+                } catch (PDOException $e) {
862 862
                         echo "error : ".$e->getMessage();
863 863
                 }
864 864
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -875,14 +875,14 @@  discard block
 block discarded – undo
875 875
                  try {
876 876
                         $sth = $this->db->prepare($query);
877 877
                         $sth->execute(array(':filter_name' => $filter_name));
878
-                } catch(PDOException $e) {
878
+                } catch (PDOException $e) {
879 879
                         echo "error : ".$e->getMessage();
880 880
                 }
881 881
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
882 882
                 return $all[0]['total'];
883 883
         }
884 884
 
885
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
885
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
886 886
 		global $globalDBdriver;
887 887
 		if ($filter_name == '') $filter_name = $this->filter_name;
888 888
 		if ($globalDBdriver == 'mysql') {
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
                 } else {
891 891
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
892 892
 		}
893
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
893
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
894 894
                  try {
895 895
                         $sth = $this->db->prepare($query);
896 896
                         $sth->execute($query_values);
897
-                } catch(PDOException $e) {
897
+                } catch (PDOException $e) {
898 898
                         return "error : ".$e->getMessage();
899 899
                 }
900 900
         }
901
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
901
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
902 902
 		global $globalDBdriver;
903 903
 		if ($filter_name == '') $filter_name = $this->filter_name;
904 904
 		if ($globalDBdriver == 'mysql') {
@@ -907,219 +907,219 @@  discard block
 block discarded – undo
907 907
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
908 908
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
909 909
                 }
910
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
910
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
911 911
                  try {
912 912
                         $sth = $this->db->prepare($query);
913 913
                         $sth->execute($query_values);
914
-                } catch(PDOException $e) {
914
+                } catch (PDOException $e) {
915 915
                         return "error : ".$e->getMessage();
916 916
                 }
917 917
         }
918
-	public function getStatsSource($date,$stats_type = '') {
918
+	public function getStatsSource($date, $stats_type = '') {
919 919
 		if ($stats_type == '') {
920 920
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
921 921
 			$query_values = array(':date' => $date);
922 922
 		} else {
923 923
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
924
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
924
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
925 925
 		}
926 926
                  try {
927 927
                         $sth = $this->db->prepare($query);
928 928
                         $sth->execute($query_values);
929
-                } catch(PDOException $e) {
929
+                } catch (PDOException $e) {
930 930
                         echo "error : ".$e->getMessage();
931 931
                 }
932 932
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
933 933
                 return $all;
934 934
         }
935 935
 
936
-	public function addStatSource($data,$source_name,$stats_type,$date) {
936
+	public function addStatSource($data, $source_name, $stats_type, $date) {
937 937
 		global $globalDBdriver;
938 938
 		if ($globalDBdriver == 'mysql') {
939 939
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
940 940
 		} else {
941 941
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
942 942
                 }
943
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
943
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
944 944
                  try {
945 945
                         $sth = $this->db->prepare($query);
946 946
                         $sth->execute($query_values);
947
-                } catch(PDOException $e) {
947
+                } catch (PDOException $e) {
948 948
                         return "error : ".$e->getMessage();
949 949
                 }
950 950
         }
951
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
951
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
952 952
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
953
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
953
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
954 954
                  try {
955 955
                         $sth = $this->db->prepare($query);
956 956
                         $sth->execute($query_values);
957
-                } catch(PDOException $e) {
957
+                } catch (PDOException $e) {
958 958
                         return "error : ".$e->getMessage();
959 959
                 }
960 960
         }
961
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
961
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') {
962 962
 		global $globalDBdriver;
963 963
 		if ($globalDBdriver == 'mysql') {
964 964
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
965 965
 		} else {
966 966
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
967 967
 		}
968
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
968
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
969 969
                  try {
970 970
                         $sth = $this->db->prepare($query);
971 971
                         $sth->execute($query_values);
972
-                } catch(PDOException $e) {
972
+                } catch (PDOException $e) {
973 973
                         return "error : ".$e->getMessage();
974 974
                 }
975 975
         }
976
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
976
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') {
977 977
 		global $globalDBdriver;
978 978
 		if ($globalDBdriver == 'mysql') {
979 979
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
980 980
 		} else {
981 981
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
982 982
 		}
983
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
983
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
984 984
                  try {
985 985
                         $sth = $this->db->prepare($query);
986 986
                         $sth->execute($query_values);
987
-                } catch(PDOException $e) {
987
+                } catch (PDOException $e) {
988 988
                         return "error : ".$e->getMessage();
989 989
                 }
990 990
         }
991
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
991
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') {
992 992
 		global $globalDBdriver;
993 993
 		if ($globalDBdriver == 'mysql') {
994 994
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
995 995
 		} else {
996 996
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
997 997
 		}
998
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
998
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
999 999
                  try {
1000 1000
                         $sth = $this->db->prepare($query);
1001 1001
                         $sth->execute($query_values);
1002
-                } catch(PDOException $e) {
1002
+                } catch (PDOException $e) {
1003 1003
                         return "error : ".$e->getMessage();
1004 1004
                 }
1005 1005
         }
1006
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
1006
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
1007 1007
 		global $globalDBdriver;
1008 1008
 		if ($globalDBdriver == 'mysql') {
1009 1009
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline";
1010 1010
 		} else {
1011 1011
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1012 1012
 		}
1013
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1013
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1014 1014
                  try {
1015 1015
                         $sth = $this->db->prepare($query);
1016 1016
                         $sth->execute($query_values);
1017
-                } catch(PDOException $e) {
1017
+                } catch (PDOException $e) {
1018 1018
                         return "error : ".$e->getMessage();
1019 1019
                 }
1020 1020
         }
1021
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
1021
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') {
1022 1022
 		global $globalDBdriver;
1023 1023
 		if ($globalDBdriver == 'mysql') {
1024 1024
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
1025 1025
 		} else {
1026 1026
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1027 1027
 		}
1028
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1028
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1029 1029
                  try {
1030 1030
                         $sth = $this->db->prepare($query);
1031 1031
                         $sth->execute($query_values);
1032
-                } catch(PDOException $e) {
1032
+                } catch (PDOException $e) {
1033 1033
                         return "error : ".$e->getMessage();
1034 1034
                 }
1035 1035
         }
1036
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1036
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') {
1037 1037
 		global $globalDBdriver;
1038 1038
 		if ($globalDBdriver == 'mysql') {
1039 1039
 			$query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
1040 1040
 		} else {
1041 1041
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1042 1042
 		}
1043
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1043
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1044 1044
                  try {
1045 1045
                         $sth = $this->db->prepare($query);
1046 1046
                         $sth->execute($query_values);
1047
-                } catch(PDOException $e) {
1047
+                } catch (PDOException $e) {
1048 1048
                         return "error : ".$e->getMessage();
1049 1049
                 }
1050 1050
         }
1051
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') {
1051
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '') {
1052 1052
 		global $globalDBdriver;
1053 1053
 		if ($globalDBdriver == 'mysql') {
1054 1054
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name";
1055 1055
 		} else {
1056 1056
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1057 1057
 		}
1058
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1058
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1059 1059
                  try {
1060 1060
                         $sth = $this->db->prepare($query);
1061 1061
                         $sth->execute($query_values);
1062
-                } catch(PDOException $e) {
1062
+                } catch (PDOException $e) {
1063 1063
                         return "error : ".$e->getMessage();
1064 1064
                 }
1065 1065
         }
1066
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1066
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1067 1067
 		global $globalDBdriver;
1068 1068
 		if ($globalDBdriver == 'mysql') {
1069 1069
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure";
1070 1070
 		} else {
1071 1071
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1072 1072
 		}
1073
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1073
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1074 1074
                  try {
1075 1075
                         $sth = $this->db->prepare($query);
1076 1076
                         $sth->execute($query_values);
1077
-                } catch(PDOException $e) {
1077
+                } catch (PDOException $e) {
1078 1078
                         return "error : ".$e->getMessage();
1079 1079
                 }
1080 1080
         }
1081
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1081
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1082 1082
 		global $globalDBdriver;
1083 1083
 		if ($globalDBdriver == 'mysql') {
1084 1084
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure";
1085 1085
 		} else {
1086 1086
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1087 1087
 		}
1088
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1088
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1089 1089
                  try {
1090 1090
                         $sth = $this->db->prepare($query);
1091 1091
                         $sth->execute($query_values);
1092
-                } catch(PDOException $e) {
1092
+                } catch (PDOException $e) {
1093 1093
                         return "error : ".$e->getMessage();
1094 1094
                 }
1095 1095
         }
1096
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1096
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1097 1097
 		global $globalDBdriver;
1098 1098
 		if ($globalDBdriver == 'mysql') {
1099 1099
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
1100 1100
 		} else {
1101 1101
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1102 1102
 		}
1103
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1103
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1104 1104
                  try {
1105 1105
                         $sth = $this->db->prepare($query);
1106 1106
                         $sth->execute($query_values);
1107
-                } catch(PDOException $e) {
1107
+                } catch (PDOException $e) {
1108 1108
                         return "error : ".$e->getMessage();
1109 1109
                 }
1110 1110
         }
1111
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1111
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1112 1112
 		global $globalDBdriver;
1113 1113
 		if ($globalDBdriver == 'mysql') {
1114 1114
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival";
1115 1115
 		} else {
1116 1116
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1117 1117
 		}
1118
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1118
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1119 1119
                  try {
1120 1120
                         $sth = $this->db->prepare($query);
1121 1121
                         $sth->execute($query_values);
1122
-                } catch(PDOException $e) {
1122
+                } catch (PDOException $e) {
1123 1123
                         return "error : ".$e->getMessage();
1124 1124
                 }
1125 1125
         }
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                  try {
1131 1131
                         $sth = $this->db->prepare($query);
1132 1132
                         $sth->execute($query_values);
1133
-                } catch(PDOException $e) {
1133
+                } catch (PDOException $e) {
1134 1134
                         return "error : ".$e->getMessage();
1135 1135
                 }
1136 1136
         }
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
                  try {
1141 1141
                         $sth = $this->db->prepare($query);
1142 1142
                         $sth->execute($query_values);
1143
-                } catch(PDOException $e) {
1143
+                } catch (PDOException $e) {
1144 1144
                         return "error : ".$e->getMessage();
1145 1145
                 }
1146 1146
         }
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
                  try {
1151 1151
                         $sth = $this->db->prepare($query);
1152 1152
                         $sth->execute($query_values);
1153
-                } catch(PDOException $e) {
1153
+                } catch (PDOException $e) {
1154 1154
                         return "error : ".$e->getMessage();
1155 1155
                 }
1156 1156
         }
@@ -1389,40 +1389,40 @@  discard block
 block discarded – undo
1389 1389
 				$last_update_day = $last_update[0]['value'];
1390 1390
 			} else $last_update_day = '2012-12-12 12:12:12';
1391 1391
 			$Spotter = new Spotter($this->db);
1392
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1392
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1393 1393
 			foreach ($alldata as $number) {
1394
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1394
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']);
1395 1395
 			}
1396 1396
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1397
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1397
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1398 1398
 			foreach ($alldata as $number) {
1399
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1399
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1400 1400
 			}
1401 1401
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1402
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1402
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1403 1403
 			foreach ($alldata as $number) {
1404
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1404
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1405 1405
 			}
1406 1406
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1407
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1407
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1408 1408
 			foreach ($alldata as $number) {
1409
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1409
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1410 1410
 			}
1411 1411
 			if ($globalDebug) echo 'Count all owners...'."\n";
1412
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1412
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1413 1413
 			foreach ($alldata as $number) {
1414
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1414
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1415 1415
 			}
1416 1416
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1417
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1417
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1418 1418
 			foreach ($alldata as $number) {
1419
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);
1419
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source']);
1420 1420
 			}
1421 1421
 			
1422 1422
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1423
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1423
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1424 1424
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1425
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1425
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1426 1426
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1427 1427
 	        	$alldata = array();
1428 1428
 	        	
@@ -1440,14 +1440,14 @@  discard block
 block discarded – undo
1440 1440
     			foreach ($alldata as $key => $row) {
1441 1441
     				$count[$key] = $row['airport_departure_icao_count'];
1442 1442
         		}
1443
-			array_multisort($count,SORT_DESC,$alldata);
1443
+			array_multisort($count, SORT_DESC, $alldata);
1444 1444
 			foreach ($alldata as $number) {
1445
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1445
+				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 1446
 			}
1447 1447
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1448
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1448
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1449 1449
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1450
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1450
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1451 1451
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1452 1452
 	        	$alldata = array();
1453 1453
     			foreach ($pall as $value) {
@@ -1464,16 +1464,16 @@  discard block
 block discarded – undo
1464 1464
         		foreach ($alldata as $key => $row) {
1465 1465
         			$count[$key] = $row['airport_arrival_icao_count'];
1466 1466
 	        	}
1467
-    			array_multisort($count,SORT_DESC,$alldata);
1467
+    			array_multisort($count, SORT_DESC, $alldata);
1468 1468
                         foreach ($alldata as $number) {
1469
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1469
+				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 1470
 			}
1471 1471
 			if ($Connection->tableExists('countries')) {
1472 1472
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1473 1473
 				$SpotterArchive = new SpotterArchive();
1474
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1474
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1475 1475
 				foreach ($alldata as $number) {
1476
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1476
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1477 1477
 				}
1478 1478
 			}
1479 1479
 			
@@ -1487,37 +1487,37 @@  discard block
 block discarded – undo
1487 1487
 			$lastyear = false;
1488 1488
 			foreach ($alldata as $number) {
1489 1489
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1490
-				$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'])));
1490
+				$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 1491
 			}
1492 1492
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1493 1493
 			$alldata = $Spotter->countAllMilitaryMonths();
1494 1494
 			foreach ($alldata as $number) {
1495
-				$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'])));
1495
+				$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 1496
 			}
1497 1497
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1498 1498
 			$alldata = $Spotter->countAllMonthsOwners();
1499 1499
 			foreach ($alldata as $number) {
1500
-				$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'])));
1500
+				$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 1501
 			}
1502 1502
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1503 1503
 			$alldata = $Spotter->countAllMonthsPilots();
1504 1504
 			foreach ($alldata as $number) {
1505
-				$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'])));
1505
+				$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 1506
 			}
1507 1507
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1508 1508
 			$alldata = $Spotter->countAllMonthsAirlines();
1509 1509
 			foreach ($alldata as $number) {
1510
-				$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'])));
1510
+				$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 1511
 			}
1512 1512
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1513 1513
 			$alldata = $Spotter->countAllMonthsAircrafts();
1514 1514
 			foreach ($alldata as $number) {
1515
-				$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'])));
1515
+				$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 1516
 			}
1517 1517
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1518 1518
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1519 1519
 			foreach ($alldata as $number) {
1520
-				$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'])));
1520
+				$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 1521
 			}
1522 1522
 			if ($globalDebug) echo 'Airports data...'."\n";
1523 1523
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
     			}
1563 1563
     			$alldata = $pall;
1564 1564
 			foreach ($alldata as $number) {
1565
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1565
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1566 1566
 			}
1567 1567
 			echo '...Arrival'."\n";
1568 1568
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
     			}
1605 1605
     			$alldata = $pall;
1606 1606
 			foreach ($alldata as $number) {
1607
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1607
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1608 1608
 			}
1609 1609
 
1610 1610
 			echo 'Flights data...'."\n";
@@ -1612,28 +1612,28 @@  discard block
 block discarded – undo
1612 1612
 			echo '-> countAllDatesLastMonth...'."\n";
1613 1613
 			$alldata = $Spotter->countAllDatesLastMonth();
1614 1614
 			foreach ($alldata as $number) {
1615
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1615
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1616 1616
 			}
1617 1617
 			echo '-> countAllDates...'."\n";
1618 1618
 			$previousdata = $this->countAllDates();
1619 1619
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1620 1620
 			$this->deleteStatFlight('date');
1621
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1621
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1622 1622
 			$values = array();
1623 1623
 			foreach ($alldata as $cnt) {
1624 1624
 				$values[] = $cnt['date_count'];
1625 1625
 			}
1626
-			array_multisort($values,SORT_DESC,$alldata);
1627
-			array_splice($alldata,11);
1626
+			array_multisort($values, SORT_DESC, $alldata);
1627
+			array_splice($alldata, 11);
1628 1628
 			foreach ($alldata as $number) {
1629
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1629
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1630 1630
 			}
1631 1631
 			
1632 1632
 			$this->deleteStatFlight('hour');
1633 1633
 			echo '-> countAllHours...'."\n";
1634 1634
 			$alldata = $Spotter->countAllHours('hour');
1635 1635
 			foreach ($alldata as $number) {
1636
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1636
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1637 1637
 			}
1638 1638
 
1639 1639
 
@@ -1642,34 +1642,34 @@  discard block
 block discarded – undo
1642 1642
 			echo '--- Stats by airlines ---'."\n";
1643 1643
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1644 1644
 			$Spotter = new Spotter($this->db);
1645
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1645
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1646 1646
 			foreach ($alldata as $number) {
1647
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1647
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']);
1648 1648
 			}
1649 1649
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1650
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1650
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1651 1651
 			foreach ($alldata as $number) {
1652
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1652
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']);
1653 1653
 			}
1654 1654
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1655
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1655
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1656 1656
 			foreach ($alldata as $number) {
1657
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1657
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1658 1658
 			}
1659 1659
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1660
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1660
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1661 1661
 			foreach ($alldata as $number) {
1662
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1662
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']);
1663 1663
 			}
1664 1664
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1665
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1665
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1666 1666
 			foreach ($alldata as $number) {
1667
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);
1667
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source']);
1668 1668
 			}
1669 1669
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1670
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1670
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1671 1671
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1672
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1672
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1673 1673
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1674 1674
 	        	//$alldata = array();
1675 1675
     			foreach ($dall as $value) {
@@ -1689,12 +1689,12 @@  discard block
 block discarded – undo
1689 1689
     			}
1690 1690
     			$alldata = $pall;
1691 1691
 			foreach ($alldata as $number) {
1692
-				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']);
1692
+				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 1693
 			}
1694 1694
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1695
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1695
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1696 1696
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1697
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1697
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1698 1698
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1699 1699
 	        	//$alldata = array();
1700 1700
     			foreach ($dall as $value) {
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
     			}
1715 1715
     			$alldata = $pall;
1716 1716
                         foreach ($alldata as $number) {
1717
-				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']);
1717
+				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 1718
 			}
1719 1719
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1720 1720
 			$Spotter = new Spotter($this->db);
@@ -1722,27 +1722,27 @@  discard block
 block discarded – undo
1722 1722
 			$lastyear = false;
1723 1723
 			foreach ($alldata as $number) {
1724 1724
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1725
-				$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']);
1725
+				$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 1726
 			}
1727 1727
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1728 1728
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1729 1729
 			foreach ($alldata as $number) {
1730
-				$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']);
1730
+				$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 1731
 			}
1732 1732
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1733 1733
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1734 1734
 			foreach ($alldata as $number) {
1735
-				$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']);
1735
+				$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 1736
 			}
1737 1737
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1738 1738
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1739 1739
 			foreach ($alldata as $number) {
1740
-				$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']);
1740
+				$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 1741
 			}
1742 1742
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1743 1743
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1744 1744
 			foreach ($alldata as $number) {
1745
-				$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']);
1745
+				$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 1746
 			}
1747 1747
 			if ($globalDebug) echo '...Departure'."\n";
1748 1748
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
     			}
1766 1766
     			$alldata = $pall;
1767 1767
 			foreach ($alldata as $number) {
1768
-				$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']);
1768
+				$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 1769
 			}
1770 1770
 			if ($globalDebug) echo '...Arrival'."\n";
1771 1771
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1788,32 +1788,32 @@  discard block
 block discarded – undo
1788 1788
     			}
1789 1789
     			$alldata = $pall;
1790 1790
 			foreach ($alldata as $number) {
1791
-				$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']);
1791
+				$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 1792
 			}
1793 1793
 
1794 1794
 			if ($globalDebug) echo 'Flights data...'."\n";
1795 1795
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1796 1796
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1797 1797
 			foreach ($alldata as $number) {
1798
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1798
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1799 1799
 			}
1800 1800
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1801 1801
 			//$previousdata = $this->countAllDatesByAirlines();
1802
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1802
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1803 1803
 			$values = array();
1804 1804
 			foreach ($alldata as $cnt) {
1805 1805
 				$values[] = $cnt['date_count'];
1806 1806
 			}
1807
-			array_multisort($values,SORT_DESC,$alldata);
1808
-			array_splice($alldata,11);
1807
+			array_multisort($values, SORT_DESC, $alldata);
1808
+			array_splice($alldata, 11);
1809 1809
 			foreach ($alldata as $number) {
1810
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1810
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1811 1811
 			}
1812 1812
 			
1813 1813
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1814 1814
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1815 1815
 			foreach ($alldata as $number) {
1816
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1816
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1817 1817
 			}
1818 1818
 			
1819 1819
 
@@ -1830,33 +1830,33 @@  discard block
 block discarded – undo
1830 1830
 				// Count by filter
1831 1831
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1832 1832
 				$Spotter = new Spotter($this->db);
1833
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1833
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1834 1834
 				foreach ($alldata as $number) {
1835
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name);
1835
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name);
1836 1836
 				}
1837
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1837
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1838 1838
 				foreach ($alldata as $number) {
1839
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name);
1839
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name);
1840 1840
 				}
1841
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1841
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1842 1842
 				foreach ($alldata as $number) {
1843
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name);
1843
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name);
1844 1844
 				}
1845
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1845
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1846 1846
 				foreach ($alldata as $number) {
1847
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name);
1847
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name);
1848 1848
 				}
1849
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1849
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1850 1850
 				foreach ($alldata as $number) {
1851
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name);
1851
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name);
1852 1852
 				}
1853
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1853
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1854 1854
 				foreach ($alldata as $number) {
1855
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']);
1855
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source']);
1856 1856
 				}
1857 1857
     			
1858
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1859
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1858
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1859
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1860 1860
 		        	$alldata = array();
1861 1861
 	    			foreach ($pall as $value) {
1862 1862
 		        		$icao = $value['airport_departure_icao'];
@@ -1872,12 +1872,12 @@  discard block
 block discarded – undo
1872 1872
     				foreach ($alldata as $key => $row) {
1873 1873
     					$count[$key] = $row['airport_departure_icao_count'];
1874 1874
     				}
1875
-				array_multisort($count,SORT_DESC,$alldata);
1875
+				array_multisort($count, SORT_DESC, $alldata);
1876 1876
 				foreach ($alldata as $number) {
1877
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name);
1877
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name);
1878 1878
 				}
1879
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1880
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1879
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter);
1880
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter);
1881 1881
 				$alldata = array();
1882 1882
     				foreach ($pall as $value) {
1883 1883
 		        		$icao = $value['airport_arrival_icao'];
@@ -1893,36 +1893,36 @@  discard block
 block discarded – undo
1893 1893
         			foreach ($alldata as $key => $row) {
1894 1894
     					$count[$key] = $row['airport_arrival_icao_count'];
1895 1895
 		        	}
1896
-        			array_multisort($count,SORT_DESC,$alldata);
1896
+        			array_multisort($count, SORT_DESC, $alldata);
1897 1897
 				foreach ($alldata as $number) {
1898
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name);
1898
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name);
1899 1899
 				}
1900 1900
 				$Spotter = new Spotter($this->db);
1901 1901
 				$alldata = $Spotter->countAllMonths($filter);
1902 1902
 				$lastyear = false;
1903 1903
 				foreach ($alldata as $number) {
1904 1904
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1905
-					$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);
1905
+					$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 1906
 				}
1907 1907
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1908 1908
 				foreach ($alldata as $number) {
1909
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1909
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1910 1910
 				}
1911 1911
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1912 1912
 				foreach ($alldata as $number) {
1913
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1913
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1914 1914
 				}
1915 1915
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1916 1916
 				foreach ($alldata as $number) {
1917
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1917
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1918 1918
 				}
1919 1919
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1920 1920
 				foreach ($alldata as $number) {
1921
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1921
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1922 1922
 				}
1923 1923
 				echo '...Departure'."\n";
1924
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1925
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1924
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1925
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1926 1926
 				foreach ($dall as $value) {
1927 1927
     					$icao = $value['departure_airport_icao'];
1928 1928
     					$ddate = $value['date'];
@@ -1940,11 +1940,11 @@  discard block
 block discarded – undo
1940 1940
     				}
1941 1941
 	    			$alldata = $pall;
1942 1942
 				foreach ($alldata as $number) {
1943
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1943
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
1944 1944
 				}
1945 1945
 				echo '...Arrival'."\n";
1946
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1947
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1946
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1947
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1948 1948
 				foreach ($dall as $value) {
1949 1949
 					$icao = $value['arrival_airport_icao'];
1950 1950
 					$ddate = $value['date'];
@@ -1962,36 +1962,36 @@  discard block
 block discarded – undo
1962 1962
     				}
1963 1963
     				$alldata = $pall;
1964 1964
 				foreach ($alldata as $number) {
1965
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1965
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
1966 1966
 				}
1967 1967
     
1968 1968
 				echo 'Flights data...'."\n";
1969 1969
 				echo '-> countAllDatesLastMonth...'."\n";
1970 1970
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1971 1971
 				foreach ($alldata as $number) {
1972
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1972
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1973 1973
 				}
1974 1974
 				echo '-> countAllDates...'."\n";
1975
-				$previousdata = $this->countAllDates('',$filter_name);
1976
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1975
+				$previousdata = $this->countAllDates('', $filter_name);
1976
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1977 1977
 				$values = array();
1978 1978
 				foreach ($alldata as $cnt) {
1979 1979
 					$values[] = $cnt['date_count'];
1980 1980
 				}
1981
-				array_multisort($values,SORT_DESC,$alldata);
1982
-				array_splice($alldata,11);
1981
+				array_multisort($values, SORT_DESC, $alldata);
1982
+				array_splice($alldata, 11);
1983 1983
 				foreach ($alldata as $number) {
1984
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1984
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1985 1985
 				}
1986 1986
 				
1987 1987
 				echo '-> countAllHours...'."\n";
1988
-				$alldata = $Spotter->countAllHours('hour',$filter);
1988
+				$alldata = $Spotter->countAllHours('hour', $filter);
1989 1989
 				foreach ($alldata as $number) {
1990
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1990
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1991 1991
 				}
1992 1992
 				echo 'Insert last stats update date...'."\n";
1993 1993
 				date_default_timezone_set('UTC');
1994
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
1994
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
1995 1995
 			}
1996 1996
 	
1997 1997
 
@@ -2001,16 +2001,16 @@  discard block
 block discarded – undo
2001 2001
 				// SUM all previous month to put as year
2002 2002
 				$previous_year = date('Y');
2003 2003
 				$previous_year--;
2004
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2005
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2006
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2007
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2004
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2005
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2006
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2007
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2008 2008
 				$allairlines = $this->getAllAirlineNames();
2009 2009
 				foreach ($allairlines as $data) {
2010
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2011
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2012
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2013
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2010
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2011
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2012
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2013
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2014 2014
 				}
2015 2015
 				
2016 2016
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
 						try {
2020 2020
 							$sth = $this->db->prepare($query);
2021 2021
 							$sth->execute();
2022
-						} catch(PDOException $e) {
2022
+						} catch (PDOException $e) {
2023 2023
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2024 2024
 						}
2025 2025
 					}
@@ -2028,7 +2028,7 @@  discard block
 block discarded – undo
2028 2028
 					try {
2029 2029
 						$sth = $this->db->prepare($query);
2030 2030
 						$sth->execute();
2031
-					} catch(PDOException $e) {
2031
+					} catch (PDOException $e) {
2032 2032
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2033 2033
 					}
2034 2034
 				}
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 					try {
2051 2051
 						$sth = $this->db->prepare($query);
2052 2052
 						$sth->execute();
2053
-					} catch(PDOException $e) {
2053
+					} catch (PDOException $e) {
2054 2054
 						return "error : ".$e->getMessage();
2055 2055
 					}
2056 2056
 				}
@@ -2064,13 +2064,13 @@  discard block
 block discarded – undo
2064 2064
 				try {
2065 2065
 					$sth = $this->db->prepare($query);
2066 2066
 					$sth->execute();
2067
-				} catch(PDOException $e) {
2067
+				} catch (PDOException $e) {
2068 2068
 					return "error : ".$e->getMessage();
2069 2069
 				}
2070 2070
 			}
2071 2071
 			echo 'Insert last stats update date...'."\n";
2072 2072
 			date_default_timezone_set('UTC');
2073
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2073
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2074 2074
 		//}
2075 2075
 	}
2076 2076
 }
Please login to merge, or discard this patch.