Completed
Push — master ( 34a40a...b282d7 )
by Yannick
06:06
created
require/class.Stats.php 2 patches
Spacing   +348 added lines, -348 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,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
                 return $all;
126 126
         }
127 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			try {
282 282
 				$sth = $this->db->prepare($query);
283 283
 				$sth->execute(array(':filter_name' => $filter_name));
284
-			} catch(PDOException $e) {
284
+			} catch (PDOException $e) {
285 285
 				echo "error : ".$e->getMessage();
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	                $Spotter = new Spotter($this->db);
291 291
             		$filters = array();
292 292
             		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
293
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
296
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
297 297
                 }
298 298
                 return $all;
299 299
 	}
300
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
300
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
301 301
 		global $globalStatsFilters;
302 302
 		if ($filter_name == '') $filter_name = $this->filter_name;
303 303
 		if ($year == '' && $month == '') {
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306 306
 			try {
307 307
 				$sth = $this->db->prepare($query);
308
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-			} catch(PDOException $e) {
308
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+			} catch (PDOException $e) {
310 310
 				echo "error : ".$e->getMessage();
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
                 if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
317
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
318 318
 			}
319 319
 	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
320
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
321 321
                 }
322 322
                 return $all;
323 323
 	}
324
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
324
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
325 325
 		global $globalStatsFilters;
326 326
 		if ($filter_name == '') $filter_name = $this->filter_name;
327 327
 		if ($year == '' && $month == '') {
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
330 330
 			 try {
331 331
 				$sth = $this->db->prepare($query);
332
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
333
-			} catch(PDOException $e) {
332
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
333
+			} catch (PDOException $e) {
334 334
 				echo "error : ".$e->getMessage();
335 335
 			}
336 336
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		if (empty($all)) {
339 339
 			$filters = array('airlines' => array($stats_airline));
340 340
 			if ($filter_name != '') {
341
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
341
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
342 342
 			}
343 343
 			$Spotter = new Spotter($this->db);
344
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
344
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
345 345
 		}
346 346
 		return $all;
347 347
 	}
348
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
348
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		$Connection = new Connection();
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($Connection->tableExists('countries')) {
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
355 355
 				 try {
356 356
 					$sth = $this->db->prepare($query);
357
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
358
-				} catch(PDOException $e) {
357
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
358
+				} catch (PDOException $e) {
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			return array();
372 372
 		}
373 373
 	}
374
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
374
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
375 375
 		global $globalStatsFilters;
376 376
 		if ($filter_name == '') $filter_name = $this->filter_name;
377 377
 		if ($year == '' && $month == '') {
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
380 380
 			try {
381 381
 				$sth = $this->db->prepare($query);
382
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
383
-			} catch(PDOException $e) {
382
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
383
+			} catch (PDOException $e) {
384 384
 				echo "error : ".$e->getMessage();
385 385
 			}
386 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 		if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
 			if ($filter_name != '') {
391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
 			$Spotter = new Spotter($this->db);
394
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
394
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
395 395
 		}
396 396
 		return $all;
397 397
 	}
398 398
 
399
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
399
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
400 400
 		global $globalStatsFilters;
401 401
 		if ($filter_name == '') $filter_name = $this->filter_name;
402 402
 		if ($year == '' && $month == '') {
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
405 405
 			try {
406 406
 				$sth = $this->db->prepare($query);
407
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
408
-			} catch(PDOException $e) {
407
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
408
+			} catch (PDOException $e) {
409 409
 				echo "error : ".$e->getMessage();
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                 if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
416
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
417 417
 			}
418 418
             		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
419
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
420 420
                 }
421 421
                 return $all;
422 422
 	}
423
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
424 424
 		global $globalStatsFilters;
425 425
 		if ($filter_name == '') $filter_name = $this->filter_name;
426 426
 		if ($year == '' && $month == '') {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
429 429
 			try {
430 430
 				$sth = $this->db->prepare($query);
431
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
432
-			} catch(PDOException $e) {
431
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
432
+			} catch (PDOException $e) {
433 433
 				echo "error : ".$e->getMessage();
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
                 if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
             		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
443
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
444
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
445 445
         		$all = array();
446 446
         		foreach ($pall as $value) {
447 447
         			$icao = $value['airport_departure_icao'];
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
         		foreach ($all as $key => $row) {
459 459
         			$count[$key] = $row['airport_departure_icao_count'];
460 460
         		}
461
-        		array_multisort($count,SORT_DESC,$all);
461
+        		array_multisort($count, SORT_DESC, $all);
462 462
                 }
463 463
                 return $all;
464 464
 	}
465
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
465
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
466 466
 		global $globalStatsFilters;
467 467
 		if ($filter_name == '') $filter_name = $this->filter_name;
468 468
 		if ($year == '' && $month == '') {
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
471 471
 			try {
472 472
 				$sth = $this->db->prepare($query);
473
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
474
-			} catch(PDOException $e) {
473
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
474
+			} catch (PDOException $e) {
475 475
 				echo "error : ".$e->getMessage();
476 476
 			}
477 477
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 		if (empty($all)) {
480 480
 			$filters = array('airlines' => array($stats_airline));
481 481
 			if ($filter_name != '') {
482
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
482
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
483 483
 			}
484 484
 			$Spotter = new Spotter($this->db);
485
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
485
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
486
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
487 487
         		$all = array();
488 488
         		foreach ($pall as $value) {
489 489
         			$icao = $value['airport_arrival_icao'];
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
         		foreach ($all as $key => $row) {
501 501
         			$count[$key] = $row['airport_arrival_icao_count'];
502 502
         		}
503
-        		array_multisort($count,SORT_DESC,$all);
503
+        		array_multisort($count, SORT_DESC, $all);
504 504
                 }
505 505
  
506 506
                 return $all;
507 507
 	}
508
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
508
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
510 510
 		if ($filter_name == '') $filter_name = $this->filter_name;
511 511
 		if ($globalDBdriver == 'mysql') {
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516 516
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
517 517
 		}
518
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
519 519
                  try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute($query_data);
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo "error : ".$e->getMessage();
524 524
                 }
525 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526 526
                 if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
530 530
 			}
531 531
             		$Spotter = new Spotter($this->db);
532 532
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
                 return $all;
536 536
 	}
537 537
 	
538
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
538
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
539 539
 		global $globalStatsFilters;
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLastMonth($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
560
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		if ($globalDBdriver == 'mysql') {
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		} else {
566 566
 			$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";
567 567
 		}
568
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
568
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
569 569
                  try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute($query_data);
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo "error : ".$e->getMessage();
574 574
                 }
575 575
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576 576
                 if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
             		$Spotter = new Spotter($this->db);
582 582
             		$all = $Spotter->countAllDatesLast7Days($filters);
583 583
                 }
584 584
                 return $all;
585 585
 	}
586
-	public function countAllDates($stats_airline = '',$filter_name = '') {
586
+	public function countAllDates($stats_airline = '', $filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
590
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
591 591
                  try {
592 592
                         $sth = $this->db->prepare($query);
593 593
                         $sth->execute($query_data);
594
-                } catch(PDOException $e) {
594
+                } catch (PDOException $e) {
595 595
                         echo "error : ".$e->getMessage();
596 596
                 }
597 597
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598 598
                 if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
602 602
 			}
603 603
             		$Spotter = new Spotter($this->db);
604 604
             		$all = $Spotter->countAllDates($filters);
@@ -613,28 +613,28 @@  discard block
 block discarded – undo
613 613
                  try {
614 614
                         $sth = $this->db->prepare($query);
615 615
                         $sth->execute($query_data);
616
-                } catch(PDOException $e) {
616
+                } catch (PDOException $e) {
617 617
                         echo "error : ".$e->getMessage();
618 618
                 }
619 619
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620 620
                 if (empty($all)) {
621 621
             		$filters = array();
622 622
             		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
623
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
624 624
 			}
625 625
             		$Spotter = new Spotter($this->db);
626 626
             		$all = $Spotter->countAllDatesByAirlines($filters);
627 627
                 }
628 628
                 return $all;
629 629
 	}
630
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
630
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633 633
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 634
                  try {
635 635
                         $sth = $this->db->prepare($query);
636 636
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
637
+                } catch (PDOException $e) {
638 638
                         echo "error : ".$e->getMessage();
639 639
                 }
640 640
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                 if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
646 646
 			}
647 647
             		$Spotter = new Spotter($this->db);
648 648
             		$all = $Spotter->countAllMonths($filters);
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
                  try {
658 658
                         $sth = $this->db->prepare($query);
659 659
                         $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
660
+                } catch (PDOException $e) {
661 661
                         echo "error : ".$e->getMessage();
662 662
                 }
663 663
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664 664
                 if (empty($all)) {
665 665
             		$filters = array();
666 666
             		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
667
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
668 668
 			}
669 669
             		$Spotter = new Spotter($this->db);
670 670
             		$all = $Spotter->countAllMilitaryMonths($filters);
671 671
                 }
672 672
                 return $all;
673 673
 	}
674
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
674
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676 676
 		if ($filter_name == '') $filter_name = $this->filter_name;
677 677
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -688,91 +688,91 @@  discard block
 block discarded – undo
688 688
                  try {
689 689
                         $sth = $this->db->prepare($query);
690 690
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
691
+                } catch (PDOException $e) {
692 692
                         echo "error : ".$e->getMessage();
693 693
                 }
694 694
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695 695
                 if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
699 699
 			}
700 700
             		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
701
+            		$all = $Spotter->countAllHours($orderby, $filters);
702 702
                 }
703 703
                 return $all;
704 704
 	}
705 705
 	
706
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
706
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
707 707
 		global $globalStatsFilters;
708 708
 		if ($filter_name == '') $filter_name = $this->filter_name;
709 709
 		if ($year == '') $year = date('Y');
710
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
710
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
711 711
 		if (empty($all)) {
712 712
 			$filters = array('airlines' => array($stats_airline));
713 713
 			if ($filter_name != '') {
714
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
714
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
715 715
 			}
716 716
 			$Spotter = new Spotter($this->db);
717
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
717
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
718 718
 		}
719 719
 		return $all;
720 720
 	}
721
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
721
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
722 722
 		global $globalStatsFilters;
723 723
 		if ($filter_name == '') $filter_name = $this->filter_name;
724 724
 		if ($year == '') $year = date('Y');
725
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
725
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
726 726
 		if (empty($all)) {
727 727
 		        $filters = array();
728 728
             		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
729
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
732
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
733 733
 		}
734 734
 		return $all;
735 735
 	}
736
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
736
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
737 737
 		global $globalStatsFilters;
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739 739
 		if ($year == '') $year = date('Y');
740
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
740
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
741 741
 		if (empty($all)) {
742 742
 			$filters = array('airlines' => array($stats_airline));
743 743
 			if ($filter_name != '') {
744
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
744
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
745 745
 			}
746 746
 			$Spotter = new Spotter($this->db);
747
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
747
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
748 748
 		}
749 749
 		return $all;
750 750
 	}
751
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
751
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
752 752
 		global $globalStatsFilters;
753 753
 		if ($filter_name == '') $filter_name = $this->filter_name;
754 754
 		if ($year == '' && $month == '') {
755 755
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
756 756
 			try {
757 757
 				$sth = $this->db->prepare($query);
758
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
759
-			} catch(PDOException $e) {
758
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
759
+			} catch (PDOException $e) {
760 760
 				echo "error : ".$e->getMessage();
761 761
 			}
762 762
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
763 763
 			$all = $result[0]['nb'];
764
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
764
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
765 765
 		if (empty($all)) {
766 766
 			$filters = array('airlines' => array($stats_airline));
767 767
 			if ($filter_name != '') {
768
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
768
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
769 769
 			}
770 770
 			$Spotter = new Spotter($this->db);
771
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
771
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
772 772
 		}
773 773
 		return $all;
774 774
 	}
775
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
775
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
776 776
 		global $globalStatsFilters;
777 777
 		if ($filter_name == '') $filter_name = $this->filter_name;
778 778
 		if ($year == '' && $month == '') {
@@ -780,23 +780,23 @@  discard block
 block discarded – undo
780 780
 			try {
781 781
 				$sth = $this->db->prepare($query);
782 782
 				$sth->execute(array(':filter_name' => $filter_name));
783
-			} catch(PDOException $e) {
783
+			} catch (PDOException $e) {
784 784
 				echo "error : ".$e->getMessage();
785 785
 			}
786 786
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
787 787
 			$all = $result[0]['nb_airline'];
788
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
788
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
789 789
 		if (empty($all)) {
790 790
             		$filters = array();
791 791
             		if ($filter_name != '') {
792
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
792
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
793 793
 			}
794 794
 			$Spotter = new Spotter($this->db);
795
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
795
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
796 796
 		}
797 797
 		return $all;
798 798
 	}
799
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
799
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
800 800
 		global $globalStatsFilters;
801 801
 		if ($filter_name == '') $filter_name = $this->filter_name;
802 802
 		if ($year == '' && $month == '') {
@@ -805,25 +805,25 @@  discard block
 block discarded – undo
805 805
 			try {
806 806
 				$sth = $this->db->prepare($query);
807 807
 				$sth->execute($query_values);
808
-			} catch(PDOException $e) {
808
+			} catch (PDOException $e) {
809 809
 				echo "error : ".$e->getMessage();
810 810
 			}
811 811
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
812 812
 			$all = $result[0]['nb'];
813 813
 		} else {
814
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
814
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
815 815
 		}
816 816
 		if (empty($all)) {
817 817
 			$filters = array('airlines' => array($stats_airline));
818 818
 			if ($filter_name != '') {
819
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
819
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
820 820
 			}
821 821
 			$Spotter = new Spotter($this->db);
822
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
822
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
823 823
 		}
824 824
 		return $all;
825 825
 	}
826
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
826
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
827 827
 		global $globalStatsFilters;
828 828
 		if ($filter_name == '') $filter_name = $this->filter_name;
829 829
 		//if ($year == '') $year = date('Y');
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
 			try {
834 834
 				$sth = $this->db->prepare($query);
835 835
 				$sth->execute($query_values);
836
-			} catch(PDOException $e) {
836
+			} catch (PDOException $e) {
837 837
 				echo "error : ".$e->getMessage();
838 838
 			}
839 839
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
840 840
 			$all = $result[0]['nb'];
841 841
 		} else {
842
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
842
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
843 843
 		}
844 844
 		if (empty($all)) {
845 845
 			$filters = array('airlines' => array($stats_airline));
846 846
 			if ($filter_name != '') {
847
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
847
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
848 848
 			}
849 849
 			$Spotter = new Spotter($this->db);
850
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
850
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
851 851
 		}
852 852
 		return $all;
853 853
 	}
854 854
 
855
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
855
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
858
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
858
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859 859
                  try {
860 860
                         $sth = $this->db->prepare($query);
861 861
                         $sth->execute($query_values);
862
-                } catch(PDOException $e) {
862
+                } catch (PDOException $e) {
863 863
                         echo "error : ".$e->getMessage();
864 864
                 }
865 865
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866 866
                 return $all;
867 867
 	}
868
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
868
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870 870
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
871
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
872 872
                  try {
873 873
                         $sth = $this->db->prepare($query);
874 874
                         $sth->execute($query_values);
875
-                } catch(PDOException $e) {
875
+                } catch (PDOException $e) {
876 876
                         echo "error : ".$e->getMessage();
877 877
                 }
878 878
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879 879
                 return $all;
880 880
         }
881
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
881
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 883
     		global $globalArchiveMonths, $globalDBdriver;
884 884
     		if ($globalDBdriver == 'mysql') {
885 885
     			if ($month == '') {
886 886
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
887
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
887
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
888 888
 			} else {
889 889
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
890
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
890
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
891 891
 			}
892 892
 		} else {
893 893
 			if ($month == '') {
894 894
 				$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";
895
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
895
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896 896
 			} else {
897 897
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
898
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
898
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
899 899
 			}
900 900
                 }
901 901
                  try {
902 902
                         $sth = $this->db->prepare($query);
903 903
                         $sth->execute($query_values);
904
-                } catch(PDOException $e) {
904
+                } catch (PDOException $e) {
905 905
                         echo "error : ".$e->getMessage();
906 906
                 }
907 907
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                  try {
920 920
                         $sth = $this->db->prepare($query);
921 921
                         $sth->execute($query_values);
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         echo "error : ".$e->getMessage();
924 924
                 }
925 925
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
                  try {
937 937
                         $sth = $this->db->prepare($query);
938 938
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
939
+                } catch (PDOException $e) {
940 940
                         echo "error : ".$e->getMessage();
941 941
                 }
942 942
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                  try {
954 954
                         $sth = $this->db->prepare($query);
955 955
                         $sth->execute(array(':filter_name' => $filter_name));
956
-                } catch(PDOException $e) {
956
+                } catch (PDOException $e) {
957 957
                         echo "error : ".$e->getMessage();
958 958
                 }
959 959
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
                  try {
971 971
                         $sth = $this->db->prepare($query);
972 972
                         $sth->execute(array(':filter_name' => $filter_name));
973
-                } catch(PDOException $e) {
973
+                } catch (PDOException $e) {
974 974
                         echo "error : ".$e->getMessage();
975 975
                 }
976 976
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -987,14 +987,14 @@  discard block
 block discarded – undo
987 987
                  try {
988 988
                         $sth = $this->db->prepare($query);
989 989
                         $sth->execute(array(':filter_name' => $filter_name));
990
-                } catch(PDOException $e) {
990
+                } catch (PDOException $e) {
991 991
                         echo "error : ".$e->getMessage();
992 992
                 }
993 993
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
994 994
                 return $all[0]['total'];
995 995
         }
996 996
 
997
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
997
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
998 998
 		global $globalDBdriver;
999 999
 		if ($filter_name == '') $filter_name = $this->filter_name;
1000 1000
 		if ($globalDBdriver == 'mysql') {
@@ -1002,15 +1002,15 @@  discard block
 block discarded – undo
1002 1002
                 } else {
1003 1003
 			$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);"; 
1004 1004
 		}
1005
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1005
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1006 1006
                  try {
1007 1007
                         $sth = $this->db->prepare($query);
1008 1008
                         $sth->execute($query_values);
1009
-                } catch(PDOException $e) {
1009
+                } catch (PDOException $e) {
1010 1010
                         return "error : ".$e->getMessage();
1011 1011
                 }
1012 1012
         }
1013
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1013
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1014 1014
 		global $globalDBdriver;
1015 1015
 		if ($filter_name == '') $filter_name = $this->filter_name;
1016 1016
 		if ($globalDBdriver == 'mysql') {
@@ -1019,11 +1019,11 @@  discard block
 block discarded – undo
1019 1019
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1020 1020
 			$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);"; 
1021 1021
                 }
1022
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1022
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1023 1023
                  try {
1024 1024
                         $sth = $this->db->prepare($query);
1025 1025
                         $sth->execute($query_values);
1026
-                } catch(PDOException $e) {
1026
+                } catch (PDOException $e) {
1027 1027
                         return "error : ".$e->getMessage();
1028 1028
                 }
1029 1029
         }
@@ -1047,75 +1047,75 @@  discard block
 block discarded – undo
1047 1047
         }
1048 1048
         */
1049 1049
 
1050
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1050
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1051 1051
 		global $globalDBdriver;
1052 1052
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1053 1053
 		$query_values = array();
1054 1054
 		if ($globalDBdriver == 'mysql') {
1055 1055
 			if ($year != '') {
1056 1056
 				$query .= ' AND YEAR(stats_date) = :year';
1057
-				$query_values = array_merge($query_values,array(':year' => $year));
1057
+				$query_values = array_merge($query_values, array(':year' => $year));
1058 1058
 			}
1059 1059
 			if ($month != '') {
1060 1060
 				$query .= ' AND MONTH(stats_date) = :month';
1061
-				$query_values = array_merge($query_values,array(':month' => $month));
1061
+				$query_values = array_merge($query_values, array(':month' => $month));
1062 1062
 			}
1063 1063
 			if ($day != '') {
1064 1064
 				$query .= ' AND DAY(stats_date) = :day';
1065
-				$query_values = array_merge($query_values,array(':day' => $day));
1065
+				$query_values = array_merge($query_values, array(':day' => $day));
1066 1066
 			}
1067 1067
 		} else {
1068 1068
 			if ($year != '') {
1069 1069
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1070
-				$query_values = array_merge($query_values,array(':year' => $year));
1070
+				$query_values = array_merge($query_values, array(':year' => $year));
1071 1071
 			}
1072 1072
 			if ($month != '') {
1073 1073
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1074
-				$query_values = array_merge($query_values,array(':month' => $month));
1074
+				$query_values = array_merge($query_values, array(':month' => $month));
1075 1075
 			}
1076 1076
 			if ($day != '') {
1077 1077
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1078
-				$query_values = array_merge($query_values,array(':day' => $day));
1078
+				$query_values = array_merge($query_values, array(':day' => $day));
1079 1079
 			}
1080 1080
 		}
1081 1081
 		$query .= " ORDER BY source_name";
1082
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1082
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1083 1083
 		try {
1084 1084
 			$sth = $this->db->prepare($query);
1085 1085
 			$sth->execute($query_values);
1086
-		} catch(PDOException $e) {
1086
+		} catch (PDOException $e) {
1087 1087
 			echo "error : ".$e->getMessage();
1088 1088
 		}
1089 1089
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1090 1090
 		return $all;
1091 1091
 	}
1092 1092
 
1093
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1093
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1094 1094
 		global $globalDBdriver;
1095 1095
 		if ($globalDBdriver == 'mysql') {
1096 1096
 			$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";
1097 1097
 		} else {
1098 1098
 			$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);"; 
1099 1099
                 }
1100
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1100
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1101 1101
                  try {
1102 1102
                         $sth = $this->db->prepare($query);
1103 1103
                         $sth->execute($query_values);
1104
-                } catch(PDOException $e) {
1104
+                } catch (PDOException $e) {
1105 1105
                         return "error : ".$e->getMessage();
1106 1106
                 }
1107 1107
         }
1108
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1108
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1109 1109
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1110
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1110
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1111 1111
                  try {
1112 1112
                         $sth = $this->db->prepare($query);
1113 1113
                         $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1114
+                } catch (PDOException $e) {
1115 1115
                         return "error : ".$e->getMessage();
1116 1116
                 }
1117 1117
         }
1118
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1118
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
1121 1121
 			if ($reset) {
@@ -1130,15 +1130,15 @@  discard block
 block discarded – undo
1130 1130
 				$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);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1133
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1134 1134
                  try {
1135 1135
                         $sth = $this->db->prepare($query);
1136 1136
                         $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1137
+                } catch (PDOException $e) {
1138 1138
                         return "error : ".$e->getMessage();
1139 1139
                 }
1140 1140
         }
1141
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1141
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
1144 1144
 			if ($reset) {
@@ -1153,15 +1153,15 @@  discard block
 block discarded – undo
1153 1153
 				$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);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1156
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1157 1157
                  try {
1158 1158
                         $sth = $this->db->prepare($query);
1159 1159
                         $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1160
+                } catch (PDOException $e) {
1161 1161
                         return "error : ".$e->getMessage();
1162 1162
                 }
1163 1163
         }
1164
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1164
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
1167 1167
 			if ($reset) {
@@ -1176,15 +1176,15 @@  discard block
 block discarded – undo
1176 1176
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1179
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1180 1180
                  try {
1181 1181
                         $sth = $this->db->prepare($query);
1182 1182
                         $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1183
+                } catch (PDOException $e) {
1184 1184
                         return "error : ".$e->getMessage();
1185 1185
                 }
1186 1186
         }
1187
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1187
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
1190 1190
 			if ($reset) {
@@ -1199,15 +1199,15 @@  discard block
 block discarded – undo
1199 1199
 				$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);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $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);
1202
+                $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);
1203 1203
                  try {
1204 1204
                         $sth = $this->db->prepare($query);
1205 1205
                         $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1206
+                } catch (PDOException $e) {
1207 1207
                         return "error : ".$e->getMessage();
1208 1208
                 }
1209 1209
         }
1210
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1210
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
1213 1213
 			if ($reset) {
@@ -1222,15 +1222,15 @@  discard block
 block discarded – undo
1222 1222
 				$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);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1225
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1226 1226
                  try {
1227 1227
                         $sth = $this->db->prepare($query);
1228 1228
                         $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1229
+                } catch (PDOException $e) {
1230 1230
                         return "error : ".$e->getMessage();
1231 1231
                 }
1232 1232
         }
1233
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1233
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
1236 1236
 			if ($reset) {
@@ -1245,15 +1245,15 @@  discard block
 block discarded – undo
1245 1245
 				$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);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1248
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1249 1249
                  try {
1250 1250
                         $sth = $this->db->prepare($query);
1251 1251
                         $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1252
+                } catch (PDOException $e) {
1253 1253
                         return "error : ".$e->getMessage();
1254 1254
                 }
1255 1255
         }
1256
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1256
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($globalDBdriver == 'mysql') {
1259 1259
 			if ($reset) {
@@ -1268,15 +1268,15 @@  discard block
 block discarded – undo
1268 1268
 				$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);"; 
1269 1269
 			}
1270 1270
 		}
1271
-                $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);
1271
+                $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);
1272 1272
                  try {
1273 1273
                         $sth = $this->db->prepare($query);
1274 1274
                         $sth->execute($query_values);
1275
-                } catch(PDOException $e) {
1275
+                } catch (PDOException $e) {
1276 1276
                         return "error : ".$e->getMessage();
1277 1277
                 }
1278 1278
         }
1279
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1279
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1280 1280
 		global $globalDBdriver;
1281 1281
 		if ($airport_icao != '') {
1282 1282
 			if ($globalDBdriver == 'mysql') {
@@ -1292,16 +1292,16 @@  discard block
 block discarded – undo
1292 1292
 					$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);"; 
1293 1293
 				}
1294 1294
 			}
1295
-			$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);
1295
+			$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);
1296 1296
 			try {
1297 1297
 				$sth = $this->db->prepare($query);
1298 1298
 				$sth->execute($query_values);
1299
-			} catch(PDOException $e) {
1299
+			} catch (PDOException $e) {
1300 1300
 				return "error : ".$e->getMessage();
1301 1301
 			}
1302 1302
                 }
1303 1303
         }
1304
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1304
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1305 1305
 		global $globalDBdriver;
1306 1306
 		if ($airport_icao != '') {
1307 1307
 			if ($globalDBdriver == 'mysql') {
@@ -1309,16 +1309,16 @@  discard block
 block discarded – undo
1309 1309
 			} else {
1310 1310
 				$query = "UPDATE stats_airport SET 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);"; 
1311 1311
 			}
1312
-			$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);
1312
+			$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);
1313 1313
 			 try {
1314 1314
 				$sth = $this->db->prepare($query);
1315 1315
 				$sth->execute($query_values);
1316
-			} catch(PDOException $e) {
1316
+			} catch (PDOException $e) {
1317 1317
 				return "error : ".$e->getMessage();
1318 1318
 			}
1319 1319
                 }
1320 1320
         }
1321
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1321
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1322 1322
 		global $globalDBdriver;
1323 1323
 		if ($airport_icao != '') {
1324 1324
 			if ($globalDBdriver == 'mysql') {
@@ -1334,16 +1334,16 @@  discard block
 block discarded – undo
1334 1334
 					$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);"; 
1335 1335
 				}
1336 1336
 			}
1337
-	                $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);
1337
+	                $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);
1338 1338
 			 try {
1339 1339
                     		$sth = $this->db->prepare($query);
1340 1340
 	                        $sth->execute($query_values);
1341
-    		        } catch(PDOException $e) {
1341
+    		        } catch (PDOException $e) {
1342 1342
             		        return "error : ".$e->getMessage();
1343 1343
 	                }
1344 1344
 	        }
1345 1345
         }
1346
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1346
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1347 1347
 		global $globalDBdriver;
1348 1348
 		if ($airport_icao != '') {
1349 1349
 			if ($globalDBdriver == 'mysql') {
@@ -1351,11 +1351,11 @@  discard block
 block discarded – undo
1351 1351
 			} else {
1352 1352
 				$query = "UPDATE stats_airport SET 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);"; 
1353 1353
 			}
1354
-			$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);
1354
+			$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);
1355 1355
 			try {
1356 1356
 				$sth = $this->db->prepare($query);
1357 1357
 				$sth->execute($query_values);
1358
-			} catch(PDOException $e) {
1358
+			} catch (PDOException $e) {
1359 1359
 				return "error : ".$e->getMessage();
1360 1360
 			}
1361 1361
                 }
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
                  try {
1368 1368
                         $sth = $this->db->prepare($query);
1369 1369
                         $sth->execute($query_values);
1370
-                } catch(PDOException $e) {
1370
+                } catch (PDOException $e) {
1371 1371
                         return "error : ".$e->getMessage();
1372 1372
                 }
1373 1373
         }
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
                  try {
1378 1378
                         $sth = $this->db->prepare($query);
1379 1379
                         $sth->execute($query_values);
1380
-                } catch(PDOException $e) {
1380
+                } catch (PDOException $e) {
1381 1381
                         return "error : ".$e->getMessage();
1382 1382
                 }
1383 1383
         }
@@ -1387,13 +1387,13 @@  discard block
 block discarded – undo
1387 1387
                  try {
1388 1388
                         $sth = $this->db->prepare($query);
1389 1389
                         $sth->execute($query_values);
1390
-                } catch(PDOException $e) {
1390
+                } catch (PDOException $e) {
1391 1391
                         return "error : ".$e->getMessage();
1392 1392
                 }
1393 1393
         }
1394 1394
         
1395 1395
         public function addOldStats() {
1396
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1396
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1397 1397
     		$Common = new Common();
1398 1398
     		$Connection = new Connection();
1399 1399
     		date_default_timezone_set('UTC');
@@ -1410,40 +1410,40 @@  discard block
 block discarded – undo
1410 1410
 			$Spotter = new Spotter($this->db);
1411 1411
 
1412 1412
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1413
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1413
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1414 1414
 			foreach ($alldata as $number) {
1415
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1415
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1416 1416
 			}
1417 1417
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1418
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1418
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1419 1419
 			foreach ($alldata as $number) {
1420
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1420
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1421 1421
 			}
1422 1422
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1423
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1423
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1424 1424
 			foreach ($alldata as $number) {
1425
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1425
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1426 1426
 			}
1427 1427
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1428
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1428
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1429 1429
 			foreach ($alldata as $number) {
1430
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1430
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1431 1431
 			}
1432 1432
 			if ($globalDebug) echo 'Count all owners...'."\n";
1433
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1433
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1434 1434
 			foreach ($alldata as $number) {
1435
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1435
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1436 1436
 			}
1437 1437
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1438
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1438
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1439 1439
 			foreach ($alldata as $number) {
1440
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1440
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1441 1441
 			}
1442 1442
 			
1443 1443
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1444
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1444
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1445 1445
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1446
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1446
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1447 1447
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1448 1448
 	        	$alldata = array();
1449 1449
 	        	
@@ -1461,14 +1461,14 @@  discard block
 block discarded – undo
1461 1461
     			foreach ($alldata as $key => $row) {
1462 1462
     				$count[$key] = $row['airport_departure_icao_count'];
1463 1463
         		}
1464
-			array_multisort($count,SORT_DESC,$alldata);
1464
+			array_multisort($count, SORT_DESC, $alldata);
1465 1465
 			foreach ($alldata as $number) {
1466
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1466
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1467 1467
 			}
1468 1468
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1469
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1469
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1470 1470
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1471
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1471
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1472 1472
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1473 1473
 	        	$alldata = array();
1474 1474
     			foreach ($pall as $value) {
@@ -1485,16 +1485,16 @@  discard block
 block discarded – undo
1485 1485
         		foreach ($alldata as $key => $row) {
1486 1486
         			$count[$key] = $row['airport_arrival_icao_count'];
1487 1487
 	        	}
1488
-    			array_multisort($count,SORT_DESC,$alldata);
1488
+    			array_multisort($count, SORT_DESC, $alldata);
1489 1489
                         foreach ($alldata as $number) {
1490
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1490
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1491 1491
 			}
1492 1492
 			if ($Connection->tableExists('countries')) {
1493 1493
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1494 1494
 				$SpotterArchive = new SpotterArchive();
1495
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1495
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1496 1496
 				foreach ($alldata as $number) {
1497
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1497
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1498 1498
 				}
1499 1499
 			}
1500 1500
 			
@@ -1508,37 +1508,37 @@  discard block
 block discarded – undo
1508 1508
 			$lastyear = false;
1509 1509
 			foreach ($alldata as $number) {
1510 1510
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1511
-				$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'])));
1511
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1512 1512
 			}
1513 1513
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1514 1514
 			$alldata = $Spotter->countAllMilitaryMonths();
1515 1515
 			foreach ($alldata as $number) {
1516
-				$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'])));
1516
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1517 1517
 			}
1518 1518
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1519 1519
 			$alldata = $Spotter->countAllMonthsOwners();
1520 1520
 			foreach ($alldata as $number) {
1521
-				$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'])));
1521
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1522 1522
 			}
1523 1523
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1524 1524
 			$alldata = $Spotter->countAllMonthsPilots();
1525 1525
 			foreach ($alldata as $number) {
1526
-				$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'])));
1526
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1527 1527
 			}
1528 1528
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1529 1529
 			$alldata = $Spotter->countAllMonthsAirlines();
1530 1530
 			foreach ($alldata as $number) {
1531
-				$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'])));
1531
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1532 1532
 			}
1533 1533
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1534 1534
 			$alldata = $Spotter->countAllMonthsAircrafts();
1535 1535
 			foreach ($alldata as $number) {
1536
-				$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'])));
1536
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1537 1537
 			}
1538 1538
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1539 1539
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1540 1540
 			foreach ($alldata as $number) {
1541
-				$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'])));
1541
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1542 1542
 			}
1543 1543
 			if ($globalDebug) echo 'Airports data...'."\n";
1544 1544
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
     			}
1584 1584
     			$alldata = $pall;
1585 1585
 			foreach ($alldata as $number) {
1586
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1586
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1587 1587
 			}
1588 1588
 			echo '...Arrival'."\n";
1589 1589
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
     			}
1626 1626
     			$alldata = $pall;
1627 1627
 			foreach ($alldata as $number) {
1628
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1628
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1629 1629
 			}
1630 1630
 
1631 1631
 			echo 'Flights data...'."\n";
@@ -1633,28 +1633,28 @@  discard block
 block discarded – undo
1633 1633
 			echo '-> countAllDatesLastMonth...'."\n";
1634 1634
 			$alldata = $Spotter->countAllDatesLastMonth();
1635 1635
 			foreach ($alldata as $number) {
1636
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1636
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1637 1637
 			}
1638 1638
 			echo '-> countAllDates...'."\n";
1639 1639
 			$previousdata = $this->countAllDates();
1640 1640
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1641 1641
 			$this->deleteStatFlight('date');
1642
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1642
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1643 1643
 			$values = array();
1644 1644
 			foreach ($alldata as $cnt) {
1645 1645
 				$values[] = $cnt['date_count'];
1646 1646
 			}
1647
-			array_multisort($values,SORT_DESC,$alldata);
1648
-			array_splice($alldata,11);
1647
+			array_multisort($values, SORT_DESC, $alldata);
1648
+			array_splice($alldata, 11);
1649 1649
 			foreach ($alldata as $number) {
1650
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1650
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1651 1651
 			}
1652 1652
 			
1653 1653
 			$this->deleteStatFlight('hour');
1654 1654
 			echo '-> countAllHours...'."\n";
1655 1655
 			$alldata = $Spotter->countAllHours('hour');
1656 1656
 			foreach ($alldata as $number) {
1657
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1657
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1658 1658
 			}
1659 1659
 
1660 1660
 
@@ -1664,41 +1664,41 @@  discard block
 block discarded – undo
1664 1664
 			if ($Connection->tableExists('countries')) {
1665 1665
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1666 1666
 				$SpotterArchive = new SpotterArchive();
1667
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1667
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1668 1668
 				foreach ($alldata as $number) {
1669
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1669
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1670 1670
 				}
1671 1671
 			}
1672 1672
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1673 1673
 			$Spotter = new Spotter($this->db);
1674
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1674
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1675 1675
 			foreach ($alldata as $number) {
1676
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1676
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1677 1677
 			}
1678 1678
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1679
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1679
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1680 1680
 			foreach ($alldata as $number) {
1681
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1681
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1682 1682
 			}
1683 1683
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1684
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1684
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1685 1685
 			foreach ($alldata as $number) {
1686
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1686
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1687 1687
 			}
1688 1688
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1689
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1689
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1690 1690
 			foreach ($alldata as $number) {
1691
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1691
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1692 1692
 			}
1693 1693
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1694
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1694
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1695 1695
 			foreach ($alldata as $number) {
1696
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1696
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1697 1697
 			}
1698 1698
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1699
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1699
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1700 1700
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1701
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1701
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1702 1702
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1703 1703
 	        	//$alldata = array();
1704 1704
     			foreach ($dall as $value) {
@@ -1718,12 +1718,12 @@  discard block
 block discarded – undo
1718 1718
     			}
1719 1719
     			$alldata = $pall;
1720 1720
 			foreach ($alldata as $number) {
1721
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1721
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
1722 1722
 			}
1723 1723
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1724
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1724
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1725 1725
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1726
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1726
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1727 1727
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1728 1728
 	        	//$alldata = array();
1729 1729
     			foreach ($dall as $value) {
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
     			}
1744 1744
     			$alldata = $pall;
1745 1745
                         foreach ($alldata as $number) {
1746
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1746
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
1747 1747
 			}
1748 1748
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1749 1749
 			$Spotter = new Spotter($this->db);
@@ -1751,27 +1751,27 @@  discard block
 block discarded – undo
1751 1751
 			$lastyear = false;
1752 1752
 			foreach ($alldata as $number) {
1753 1753
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1754
-				$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']);
1754
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1755 1755
 			}
1756 1756
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1757 1757
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1758 1758
 			foreach ($alldata as $number) {
1759
-				$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']);
1759
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1760 1760
 			}
1761 1761
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1762 1762
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1763 1763
 			foreach ($alldata as $number) {
1764
-				$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']);
1764
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1765 1765
 			}
1766 1766
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1767 1767
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1768 1768
 			foreach ($alldata as $number) {
1769
-				$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']);
1769
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1770 1770
 			}
1771 1771
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1772 1772
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1773 1773
 			foreach ($alldata as $number) {
1774
-				$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']);
1774
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo '...Departure'."\n";
1777 1777
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
     			}
1795 1795
     			$alldata = $pall;
1796 1796
 			foreach ($alldata as $number) {
1797
-				$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']);
1797
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
1798 1798
 			}
1799 1799
 			if ($globalDebug) echo '...Arrival'."\n";
1800 1800
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1817,32 +1817,32 @@  discard block
 block discarded – undo
1817 1817
     			}
1818 1818
     			$alldata = $pall;
1819 1819
 			foreach ($alldata as $number) {
1820
-				$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']);
1820
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
1821 1821
 			}
1822 1822
 
1823 1823
 			if ($globalDebug) echo 'Flights data...'."\n";
1824 1824
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1825 1825
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1826 1826
 			foreach ($alldata as $number) {
1827
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1827
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1828 1828
 			}
1829 1829
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1830 1830
 			//$previousdata = $this->countAllDatesByAirlines();
1831
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1831
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1832 1832
 			$values = array();
1833 1833
 			foreach ($alldata as $cnt) {
1834 1834
 				$values[] = $cnt['date_count'];
1835 1835
 			}
1836
-			array_multisort($values,SORT_DESC,$alldata);
1837
-			array_splice($alldata,11);
1836
+			array_multisort($values, SORT_DESC, $alldata);
1837
+			array_splice($alldata, 11);
1838 1838
 			foreach ($alldata as $number) {
1839
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1839
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1840 1840
 			}
1841 1841
 			
1842 1842
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1843 1843
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1844 1844
 			foreach ($alldata as $number) {
1845
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1845
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1846 1846
 			}
1847 1847
 			
1848 1848
 
@@ -1861,32 +1861,32 @@  discard block
 block discarded – undo
1861 1861
 				// Count by filter
1862 1862
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1863 1863
 				$Spotter = new Spotter($this->db);
1864
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1864
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1865 1865
 				foreach ($alldata as $number) {
1866
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1866
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1867 1867
 				}
1868
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1868
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1869 1869
 				foreach ($alldata as $number) {
1870
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1870
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1871 1871
 				}
1872
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1872
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1873 1873
 				foreach ($alldata as $number) {
1874
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1874
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1875 1875
 				}
1876
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1876
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1877 1877
 				foreach ($alldata as $number) {
1878
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1878
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1879 1879
 				}
1880
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1880
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1881 1881
 				foreach ($alldata as $number) {
1882
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1882
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1883 1883
 				}
1884
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1884
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1885 1885
 				foreach ($alldata as $number) {
1886
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1886
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1887 1887
 				}
1888
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1889
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1888
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1889
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1890 1890
 		        	$alldata = array();
1891 1891
 	    			foreach ($pall as $value) {
1892 1892
 		        		$icao = $value['airport_departure_icao'];
@@ -1902,12 +1902,12 @@  discard block
 block discarded – undo
1902 1902
     				foreach ($alldata as $key => $row) {
1903 1903
     					$count[$key] = $row['airport_departure_icao_count'];
1904 1904
     				}
1905
-				array_multisort($count,SORT_DESC,$alldata);
1905
+				array_multisort($count, SORT_DESC, $alldata);
1906 1906
 				foreach ($alldata as $number) {
1907
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1907
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
1908 1908
 				}
1909
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1910
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1909
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1910
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1911 1911
 				$alldata = array();
1912 1912
     				foreach ($pall as $value) {
1913 1913
 		        		$icao = $value['airport_arrival_icao'];
@@ -1923,40 +1923,40 @@  discard block
 block discarded – undo
1923 1923
         			foreach ($alldata as $key => $row) {
1924 1924
     					$count[$key] = $row['airport_arrival_icao_count'];
1925 1925
 		        	}
1926
-        			array_multisort($count,SORT_DESC,$alldata);
1926
+        			array_multisort($count, SORT_DESC, $alldata);
1927 1927
 				foreach ($alldata as $number) {
1928
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1928
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
1929 1929
 				}
1930 1930
 				$Spotter = new Spotter($this->db);
1931 1931
 				$alldata = $Spotter->countAllMonths($filter);
1932 1932
 				$lastyear = false;
1933 1933
 				foreach ($alldata as $number) {
1934 1934
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1935
-					$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);
1935
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1936 1936
 				}
1937 1937
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1938 1938
 				foreach ($alldata as $number) {
1939
-					$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);
1939
+					$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);
1940 1940
 				}
1941 1941
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1942 1942
 				foreach ($alldata as $number) {
1943
-					$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);
1943
+					$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);
1944 1944
 				}
1945 1945
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1946 1946
 				foreach ($alldata as $number) {
1947
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1947
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1948 1948
 				}
1949 1949
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1950 1950
 				foreach ($alldata as $number) {
1951
-					$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);
1951
+					$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);
1952 1952
 				}
1953 1953
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1954 1954
 				foreach ($alldata as $number) {
1955
-					$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);
1955
+					$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);
1956 1956
 				}
1957 1957
 				echo '...Departure'."\n";
1958
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1959
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1958
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1959
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1960 1960
 				foreach ($dall as $value) {
1961 1961
     					$icao = $value['departure_airport_icao'];
1962 1962
     					$ddate = $value['date'];
@@ -1974,11 +1974,11 @@  discard block
 block discarded – undo
1974 1974
     				}
1975 1975
 	    			$alldata = $pall;
1976 1976
 				foreach ($alldata as $number) {
1977
-					$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);
1977
+					$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);
1978 1978
 				}
1979 1979
 				echo '...Arrival'."\n";
1980
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1981
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1980
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1981
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1982 1982
 				foreach ($dall as $value) {
1983 1983
 					$icao = $value['arrival_airport_icao'];
1984 1984
 					$ddate = $value['date'];
@@ -1996,40 +1996,40 @@  discard block
 block discarded – undo
1996 1996
     				}
1997 1997
     				$alldata = $pall;
1998 1998
 				foreach ($alldata as $number) {
1999
-					$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);
1999
+					$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);
2000 2000
 				}
2001 2001
     
2002 2002
 				echo 'Flights data...'."\n";
2003 2003
 				echo '-> countAllDatesLastMonth...'."\n";
2004 2004
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2005 2005
 				foreach ($alldata as $number) {
2006
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2006
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2007 2007
 				}
2008 2008
 				echo '-> countAllDates...'."\n";
2009
-				$previousdata = $this->countAllDates('',$filter_name);
2010
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2009
+				$previousdata = $this->countAllDates('', $filter_name);
2010
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2011 2011
 				$values = array();
2012 2012
 				foreach ($alldata as $cnt) {
2013 2013
 					$values[] = $cnt['date_count'];
2014 2014
 				}
2015
-				array_multisort($values,SORT_DESC,$alldata);
2016
-				array_splice($alldata,11);
2015
+				array_multisort($values, SORT_DESC, $alldata);
2016
+				array_splice($alldata, 11);
2017 2017
 				foreach ($alldata as $number) {
2018
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2018
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2019 2019
 				}
2020 2020
 				
2021 2021
 				echo '-> countAllHours...'."\n";
2022
-				$alldata = $Spotter->countAllHours('hour',$filter);
2022
+				$alldata = $Spotter->countAllHours('hour', $filter);
2023 2023
 				foreach ($alldata as $number) {
2024
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2024
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2025 2025
 				}
2026 2026
 				echo 'Insert last stats update date...'."\n";
2027 2027
 				date_default_timezone_set('UTC');
2028
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2028
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2029 2029
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2030
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2030
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2031 2031
 						$this->deleteOldStats($filter_name);
2032
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2032
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2033 2033
 					}
2034 2034
 				}
2035 2035
 
@@ -2042,16 +2042,16 @@  discard block
 block discarded – undo
2042 2042
 				// SUM all previous month to put as year
2043 2043
 				$previous_year = date('Y');
2044 2044
 				$previous_year--;
2045
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2046
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2047
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2048
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2045
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2046
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2047
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2048
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2049 2049
 				$allairlines = $this->getAllAirlineNames();
2050 2050
 				foreach ($allairlines as $data) {
2051
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2052
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2053
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2054
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2051
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2052
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2053
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2054
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2055 2055
 				}
2056 2056
 				
2057 2057
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
 						try {
2061 2061
 							$sth = $this->db->prepare($query);
2062 2062
 							$sth->execute();
2063
-						} catch(PDOException $e) {
2063
+						} catch (PDOException $e) {
2064 2064
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2065 2065
 						}
2066 2066
 					}
@@ -2069,15 +2069,15 @@  discard block
 block discarded – undo
2069 2069
 					try {
2070 2070
 						$sth = $this->db->prepare($query);
2071 2071
 						$sth->execute();
2072
-					} catch(PDOException $e) {
2072
+					} catch (PDOException $e) {
2073 2073
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2074 2074
 					}
2075 2075
 				}
2076 2076
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2077 2077
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2078
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2078
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2079 2079
 						$this->deleteOldStats();
2080
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2080
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2081 2081
 						$lastyearupdate = true;
2082 2082
 					}
2083 2083
 				}
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
 					try {
2100 2100
 						$sth = $this->db->prepare($query);
2101 2101
 						$sth->execute();
2102
-					} catch(PDOException $e) {
2102
+					} catch (PDOException $e) {
2103 2103
 						return "error : ".$e->getMessage();
2104 2104
 					}
2105 2105
 				}
@@ -2113,14 +2113,14 @@  discard block
 block discarded – undo
2113 2113
 				try {
2114 2114
 					$sth = $this->db->prepare($query);
2115 2115
 					$sth->execute();
2116
-				} catch(PDOException $e) {
2116
+				} catch (PDOException $e) {
2117 2117
 					return "error : ".$e->getMessage();
2118 2118
 				}
2119 2119
 			}
2120 2120
 			if (!isset($lastyearupdate)) {
2121 2121
 				echo 'Insert last stats update date...'."\n";
2122 2122
 				date_default_timezone_set('UTC');
2123
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2123
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2124 2124
 			}
2125 2125
 			if ($globalStatsResetYear) {
2126 2126
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +449 added lines, -155 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
160
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
175
+			if ($limit) {
176
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
177
+			} else {
178
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
208
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
237
+			if ($limit) {
238
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
239
+			} else {
240
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,10 +321,15 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
280
-			else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
328
+			if ($limit) {
329
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
330
+			} else {
331
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
332
+			}
281 333
 			try {
282 334
 				$sth = $this->db->prepare($query);
283 335
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -285,7 +337,9 @@  discard block
 block discarded – undo
285 337
 				echo "error : ".$e->getMessage();
286 338
 			}
287 339
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-		} else $all = array();
340
+		} else {
341
+			$all = array();
342
+		}
289 343
                 if (empty($all)) {
290 344
 	                $Spotter = new Spotter($this->db);
291 345
             		$filters = array();
@@ -299,10 +353,15 @@  discard block
 block discarded – undo
299 353
 	}
300 354
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 355
 		global $globalStatsFilters;
302
-		if ($filter_name == '') $filter_name = $this->filter_name;
356
+		if ($filter_name == '') {
357
+			$filter_name = $this->filter_name;
358
+		}
303 359
 		if ($year == '' && $month == '') {
304
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
305
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
360
+			if ($limit) {
361
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
362
+			} else {
363
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
364
+			}
306 365
 			try {
307 366
 				$sth = $this->db->prepare($query);
308 367
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -310,7 +369,9 @@  discard block
 block discarded – undo
310 369
 				echo "error : ".$e->getMessage();
311 370
 			}
312 371
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313
-		} else $all = array();
372
+		} else {
373
+			$all = array();
374
+		}
314 375
                 if (empty($all)) {
315 376
 			$filters = array('airlines' => array($stats_airline));
316 377
 			if ($filter_name != '') {
@@ -323,10 +384,15 @@  discard block
 block discarded – undo
323 384
 	}
324 385
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 386
 		global $globalStatsFilters;
326
-		if ($filter_name == '') $filter_name = $this->filter_name;
387
+		if ($filter_name == '') {
388
+			$filter_name = $this->filter_name;
389
+		}
327 390
 		if ($year == '' && $month == '') {
328
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
329
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
391
+			if ($limit) {
392
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
393
+			} else {
394
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
395
+			}
330 396
 			 try {
331 397
 				$sth = $this->db->prepare($query);
332 398
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -334,7 +400,9 @@  discard block
 block discarded – undo
334 400
 				echo "error : ".$e->getMessage();
335 401
 			}
336 402
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
337
-		} else $all = array();
403
+		} else {
404
+			$all = array();
405
+		}
338 406
 		if (empty($all)) {
339 407
 			$filters = array('airlines' => array($stats_airline));
340 408
 			if ($filter_name != '') {
@@ -347,11 +415,16 @@  discard block
 block discarded – undo
347 415
 	}
348 416
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
349 417
 		$Connection = new Connection();
350
-		if ($filter_name == '') $filter_name = $this->filter_name;
418
+		if ($filter_name == '') {
419
+			$filter_name = $this->filter_name;
420
+		}
351 421
 		if ($Connection->tableExists('countries')) {
352 422
 			if ($year == '' && $month == '') {
353
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
354
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
423
+				if ($limit) {
424
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
425
+				} else {
426
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
427
+				}
355 428
 				 try {
356 429
 					$sth = $this->db->prepare($query);
357 430
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -366,17 +439,24 @@  discard block
 block discarded – undo
366 439
                 }
367 440
                 */
368 441
 				return $all;
369
-			} else return array();
442
+			} else {
443
+				return array();
444
+			}
370 445
 		} else {
371 446
 			return array();
372 447
 		}
373 448
 	}
374 449
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
375 450
 		global $globalStatsFilters;
376
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
377 454
 		if ($year == '' && $month == '') {
378
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
379
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
455
+			if ($limit) {
456
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
457
+			} else {
458
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
459
+			}
380 460
 			try {
381 461
 				$sth = $this->db->prepare($query);
382 462
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -384,7 +464,9 @@  discard block
 block discarded – undo
384 464
 				echo "error : ".$e->getMessage();
385 465
 			}
386 466
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
387
-		} else $all = array();
467
+		} else {
468
+			$all = array();
469
+		}
388 470
 		if (empty($all)) {
389 471
 			$filters = array('airlines' => array($stats_airline));
390 472
 			if ($filter_name != '') {
@@ -398,10 +480,15 @@  discard block
 block discarded – undo
398 480
 
399 481
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
400 482
 		global $globalStatsFilters;
401
-		if ($filter_name == '') $filter_name = $this->filter_name;
483
+		if ($filter_name == '') {
484
+			$filter_name = $this->filter_name;
485
+		}
402 486
 		if ($year == '' && $month == '') {
403
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
404
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
487
+			if ($limit) {
488
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
489
+			} else {
490
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
491
+			}
405 492
 			try {
406 493
 				$sth = $this->db->prepare($query);
407 494
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -409,7 +496,9 @@  discard block
 block discarded – undo
409 496
 				echo "error : ".$e->getMessage();
410 497
 			}
411 498
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412
-		} else $all = array();
499
+		} else {
500
+			$all = array();
501
+		}
413 502
                 if (empty($all)) {
414 503
 			$filters = array('airlines' => array($stats_airline));
415 504
 			if ($filter_name != '') {
@@ -422,10 +511,15 @@  discard block
 block discarded – undo
422 511
 	}
423 512
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 513
 		global $globalStatsFilters;
425
-		if ($filter_name == '') $filter_name = $this->filter_name;
514
+		if ($filter_name == '') {
515
+			$filter_name = $this->filter_name;
516
+		}
426 517
 		if ($year == '' && $month == '') {
427
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
428
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
518
+			if ($limit) {
519
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
520
+			} else {
521
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
522
+			}
429 523
 			try {
430 524
 				$sth = $this->db->prepare($query);
431 525
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -433,7 +527,9 @@  discard block
 block discarded – undo
433 527
 				echo "error : ".$e->getMessage();
434 528
 			}
435 529
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436
-		} else $all = array();
530
+		} else {
531
+			$all = array();
532
+		}
437 533
                 if (empty($all)) {
438 534
 			$filters = array('airlines' => array($stats_airline));
439 535
             		if ($filter_name != '') {
@@ -452,7 +548,9 @@  discard block
 block discarded – undo
452 548
         			$icao = $value['airport_departure_icao'];
453 549
         			if (isset($all[$icao])) {
454 550
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
551
+        			} else {
552
+        				$all[$icao] = $value;
553
+        			}
456 554
         		}
457 555
         		$count = array();
458 556
         		foreach ($all as $key => $row) {
@@ -464,10 +562,15 @@  discard block
 block discarded – undo
464 562
 	}
465 563
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 564
 		global $globalStatsFilters;
467
-		if ($filter_name == '') $filter_name = $this->filter_name;
565
+		if ($filter_name == '') {
566
+			$filter_name = $this->filter_name;
567
+		}
468 568
 		if ($year == '' && $month == '') {
469
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
470
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
569
+			if ($limit) {
570
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
571
+			} else {
572
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
573
+			}
471 574
 			try {
472 575
 				$sth = $this->db->prepare($query);
473 576
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -475,7 +578,9 @@  discard block
 block discarded – undo
475 578
 				echo "error : ".$e->getMessage();
476 579
 			}
477 580
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
478
-		} else $all = array();
581
+		} else {
582
+			$all = array();
583
+		}
479 584
 		if (empty($all)) {
480 585
 			$filters = array('airlines' => array($stats_airline));
481 586
 			if ($filter_name != '') {
@@ -494,7 +599,9 @@  discard block
 block discarded – undo
494 599
         			$icao = $value['airport_arrival_icao'];
495 600
         			if (isset($all[$icao])) {
496 601
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
602
+        			} else {
603
+        				$all[$icao] = $value;
604
+        			}
498 605
         		}
499 606
         		$count = array();
500 607
         		foreach ($all as $key => $row) {
@@ -507,13 +614,21 @@  discard block
 block discarded – undo
507 614
 	}
508 615
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 616
 		global $globalDBdriver, $globalStatsFilters;
510
-		if ($filter_name == '') $filter_name = $this->filter_name;
617
+		if ($filter_name == '') {
618
+			$filter_name = $this->filter_name;
619
+		}
511 620
 		if ($globalDBdriver == 'mysql') {
512
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
513
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
621
+			if ($limit) {
622
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
623
+			} else {
624
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
625
+			}
514 626
 		} else {
515
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
627
+			if ($limit) {
628
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
629
+			} else {
630
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
631
+			}
517 632
 		}
518 633
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519 634
                  try {
@@ -537,7 +652,9 @@  discard block
 block discarded – undo
537 652
 	
538 653
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
539 654
 		global $globalStatsFilters;
540
-		if ($filter_name == '') $filter_name = $this->filter_name;
655
+		if ($filter_name == '') {
656
+			$filter_name = $this->filter_name;
657
+		}
541 658
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542 659
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543 660
                  try {
@@ -559,7 +676,9 @@  discard block
 block discarded – undo
559 676
 	}
560 677
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 678
 		global $globalDBdriver, $globalStatsFilters;
562
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
563 682
 		if ($globalDBdriver == 'mysql') {
564 683
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
565 684
 		} else {
@@ -585,7 +704,9 @@  discard block
 block discarded – undo
585 704
 	}
586 705
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 706
 		global $globalStatsFilters;
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
+		if ($filter_name == '') {
708
+			$filter_name = $this->filter_name;
709
+		}
589 710
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590 711
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591 712
                  try {
@@ -607,7 +728,9 @@  discard block
 block discarded – undo
607 728
 	}
608 729
 	public function countAllDatesByAirlines($filter_name = '') {
609 730
 		global $globalStatsFilters;
610
-		if ($filter_name == '') $filter_name = $this->filter_name;
731
+		if ($filter_name == '') {
732
+			$filter_name = $this->filter_name;
733
+		}
611 734
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
612 735
 		$query_data = array('filter_name' => $filter_name);
613 736
                  try {
@@ -629,7 +752,9 @@  discard block
 block discarded – undo
629 752
 	}
630 753
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 754
 		global $globalStatsFilters;
632
-		if ($filter_name == '') $filter_name = $this->filter_name;
755
+		if ($filter_name == '') {
756
+			$filter_name = $this->filter_name;
757
+		}
633 758
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 759
                  try {
635 760
                         $sth = $this->db->prepare($query);
@@ -652,7 +777,9 @@  discard block
 block discarded – undo
652 777
 	}
653 778
 	public function countAllMilitaryMonths($filter_name = '') {
654 779
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
656 783
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
657 784
                  try {
658 785
                         $sth = $this->db->prepare($query);
@@ -673,9 +800,14 @@  discard block
 block discarded – undo
673 800
 	}
674 801
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 802
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676
-		if ($filter_name == '') $filter_name = $this->filter_name;
677
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
678
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
+		if ($filter_name == '') {
804
+			$filter_name = $this->filter_name;
805
+		}
806
+		if ($limit) {
807
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
808
+		} else {
809
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
810
+		}
679 811
 		if ($orderby == 'hour') {
680 812
 			/*
681 813
 			if ($globalDBdriver == 'mysql') {
@@ -684,7 +816,9 @@  discard block
 block discarded – undo
684 816
 			*/
685 817
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 818
 		}
687
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
819
+		if ($orderby == 'count') {
820
+			$query .= " ORDER BY hour_count DESC";
821
+		}
688 822
                  try {
689 823
                         $sth = $this->db->prepare($query);
690 824
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -705,8 +839,12 @@  discard block
 block discarded – undo
705 839
 	
706 840
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
707 841
 		global $globalStatsFilters;
708
-		if ($filter_name == '') $filter_name = $this->filter_name;
709
-		if ($year == '') $year = date('Y');
842
+		if ($filter_name == '') {
843
+			$filter_name = $this->filter_name;
844
+		}
845
+		if ($year == '') {
846
+			$year = date('Y');
847
+		}
710 848
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
711 849
 		if (empty($all)) {
712 850
 			$filters = array('airlines' => array($stats_airline));
@@ -720,8 +858,12 @@  discard block
 block discarded – undo
720 858
 	}
721 859
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
722 860
 		global $globalStatsFilters;
723
-		if ($filter_name == '') $filter_name = $this->filter_name;
724
-		if ($year == '') $year = date('Y');
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
864
+		if ($year == '') {
865
+			$year = date('Y');
866
+		}
725 867
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 868
 		if (empty($all)) {
727 869
 		        $filters = array();
@@ -735,8 +877,12 @@  discard block
 block discarded – undo
735 877
 	}
736 878
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
737 879
 		global $globalStatsFilters;
738
-		if ($filter_name == '') $filter_name = $this->filter_name;
739
-		if ($year == '') $year = date('Y');
880
+		if ($filter_name == '') {
881
+			$filter_name = $this->filter_name;
882
+		}
883
+		if ($year == '') {
884
+			$year = date('Y');
885
+		}
740 886
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
741 887
 		if (empty($all)) {
742 888
 			$filters = array('airlines' => array($stats_airline));
@@ -750,7 +896,9 @@  discard block
 block discarded – undo
750 896
 	}
751 897
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
752 898
 		global $globalStatsFilters;
753
-		if ($filter_name == '') $filter_name = $this->filter_name;
899
+		if ($filter_name == '') {
900
+			$filter_name = $this->filter_name;
901
+		}
754 902
 		if ($year == '' && $month == '') {
755 903
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
756 904
 			try {
@@ -761,7 +909,9 @@  discard block
 block discarded – undo
761 909
 			}
762 910
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
763 911
 			$all = $result[0]['nb'];
764
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
912
+		} else {
913
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
914
+		}
765 915
 		if (empty($all)) {
766 916
 			$filters = array('airlines' => array($stats_airline));
767 917
 			if ($filter_name != '') {
@@ -774,7 +924,9 @@  discard block
 block discarded – undo
774 924
 	}
775 925
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
776 926
 		global $globalStatsFilters;
777
-		if ($filter_name == '') $filter_name = $this->filter_name;
927
+		if ($filter_name == '') {
928
+			$filter_name = $this->filter_name;
929
+		}
778 930
 		if ($year == '' && $month == '') {
779 931
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
780 932
 			try {
@@ -785,7 +937,9 @@  discard block
 block discarded – undo
785 937
 			}
786 938
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
787 939
 			$all = $result[0]['nb_airline'];
788
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
940
+		} else {
941
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
942
+		}
789 943
 		if (empty($all)) {
790 944
             		$filters = array();
791 945
             		if ($filter_name != '') {
@@ -798,7 +952,9 @@  discard block
 block discarded – undo
798 952
 	}
799 953
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
800 954
 		global $globalStatsFilters;
801
-		if ($filter_name == '') $filter_name = $this->filter_name;
955
+		if ($filter_name == '') {
956
+			$filter_name = $this->filter_name;
957
+		}
802 958
 		if ($year == '' && $month == '') {
803 959
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
804 960
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -825,7 +981,9 @@  discard block
 block discarded – undo
825 981
 	}
826 982
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
827 983
 		global $globalStatsFilters;
828
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
829 987
 		//if ($year == '') $year = date('Y');
830 988
 		if ($year == '' && $month == '') {
831 989
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -853,7 +1011,9 @@  discard block
 block discarded – undo
853 1011
 	}
854 1012
 
855 1013
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
856
-		if ($filter_name == '') $filter_name = $this->filter_name;
1014
+		if ($filter_name == '') {
1015
+			$filter_name = $this->filter_name;
1016
+		}
857 1017
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
858 1018
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859 1019
                  try {
@@ -866,7 +1026,9 @@  discard block
 block discarded – undo
866 1026
                 return $all;
867 1027
 	}
868 1028
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1029
+		if ($filter_name == '') {
1030
+			$filter_name = $this->filter_name;
1031
+		}
870 1032
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871 1033
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872 1034
                  try {
@@ -879,7 +1041,9 @@  discard block
 block discarded – undo
879 1041
                 return $all;
880 1042
         }
881 1043
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882
-		if ($filter_name == '') $filter_name = $this->filter_name;
1044
+		if ($filter_name == '') {
1045
+			$filter_name = $this->filter_name;
1046
+		}
883 1047
     		global $globalArchiveMonths, $globalDBdriver;
884 1048
     		if ($globalDBdriver == 'mysql') {
885 1049
     			if ($month == '') {
@@ -909,7 +1073,9 @@  discard block
 block discarded – undo
909 1073
         }
910 1074
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911 1075
     		global $globalArchiveMonths, $globalDBdriver;
912
-		if ($filter_name == '') $filter_name = $this->filter_name;
1076
+		if ($filter_name == '') {
1077
+			$filter_name = $this->filter_name;
1078
+		}
913 1079
     		if ($globalDBdriver == 'mysql') {
914 1080
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
915 1081
 		} else {
@@ -927,7 +1093,9 @@  discard block
 block discarded – undo
927 1093
         }
928 1094
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929 1095
     		global $globalArchiveMonths, $globalDBdriver;
930
-		if ($filter_name == '') $filter_name = $this->filter_name;
1096
+		if ($filter_name == '') {
1097
+			$filter_name = $this->filter_name;
1098
+		}
931 1099
     		if ($globalDBdriver == 'mysql') {
932 1100
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933 1101
                 } else {
@@ -944,7 +1112,9 @@  discard block
 block discarded – undo
944 1112
         }
945 1113
 	public function getStatsAirlineTotal($filter_name = '') {
946 1114
     		global $globalArchiveMonths, $globalDBdriver;
947
-		if ($filter_name == '') $filter_name = $this->filter_name;
1115
+		if ($filter_name == '') {
1116
+			$filter_name = $this->filter_name;
1117
+		}
948 1118
     		if ($globalDBdriver == 'mysql') {
949 1119
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950 1120
                 } else {
@@ -961,7 +1131,9 @@  discard block
 block discarded – undo
961 1131
         }
962 1132
 	public function getStatsOwnerTotal($filter_name = '') {
963 1133
     		global $globalArchiveMonths, $globalDBdriver;
964
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
965 1137
     		if ($globalDBdriver == 'mysql') {
966 1138
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 1139
 		} else {
@@ -978,7 +1150,9 @@  discard block
 block discarded – undo
978 1150
         }
979 1151
 	public function getStatsPilotTotal($filter_name = '') {
980 1152
     		global $globalArchiveMonths, $globalDBdriver;
981
-		if ($filter_name == '') $filter_name = $this->filter_name;
1153
+		if ($filter_name == '') {
1154
+			$filter_name = $this->filter_name;
1155
+		}
982 1156
     		if ($globalDBdriver == 'mysql') {
983 1157
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
984 1158
             	} else {
@@ -996,7 +1170,9 @@  discard block
 block discarded – undo
996 1170
 
997 1171
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
998 1172
 		global $globalDBdriver;
999
-		if ($filter_name == '') $filter_name = $this->filter_name;
1173
+		if ($filter_name == '') {
1174
+			$filter_name = $this->filter_name;
1175
+		}
1000 1176
 		if ($globalDBdriver == 'mysql') {
1001 1177
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1002 1178
                 } else {
@@ -1012,7 +1188,9 @@  discard block
 block discarded – undo
1012 1188
         }
1013 1189
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1014 1190
 		global $globalDBdriver;
1015
-		if ($filter_name == '') $filter_name = $this->filter_name;
1191
+		if ($filter_name == '') {
1192
+			$filter_name = $this->filter_name;
1193
+		}
1016 1194
 		if ($globalDBdriver == 'mysql') {
1017 1195
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1018 1196
 		} else {
@@ -1398,10 +1576,14 @@  discard block
 block discarded – undo
1398 1576
     		$Connection = new Connection();
1399 1577
     		date_default_timezone_set('UTC');
1400 1578
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1401
-			if ($globalDebug) echo 'Update stats !'."\n";
1579
+			if ($globalDebug) {
1580
+				echo 'Update stats !'."\n";
1581
+			}
1402 1582
 			if (isset($last_update[0]['value'])) {
1403 1583
 				$last_update_day = $last_update[0]['value'];
1404
-			} else $last_update_day = '2012-12-12 12:12:12';
1584
+			} else {
1585
+				$last_update_day = '2012-12-12 12:12:12';
1586
+			}
1405 1587
 			$reset = false;
1406 1588
 			if ($globalStatsResetYear) {
1407 1589
 				$reset = true;
@@ -1409,42 +1591,60 @@  discard block
 block discarded – undo
1409 1591
 			}
1410 1592
 			$Spotter = new Spotter($this->db);
1411 1593
 
1412
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1594
+			if ($globalDebug) {
1595
+				echo 'Count all aircraft types...'."\n";
1596
+			}
1413 1597
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1414 1598
 			foreach ($alldata as $number) {
1415 1599
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1416 1600
 			}
1417
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1601
+			if ($globalDebug) {
1602
+				echo 'Count all airlines...'."\n";
1603
+			}
1418 1604
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1419 1605
 			foreach ($alldata as $number) {
1420 1606
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1421 1607
 			}
1422
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1608
+			if ($globalDebug) {
1609
+				echo 'Count all registrations...'."\n";
1610
+			}
1423 1611
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1424 1612
 			foreach ($alldata as $number) {
1425 1613
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1426 1614
 			}
1427
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1615
+			if ($globalDebug) {
1616
+				echo 'Count all callsigns...'."\n";
1617
+			}
1428 1618
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1429 1619
 			foreach ($alldata as $number) {
1430 1620
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1431 1621
 			}
1432
-			if ($globalDebug) echo 'Count all owners...'."\n";
1622
+			if ($globalDebug) {
1623
+				echo 'Count all owners...'."\n";
1624
+			}
1433 1625
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1434 1626
 			foreach ($alldata as $number) {
1435 1627
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1436 1628
 			}
1437
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1629
+			if ($globalDebug) {
1630
+				echo 'Count all pilots...'."\n";
1631
+			}
1438 1632
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1439 1633
 			foreach ($alldata as $number) {
1440 1634
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1441 1635
 			}
1442 1636
 			
1443
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1637
+			if ($globalDebug) {
1638
+				echo 'Count all departure airports...'."\n";
1639
+			}
1444 1640
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1445
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1641
+			if ($globalDebug) {
1642
+				echo 'Count all detected departure airports...'."\n";
1643
+			}
1446 1644
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1447
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1645
+			if ($globalDebug) {
1646
+				echo 'Order departure airports...'."\n";
1647
+			}
1448 1648
 	        	$alldata = array();
1449 1649
 	        	
1450 1650
     			foreach ($pall as $value) {
@@ -1455,7 +1655,9 @@  discard block
 block discarded – undo
1455 1655
     				$icao = $value['airport_departure_icao'];
1456 1656
         			if (isset($alldata[$icao])) {
1457 1657
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1458
-        			} else $alldata[$icao] = $value;
1658
+        			} else {
1659
+        				$alldata[$icao] = $value;
1660
+        			}
1459 1661
 			}
1460 1662
     			$count = array();
1461 1663
     			foreach ($alldata as $key => $row) {
@@ -1465,11 +1667,17 @@  discard block
 block discarded – undo
1465 1667
 			foreach ($alldata as $number) {
1466 1668
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1467 1669
 			}
1468
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1670
+			if ($globalDebug) {
1671
+				echo 'Count all arrival airports...'."\n";
1672
+			}
1469 1673
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1470
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1674
+			if ($globalDebug) {
1675
+				echo 'Count all detected arrival airports...'."\n";
1676
+			}
1471 1677
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1472
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1678
+			if ($globalDebug) {
1679
+				echo 'Order arrival airports...'."\n";
1680
+			}
1473 1681
 	        	$alldata = array();
1474 1682
     			foreach ($pall as $value) {
1475 1683
 	        		$icao = $value['airport_arrival_icao'];
@@ -1479,7 +1687,9 @@  discard block
 block discarded – undo
1479 1687
     				$icao = $value['airport_arrival_icao'];
1480 1688
         			if (isset($alldata[$icao])) {
1481 1689
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1482
-	        		} else $alldata[$icao] = $value;
1690
+	        		} else {
1691
+	        			$alldata[$icao] = $value;
1692
+	        		}
1483 1693
     			}
1484 1694
         		$count = array();
1485 1695
         		foreach ($alldata as $key => $row) {
@@ -1490,7 +1700,9 @@  discard block
 block discarded – undo
1490 1700
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1491 1701
 			}
1492 1702
 			if ($Connection->tableExists('countries')) {
1493
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1703
+				if ($globalDebug) {
1704
+					echo 'Count all flights by countries...'."\n";
1705
+				}
1494 1706
 				$SpotterArchive = new SpotterArchive();
1495 1707
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1496 1708
 				foreach ($alldata as $number) {
@@ -1502,46 +1714,66 @@  discard block
 block discarded – undo
1502 1714
 			// Add by month using getstat if month finish...
1503 1715
 
1504 1716
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1505
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1717
+			if ($globalDebug) {
1718
+				echo 'Count all flights by months...'."\n";
1719
+			}
1506 1720
 			$Spotter = new Spotter($this->db);
1507 1721
 			$alldata = $Spotter->countAllMonths();
1508 1722
 			$lastyear = false;
1509 1723
 			foreach ($alldata as $number) {
1510
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1724
+				if ($number['year_name'] != date('Y')) {
1725
+					$lastyear = true;
1726
+				}
1511 1727
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1512 1728
 			}
1513
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1729
+			if ($globalDebug) {
1730
+				echo 'Count all military flights by months...'."\n";
1731
+			}
1514 1732
 			$alldata = $Spotter->countAllMilitaryMonths();
1515 1733
 			foreach ($alldata as $number) {
1516 1734
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1517 1735
 			}
1518
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1736
+			if ($globalDebug) {
1737
+				echo 'Count all owners by months...'."\n";
1738
+			}
1519 1739
 			$alldata = $Spotter->countAllMonthsOwners();
1520 1740
 			foreach ($alldata as $number) {
1521 1741
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1522 1742
 			}
1523
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1743
+			if ($globalDebug) {
1744
+				echo 'Count all pilots by months...'."\n";
1745
+			}
1524 1746
 			$alldata = $Spotter->countAllMonthsPilots();
1525 1747
 			foreach ($alldata as $number) {
1526 1748
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1527 1749
 			}
1528
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1750
+			if ($globalDebug) {
1751
+				echo 'Count all airlines by months...'."\n";
1752
+			}
1529 1753
 			$alldata = $Spotter->countAllMonthsAirlines();
1530 1754
 			foreach ($alldata as $number) {
1531 1755
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1532 1756
 			}
1533
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1757
+			if ($globalDebug) {
1758
+				echo 'Count all aircrafts by months...'."\n";
1759
+			}
1534 1760
 			$alldata = $Spotter->countAllMonthsAircrafts();
1535 1761
 			foreach ($alldata as $number) {
1536 1762
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1537 1763
 			}
1538
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1764
+			if ($globalDebug) {
1765
+				echo 'Count all real arrivals by months...'."\n";
1766
+			}
1539 1767
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1540 1768
 			foreach ($alldata as $number) {
1541 1769
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1542 1770
 			}
1543
-			if ($globalDebug) echo 'Airports data...'."\n";
1544
-			if ($globalDebug) echo '...Departure'."\n";
1771
+			if ($globalDebug) {
1772
+				echo 'Airports data...'."\n";
1773
+			}
1774
+			if ($globalDebug) {
1775
+				echo '...Departure'."\n";
1776
+			}
1545 1777
 			$this->deleteStatAirport('daily');
1546 1778
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1547 1779
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1662,44 +1894,62 @@  discard block
 block discarded – undo
1662 1894
 			// Count by airlines
1663 1895
 			echo '--- Stats by airlines ---'."\n";
1664 1896
 			if ($Connection->tableExists('countries')) {
1665
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1897
+				if ($globalDebug) {
1898
+					echo 'Count all flights by countries by airlines...'."\n";
1899
+				}
1666 1900
 				$SpotterArchive = new SpotterArchive();
1667 1901
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1668 1902
 				foreach ($alldata as $number) {
1669 1903
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1670 1904
 				}
1671 1905
 			}
1672
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1906
+			if ($globalDebug) {
1907
+				echo 'Count all aircraft types by airlines...'."\n";
1908
+			}
1673 1909
 			$Spotter = new Spotter($this->db);
1674 1910
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1675 1911
 			foreach ($alldata as $number) {
1676 1912
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1677 1913
 			}
1678
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1914
+			if ($globalDebug) {
1915
+				echo 'Count all aircraft registrations by airlines...'."\n";
1916
+			}
1679 1917
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1680 1918
 			foreach ($alldata as $number) {
1681 1919
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1682 1920
 			}
1683
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1921
+			if ($globalDebug) {
1922
+				echo 'Count all callsigns by airlines...'."\n";
1923
+			}
1684 1924
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1685 1925
 			foreach ($alldata as $number) {
1686 1926
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1687 1927
 			}
1688
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1928
+			if ($globalDebug) {
1929
+				echo 'Count all owners by airlines...'."\n";
1930
+			}
1689 1931
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1690 1932
 			foreach ($alldata as $number) {
1691 1933
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1692 1934
 			}
1693
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo 'Count all pilots by airlines...'."\n";
1937
+			}
1694 1938
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1695 1939
 			foreach ($alldata as $number) {
1696 1940
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1697 1941
 			}
1698
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1942
+			if ($globalDebug) {
1943
+				echo 'Count all departure airports by airlines...'."\n";
1944
+			}
1699 1945
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1700
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1946
+			if ($globalDebug) {
1947
+				echo 'Count all detected departure airports by airlines...'."\n";
1948
+			}
1701 1949
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1702
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1950
+			if ($globalDebug) {
1951
+				echo 'Order detected departure airports by airlines...'."\n";
1952
+			}
1703 1953
 	        	//$alldata = array();
1704 1954
     			foreach ($dall as $value) {
1705 1955
     				$icao = $value['airport_departure_icao'];
@@ -1720,11 +1970,17 @@  discard block
 block discarded – undo
1720 1970
 			foreach ($alldata as $number) {
1721 1971
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1722 1972
 			}
1723
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1973
+			if ($globalDebug) {
1974
+				echo 'Count all arrival airports by airlines...'."\n";
1975
+			}
1724 1976
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1725
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1977
+			if ($globalDebug) {
1978
+				echo 'Count all detected arrival airports by airlines...'."\n";
1979
+			}
1726 1980
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1727
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Order arrival airports by airlines...'."\n";
1983
+			}
1728 1984
 	        	//$alldata = array();
1729 1985
     			foreach ($dall as $value) {
1730 1986
     				$icao = $value['airport_arrival_icao'];
@@ -1743,37 +1999,53 @@  discard block
 block discarded – undo
1743 1999
     			}
1744 2000
     			$alldata = $pall;
1745 2001
                         foreach ($alldata as $number) {
1746
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2002
+				if ($number['airline_icao'] != '') {
2003
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2004
+				}
2005
+			}
2006
+			if ($globalDebug) {
2007
+				echo 'Count all flights by months by airlines...'."\n";
1747 2008
 			}
1748
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1749 2009
 			$Spotter = new Spotter($this->db);
1750 2010
 			$alldata = $Spotter->countAllMonthsByAirlines();
1751 2011
 			$lastyear = false;
1752 2012
 			foreach ($alldata as $number) {
1753
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2013
+				if ($number['year_name'] != date('Y')) {
2014
+					$lastyear = true;
2015
+				}
1754 2016
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1755 2017
 			}
1756
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2018
+			if ($globalDebug) {
2019
+				echo 'Count all owners by months by airlines...'."\n";
2020
+			}
1757 2021
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1758 2022
 			foreach ($alldata as $number) {
1759 2023
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1760 2024
 			}
1761
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2025
+			if ($globalDebug) {
2026
+				echo 'Count all pilots by months by airlines...'."\n";
2027
+			}
1762 2028
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1763 2029
 			foreach ($alldata as $number) {
1764 2030
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1765 2031
 			}
1766
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2032
+			if ($globalDebug) {
2033
+				echo 'Count all aircrafts by months by airlines...'."\n";
2034
+			}
1767 2035
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1768 2036
 			foreach ($alldata as $number) {
1769 2037
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1770 2038
 			}
1771
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2039
+			if ($globalDebug) {
2040
+				echo 'Count all real arrivals by months by airlines...'."\n";
2041
+			}
1772 2042
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1773 2043
 			foreach ($alldata as $number) {
1774 2044
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1775 2045
 			}
1776
-			if ($globalDebug) echo '...Departure'."\n";
2046
+			if ($globalDebug) {
2047
+				echo '...Departure'."\n";
2048
+			}
1777 2049
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1778 2050
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1779 2051
     			foreach ($dall as $value) {
@@ -1796,7 +2068,9 @@  discard block
 block discarded – undo
1796 2068
 			foreach ($alldata as $number) {
1797 2069
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1798 2070
 			}
1799
-			if ($globalDebug) echo '...Arrival'."\n";
2071
+			if ($globalDebug) {
2072
+				echo '...Arrival'."\n";
2073
+			}
1800 2074
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1801 2075
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1802 2076
     			foreach ($dall as $value) {
@@ -1820,13 +2094,19 @@  discard block
 block discarded – undo
1820 2094
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1821 2095
 			}
1822 2096
 
1823
-			if ($globalDebug) echo 'Flights data...'."\n";
1824
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2097
+			if ($globalDebug) {
2098
+				echo 'Flights data...'."\n";
2099
+			}
2100
+			if ($globalDebug) {
2101
+				echo '-> countAllDatesLastMonth...'."\n";
2102
+			}
1825 2103
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1826 2104
 			foreach ($alldata as $number) {
1827 2105
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1828 2106
 			}
1829
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2107
+			if ($globalDebug) {
2108
+				echo '-> countAllDates...'."\n";
2109
+			}
1830 2110
 			//$previousdata = $this->countAllDatesByAirlines();
1831 2111
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1832 2112
 			$values = array();
@@ -1839,7 +2119,9 @@  discard block
 block discarded – undo
1839 2119
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1840 2120
 			}
1841 2121
 			
1842
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2122
+			if ($globalDebug) {
2123
+				echo '-> countAllHours...'."\n";
2124
+			}
1843 2125
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1844 2126
 			foreach ($alldata as $number) {
1845 2127
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1847,7 +2129,9 @@  discard block
 block discarded – undo
1847 2129
 			
1848 2130
 
1849 2131
 			// Stats by filters
1850
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2132
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2133
+				$globalStatsFilters = array();
2134
+			}
1851 2135
 			foreach ($globalStatsFilters as $name => $filter) {
1852 2136
 				//$filter_name = $filter['name'];
1853 2137
 				$filter_name = $name;
@@ -1855,11 +2139,15 @@  discard block
 block discarded – undo
1855 2139
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1856 2140
 				if (isset($last_update[0]['value'])) {
1857 2141
 					$last_update_day = $last_update[0]['value'];
1858
-				} else $last_update_day = '2012-12-12 12:12:12';
2142
+				} else {
2143
+					$last_update_day = '2012-12-12 12:12:12';
2144
+				}
1859 2145
 				$reset = false;
1860 2146
 
1861 2147
 				// Count by filter
1862
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2148
+				if ($globalDebug) {
2149
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2150
+				}
1863 2151
 				$Spotter = new Spotter($this->db);
1864 2152
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1865 2153
 				foreach ($alldata as $number) {
@@ -1896,7 +2184,9 @@  discard block
 block discarded – undo
1896 2184
 	    				$icao = $value['airport_departure_icao'];
1897 2185
         				if (isset($alldata[$icao])) {
1898 2186
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1899
-        				} else $alldata[$icao] = $value;
2187
+        				} else {
2188
+        					$alldata[$icao] = $value;
2189
+        				}
1900 2190
 				}
1901 2191
 	    			$count = array();
1902 2192
     				foreach ($alldata as $key => $row) {
@@ -1917,7 +2207,9 @@  discard block
 block discarded – undo
1917 2207
 	    				$icao = $value['airport_arrival_icao'];
1918 2208
         				if (isset($alldata[$icao])) {
1919 2209
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1920
-		        		} else $alldata[$icao] = $value;
2210
+		        		} else {
2211
+		        			$alldata[$icao] = $value;
2212
+		        		}
1921 2213
 	    			}
1922 2214
         			$count = array();
1923 2215
         			foreach ($alldata as $key => $row) {
@@ -1931,7 +2223,9 @@  discard block
 block discarded – undo
1931 2223
 				$alldata = $Spotter->countAllMonths($filter);
1932 2224
 				$lastyear = false;
1933 2225
 				foreach ($alldata as $number) {
1934
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2226
+					if ($number['year_name'] != date('Y')) {
2227
+						$lastyear = true;
2228
+					}
1935 2229
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1936 2230
 				}
1937 2231
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.