Completed
Push — master ( 302f5a...bb5a03 )
by Yannick
30:38
created
require/class.Stats.php 2 patches
Spacing   +627 added lines, -627 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
22 22
 	}
23 23
 
24
-	public function addLastStatsUpdate($type,$stats_date) {
24
+	public function addLastStatsUpdate($type, $stats_date) {
25 25
 		$query = "DELETE FROM config WHERE name = :type;
26 26
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
27
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
27
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		try {
39 39
 			$sth = $this->db->prepare($query);
40 40
 			$sth->execute(array(':type' => $type));
41
-		} catch(PDOException $e) {
41
+		} catch (PDOException $e) {
42 42
 			echo "error : ".$e->getMessage();
43 43
 		}
44 44
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		try {
60 60
 			$sth = $this->db->prepare($query);
61 61
 			$sth->execute(array(':filter_name' => $filter_name));
62
-		} catch(PDOException $e) {
62
+		} catch (PDOException $e) {
63 63
 			return "error : ".$e->getMessage();
64 64
 		}
65 65
 	}
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		try {
73 73
 			$sth = $this->db->prepare($query);
74 74
 			$sth->execute();
75
-		} catch(PDOException $e) {
75
+		} catch (PDOException $e) {
76 76
 			return "error : ".$e->getMessage();
77 77
 		}
78 78
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute(array(':filter_name' => $filter_name));
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 	}
@@ -91,77 +91,77 @@  discard block
 block discarded – undo
91 91
 		 try {
92 92
 			$sth = $this->db->prepare($query);
93 93
 			$sth->execute(array(':filter_name' => $filter_name));
94
-		} catch(PDOException $e) {
94
+		} catch (PDOException $e) {
95 95
 			echo "error : ".$e->getMessage();
96 96
 		}
97 97
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
98 98
 		if (empty($all)) {
99 99
 			$filters = array();
100 100
 			if ($filter_name != '') {
101
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
101
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
102 102
 			}
103 103
 			$Spotter = new Spotter($this->db);
104
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
104
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
105 105
 		}
106 106
 		return $all;
107 107
 	}
108
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
108
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
109 109
 		if ($filter_name == '') $filter_name = $this->filter_name;
110 110
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 111
 		try {
112 112
 			$sth = $this->db->prepare($query);
113
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
114
-		} catch(PDOException $e) {
113
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
114
+		} catch (PDOException $e) {
115 115
 			echo "error : ".$e->getMessage();
116 116
 		}
117 117
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
118 118
 		return $all;
119 119
 	}
120
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
120
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
121 121
 		if ($filter_name == '') $filter_name = $this->filter_name;
122 122
 		$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";
123 123
 		try {
124 124
 			$sth = $this->db->prepare($query);
125
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
126
-		} catch(PDOException $e) {
125
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
126
+		} catch (PDOException $e) {
127 127
 			echo "error : ".$e->getMessage();
128 128
 		}
129 129
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
130 130
 		return $all;
131 131
 	}
132
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
 		$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";
135 135
 		try {
136 136
 			$sth = $this->db->prepare($query);
137
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-		} catch(PDOException $e) {
137
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+		} catch (PDOException $e) {
139 139
 			echo "error : ".$e->getMessage();
140 140
 		}
141 141
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
 		return $all;
143 143
 	}
144 144
 
145
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 148
 		try {
149 149
 			$sth = $this->db->prepare($query);
150
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-		} catch(PDOException $e) {
150
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+		} catch (PDOException $e) {
152 152
 			echo "error : ".$e->getMessage();
153 153
 		}
154 154
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
155 155
 		return $all;
156 156
 	}
157 157
 
158
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
158
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
159 159
 		if ($filter_name == '') $filter_name = $this->filter_name;
160 160
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
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,23 +169,23 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 
172
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
172
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
173 173
 		global $globalStatsFilters;
174 174
 		if ($filter_name == '') $filter_name = $this->filter_name;
175
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
175
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
176 176
 			$Spotter = new Spotter($this->db);
177
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
177
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
178 178
 			$alliance_airlines = array();
179 179
 			foreach ($airlines as $airline) {
180
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
180
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
181 181
 			}
182 182
 			if ($year == '' && $month == '') {
183
-				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
183
+				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
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);
@@ -196,29 +196,29 @@  discard block
 block discarded – undo
196 196
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
197 197
 				try {
198 198
 					$sth = $this->db->prepare($query);
199
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
200
-				} catch(PDOException $e) {
199
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
200
+				} catch (PDOException $e) {
201 201
 					echo "error : ".$e->getMessage();
202 202
 				}
203 203
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204 204
 			} else $all = array();
205 205
 		}
206 206
 		if (empty($all)) {
207
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
208
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
207
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
208
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
209 209
 			} else {
210
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
210
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
211 211
 			}
212 212
 			if ($filter_name != '') {
213
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
213
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
214 214
 			}
215 215
 			$Spotter = new Spotter($this->db);
216 216
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
217
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
217
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
218 218
 		}
219 219
 		return $all;
220 220
 	}
221
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
221
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
222 222
 		global $globalStatsFilters;
223 223
 		if ($filter_name == '') $filter_name = $this->filter_name;
224 224
 		if ($year == '' && $month == '') {
@@ -227,23 +227,23 @@  discard block
 block discarded – undo
227 227
 			try {
228 228
 				$sth = $this->db->prepare($query);
229 229
 				$sth->execute(array(':filter_name' => $filter_name));
230
-			} catch(PDOException $e) {
230
+			} catch (PDOException $e) {
231 231
 				echo "error : ".$e->getMessage();
232 232
 			}
233 233
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234 234
 		} else $all = array();
235 235
 		if (empty($all)) {
236
-			$filters = array('year' => $year,'month' => $month);
236
+			$filters = array('year' => $year, 'month' => $month);
237 237
 			if ($filter_name != '') {
238
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
238
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
239 239
 			}
240 240
 			$Marine = new Marine($this->db);
241 241
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
242
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
242
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
243 243
 		}
244 244
 		return $all;
245 245
 	}
246
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
246
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
247 247
 		global $globalStatsFilters;
248 248
 		if ($filter_name == '') $filter_name = $this->filter_name;
249 249
 		if ($year == '' && $month == '') {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			try {
253 253
 				$sth = $this->db->prepare($query);
254 254
 				$sth->execute(array(':filter_name' => $filter_name));
255
-			} catch(PDOException $e) {
255
+			} catch (PDOException $e) {
256 256
 				echo "error : ".$e->getMessage();
257 257
 			}
258 258
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -260,32 +260,32 @@  discard block
 block discarded – undo
260 260
 		if (empty($all)) {
261 261
 			$Spotter = new Spotter($this->db);
262 262
 			$filters = array();
263
-			$filters = array('year' => $year,'month' => $month);
263
+			$filters = array('year' => $year, 'month' => $month);
264 264
 			if ($filter_name != '') {
265
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
265
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
266 266
 			}
267 267
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
268
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
268
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
269 269
 		}
270 270
 		return $all;
271 271
 	}
272
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
272
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
273 273
 		global $globalStatsFilters;
274 274
 		if ($filter_name == '') $filter_name = $this->filter_name;
275
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
275
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
276 276
 			$Spotter = new Spotter($this->db);
277
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
277
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
278 278
 			$alliance_airlines = array();
279 279
 			foreach ($airlines as $airline) {
280
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
280
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
281 281
 			}
282 282
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
283
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
285 285
 				try {
286 286
 					$sth = $this->db->prepare($query);
287 287
 					$sth->execute(array(':filter_name' => $filter_name));
288
-				} catch(PDOException $e) {
288
+				} catch (PDOException $e) {
289 289
 					echo "error : ".$e->getMessage();
290 290
 				}
291 291
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -296,21 +296,21 @@  discard block
 block discarded – undo
296 296
 				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";
297 297
 				try {
298 298
 					$sth = $this->db->prepare($query);
299
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
300
-				} catch(PDOException $e) {
299
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
300
+				} catch (PDOException $e) {
301 301
 					echo "error : ".$e->getMessage();
302 302
 				}
303 303
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304 304
 			} else $all = array();
305 305
 		}
306 306
 		if (empty($all)) {
307
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
308
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
307
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
308
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
309 309
 			} else {
310
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
310
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
311 311
 			}
312 312
 			if ($filter_name != '') {
313
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			$Spotter = new Spotter($this->db);
316 316
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
 		return $all;
320 320
 	}
321 321
 
322
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
322
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
323 323
 		global $globalStatsFilters;
324 324
 		if ($filter_name == '') $filter_name = $this->filter_name;
325
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
325
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
326 326
 			$Spotter = new Spotter($this->db);
327
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
327
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
328 328
 			$alliance_airlines = array();
329 329
 			foreach ($airlines as $airline) {
330
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
330
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
331 331
 			}
332 332
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
333
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
335 335
 				try {
336 336
 					$sth = $this->db->prepare($query);
337 337
 					$sth->execute(array(':filter_name' => $filter_name));
338
-				} catch(PDOException $e) {
338
+				} catch (PDOException $e) {
339 339
 					echo "error : ".$e->getMessage();
340 340
 				}
341 341
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -346,61 +346,61 @@  discard block
 block discarded – undo
346 346
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
347 347
 				try {
348 348
 					$sth = $this->db->prepare($query);
349
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
350
-				} catch(PDOException $e) {
349
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
350
+				} catch (PDOException $e) {
351 351
 					echo "error : ".$e->getMessage();
352 352
 				}
353 353
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354 354
 			} else $all = array();
355 355
 		}
356 356
 		if (empty($all)) {
357
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
358
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
357
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
358
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
359 359
 			} else {
360
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			}
362 362
 			if ($filter_name != '') {
363
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
363
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
364 364
 			}
365 365
 			$Spotter = new Spotter($this->db);
366 366
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
367
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
367
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
368 368
 		}
369 369
 		return $all;
370 370
 	}
371 371
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 372
 		global $globalStatsFilters;
373 373
 		if ($filter_name == '') $filter_name = $this->filter_name;
374
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
374
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
375 375
 			$Spotter = new Spotter($this->db);
376
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
376
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
377 377
 			$alliance_airlines = array();
378 378
 			foreach ($airlines as $airline) {
379
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
379
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
380 380
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
381
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
383 383
 			$query_values = array(':filter_name' => $filter_name);
384 384
 		} else {
385 385
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386 386
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
387
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
387
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
388 388
 		}
389 389
 		try {
390 390
 			$sth = $this->db->prepare($query);
391 391
 			$sth->execute($query_values);
392
-		} catch(PDOException $e) {
392
+		} catch (PDOException $e) {
393 393
 			echo "error : ".$e->getMessage();
394 394
 		}
395 395
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
396 396
 		if (empty($all)) {
397
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
398
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
397
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
398
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
399 399
 			} else {
400
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
400
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
401 401
 			}
402 402
 			if ($filter_name != '') {
403
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
403
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
404 404
 			}
405 405
 			$Spotter = new Spotter($this->db);
406 406
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		return $all;
410 410
 	}
411 411
 
412
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
412
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
413 413
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414 414
 		if ($filter_name == '') $filter_name = $this->filter_name;
415 415
 		if ($year == '' && $month == '') {
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			if (isset($forsource)) {
419 419
 				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420 420
 				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
421
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
421
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
422 422
 			} else {
423 423
 				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424 424
 				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			try {
428 428
 				$sth = $this->db->prepare($query);
429 429
 				$sth->execute($query_values);
430
-			} catch(PDOException $e) {
430
+			} catch (PDOException $e) {
431 431
 				echo "error : ".$e->getMessage();
432 432
 			}
433 433
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -435,32 +435,32 @@  discard block
 block discarded – undo
435 435
                 if (empty($all)) {
436 436
 	                $Spotter = new Spotter($this->db);
437 437
             		$filters = array();
438
-			$filters = array('year' => $year,'month' => $month);
438
+			$filters = array('year' => $year, 'month' => $month);
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
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
443
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
443
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
450
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
451 451
 			$Spotter = new Spotter($this->db);
452
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
452
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
453 453
 			$alliance_airlines = array();
454 454
 			foreach ($airlines as $airline) {
455
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
455
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
456 456
 			}
457 457
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
458
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
+				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
460 460
 				try {
461 461
 					$sth = $this->db->prepare($query);
462 462
 					$sth->execute(array(':filter_name' => $filter_name));
463
-				} catch(PDOException $e) {
463
+				} catch (PDOException $e) {
464 464
 					echo "error : ".$e->getMessage();
465 465
 				}
466 466
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -471,45 +471,45 @@  discard block
 block discarded – undo
471 471
 				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
472 472
 				try {
473 473
 					$sth = $this->db->prepare($query);
474
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
475
-				} catch(PDOException $e) {
474
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
475
+				} catch (PDOException $e) {
476 476
 					echo "error : ".$e->getMessage();
477 477
 				}
478 478
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479 479
 			} else $all = array();
480 480
 		}
481 481
 		if (empty($all)) {
482
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
483
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
482
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
483
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
484 484
 			} else {
485
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
485
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
486 486
 			}
487 487
 			if ($filter_name != '') {
488
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
488
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
489 489
 			}
490 490
 			$Spotter = new Spotter($this->db);
491 491
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
492
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
492
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
493 493
 		}
494 494
 		return $all;
495 495
 	}
496
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
496
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
497 497
 		global $globalStatsFilters;
498 498
 		if ($filter_name == '') $filter_name = $this->filter_name;
499
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
499
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
500 500
 			$Spotter = new Spotter($this->db);
501
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
501
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
502 502
 			$alliance_airlines = array();
503 503
 			foreach ($airlines as $airline) {
504
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
504
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
505 505
 			}
506 506
 			if ($year == '' && $month == '') {
507
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
507
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
509 509
 				 try {
510 510
 					$sth = $this->db->prepare($query);
511 511
 					$sth->execute(array(':filter_name' => $filter_name));
512
-				} catch(PDOException $e) {
512
+				} catch (PDOException $e) {
513 513
 					echo "error : ".$e->getMessage();
514 514
 				}
515 515
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -520,46 +520,46 @@  discard block
 block discarded – undo
520 520
 				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";
521 521
 				 try {
522 522
 					$sth = $this->db->prepare($query);
523
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
524
-				} catch(PDOException $e) {
523
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
524
+				} catch (PDOException $e) {
525 525
 					echo "error : ".$e->getMessage();
526 526
 				}
527 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528 528
 			} else $all = array();
529 529
 		}
530 530
 		if (empty($all)) {
531
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
532
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
531
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
532
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
533 533
 			} else {
534
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
534
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
535 535
 			}
536 536
 			if ($filter_name != '') {
537
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
538 538
 			}
539 539
 			$Spotter = new Spotter($this->db);
540 540
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
541
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
541
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
542 542
 		}
543 543
 		return $all;
544 544
 	}
545
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
545
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
546 546
 		$Connection = new Connection($this->db);
547 547
 		if ($filter_name == '') $filter_name = $this->filter_name;
548 548
 		if ($Connection->tableExists('countries')) {
549
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
549
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
550 550
 				$Spotter = new Spotter($this->db);
551
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
551
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
552 552
 				if ($year == '' && $month == '') {
553 553
 					$alliance_airlines = array();
554 554
 					foreach ($airlines as $airline) {
555
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
555
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
556 556
 					}
557
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
557
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
559 559
 					 try {
560 560
 						$sth = $this->db->prepare($query);
561 561
 						$sth->execute(array(':filter_name' => $filter_name));
562
-					} catch(PDOException $e) {
562
+					} catch (PDOException $e) {
563 563
 						echo "error : ".$e->getMessage();
564 564
 					}
565 565
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 					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";
572 572
 					 try {
573 573
 						$sth = $this->db->prepare($query);
574
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
575
-					} catch(PDOException $e) {
574
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
575
+					} catch (PDOException $e) {
576 576
 						echo "error : ".$e->getMessage();
577 577
 					}
578 578
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			return $Spotter->countAllFlightOverCountries($limit);
584 584
 		} else return array();
585 585
 	}
586
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
586
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
587 587
 		$Connection = new Connection($this->db);
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		if ($Connection->tableExists('countries')) {
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 				 try {
595 595
 					$sth = $this->db->prepare($query);
596 596
 					$sth->execute(array(':filter_name' => $filter_name));
597
-				} catch(PDOException $e) {
597
+				} catch (PDOException $e) {
598 598
 					echo "error : ".$e->getMessage();
599 599
 				}
600 600
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
 			if (empty($all)) {
603 603
 				$filters = array();
604 604
 				if ($filter_name != '') {
605
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
605
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
606 606
 				}
607 607
 				$Marine = new Marine($this->db);
608
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
608
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
609 609
 			}
610 610
 			return $all;
611 611
 		} else return array();
612 612
 	}
613
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
613
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
614 614
 		global $globalStatsFilters;
615 615
 		$Connection = new Connection($this->db);
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 				 try {
623 623
 					$sth = $this->db->prepare($query);
624 624
 					$sth->execute(array(':filter_name' => $filter_name));
625
-				} catch(PDOException $e) {
625
+				} catch (PDOException $e) {
626 626
 					echo "error : ".$e->getMessage();
627 627
 				}
628 628
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 			if (empty($all)) {
632 632
 				$filters = array();
633 633
 				if ($filter_name != '') {
634
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
634
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
635 635
 				}
636 636
 				$Tracker = new Tracker($this->db);
637
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
637
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
638 638
 			}
639 639
 			return $all;
640 640
 		} else return array();
641 641
 	}
642
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
642
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
643 643
 		global $globalStatsFilters;
644 644
 		if ($filter_name == '') $filter_name = $this->filter_name;
645 645
 		if ($year == '' && $month == '') {
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
 			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";
648 648
 			try {
649 649
 				$sth = $this->db->prepare($query);
650
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
651
-			} catch(PDOException $e) {
650
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
651
+			} catch (PDOException $e) {
652 652
 				echo "error : ".$e->getMessage();
653 653
 			}
654 654
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655 655
 		} else $all = array();
656 656
 		if (empty($all)) {
657
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
657
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
658 658
 			if ($filter_name != '') {
659
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
659
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
660 660
 			}
661 661
 			$Spotter = new Spotter($this->db);
662 662
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
663
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
663
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
664 664
 		}
665 665
 		return $all;
666 666
 	}
667 667
 
668
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
668
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
669 669
 		global $globalStatsFilters;
670 670
 		if ($filter_name == '') $filter_name = $this->filter_name;
671
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
671
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
672 672
 			$Spotter = new Spotter($this->db);
673
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
673
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
674 674
 			if ($year == '' && $month == '') {
675 675
 				$alliance_airlines = array();
676 676
 				foreach ($airlines as $airline) {
677
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
677
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
678 678
 				}
679
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
679
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
681 681
 				try {
682 682
 					$sth = $this->db->prepare($query);
683 683
 					$sth->execute(array(':filter_name' => $filter_name));
684
-				} catch(PDOException $e) {
684
+				} catch (PDOException $e) {
685 685
 					echo "error : ".$e->getMessage();
686 686
 				}
687 687
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -692,45 +692,45 @@  discard block
 block discarded – undo
692 692
 				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";
693 693
 				try {
694 694
 					$sth = $this->db->prepare($query);
695
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
696
-				} catch(PDOException $e) {
695
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
696
+				} catch (PDOException $e) {
697 697
 					echo "error : ".$e->getMessage();
698 698
 				}
699 699
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
700 700
 			} else $all = array();
701 701
 		}
702 702
 		if (empty($all)) {
703
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
704
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
703
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
704
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
705 705
 			} else {
706
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
706
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
707 707
 			}
708 708
 			if ($filter_name != '') {
709
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
709
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
710 710
 			}
711 711
 			$Spotter = new Spotter($this->db);
712 712
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
713
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
713
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
714 714
 		}
715 715
 		return $all;
716 716
 	}
717
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
717
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
718 718
 		global $globalStatsFilters;
719 719
 		if ($filter_name == '') $filter_name = $this->filter_name;
720
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
720
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
721 721
 			$Spotter = new Spotter($this->db);
722
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
722
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
723 723
 			if ($year == '' && $month == '') {
724 724
 				$alliance_airlines = array();
725 725
 				foreach ($airlines as $airline) {
726
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
726
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
727 727
 				}
728
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
728
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
730 730
 				try {
731 731
 					$sth = $this->db->prepare($query);
732 732
 					$sth->execute(array(':filter_name' => $filter_name));
733
-				} catch(PDOException $e) {
733
+				} catch (PDOException $e) {
734 734
 					echo "error : ".$e->getMessage();
735 735
 				}
736 736
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -741,27 +741,27 @@  discard block
 block discarded – undo
741 741
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
742 742
 				try {
743 743
 					$sth = $this->db->prepare($query);
744
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
745
-				} catch(PDOException $e) {
744
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
745
+				} catch (PDOException $e) {
746 746
 					echo "error : ".$e->getMessage();
747 747
 				}
748 748
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
749 749
 			} else $all = array();
750 750
 		}
751 751
 		if (empty($all)) {
752
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
753
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
752
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
753
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
754 754
 			} else {
755
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
755
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
756 756
 			}
757 757
 			if ($filter_name != '') {
758
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
758
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
759 759
 			}
760 760
 			$Spotter = new Spotter($this->db);
761 761
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
762 762
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
763
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
764
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
763
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
764
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
765 765
 			$all = array();
766 766
 			foreach ($pall as $value) {
767 767
 				$icao = $value['airport_departure_icao'];
@@ -777,27 +777,27 @@  discard block
 block discarded – undo
777 777
 			foreach ($all as $key => $row) {
778 778
 				$count[$key] = $row['airport_departure_icao_count'];
779 779
 			}
780
-			array_multisort($count,SORT_DESC,$all);
780
+			array_multisort($count, SORT_DESC, $all);
781 781
 		}
782 782
 		return $all;
783 783
 	}
784
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
784
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
785 785
 		global $globalStatsFilters;
786 786
 		if ($filter_name == '') $filter_name = $this->filter_name;
787
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
787
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
788 788
 			$Spotter = new Spotter($this->db);
789
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
789
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
790 790
 			if ($year == '' && $month == '') {
791 791
 				$alliance_airlines = array();
792 792
 				foreach ($airlines as $airline) {
793
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
793
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
794 794
 				}
795
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
795
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
797 797
 				try {
798 798
 					$sth = $this->db->prepare($query);
799 799
 					$sth->execute(array(':filter_name' => $filter_name));
800
-				} catch(PDOException $e) {
800
+				} catch (PDOException $e) {
801 801
 					echo "error : ".$e->getMessage();
802 802
 				}
803 803
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -808,27 +808,27 @@  discard block
 block discarded – undo
808 808
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
809 809
 				try {
810 810
 					$sth = $this->db->prepare($query);
811
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
812
-				} catch(PDOException $e) {
811
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
812
+				} catch (PDOException $e) {
813 813
 					echo "error : ".$e->getMessage();
814 814
 				}
815 815
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
816 816
 			} else $all = array();
817 817
 		}
818 818
 		if (empty($all)) {
819
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
820
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
819
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
820
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
821 821
 			} else {
822
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
822
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
823 823
 			}
824 824
 			if ($filter_name != '') {
825
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
825
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
826 826
 			}
827 827
 			$Spotter = new Spotter($this->db);
828 828
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
829 829
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
830
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
831
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
830
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
831
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
832 832
 			$all = array();
833 833
 			foreach ($pall as $value) {
834 834
 				$icao = $value['airport_arrival_icao'];
@@ -844,26 +844,26 @@  discard block
 block discarded – undo
844 844
 			foreach ($all as $key => $row) {
845 845
 				$count[$key] = $row['airport_arrival_icao_count'];
846 846
 			}
847
-			array_multisort($count,SORT_DESC,$all);
847
+			array_multisort($count, SORT_DESC, $all);
848 848
 		}
849 849
 		return $all;
850 850
 	}
851
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
851
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
852 852
 		global $globalDBdriver, $globalStatsFilters;
853 853
 		if ($filter_name == '') $filter_name = $this->filter_name;
854
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
854
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
855 855
 			$Spotter = new Spotter($this->db);
856
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
856
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
857 857
 			$alliance_airlines = array();
858 858
 			foreach ($airlines as $airline) {
859
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
859
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
860 860
 			}
861 861
 			if ($globalDBdriver == 'mysql') {
862
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
864 864
 			} else {
865
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
867 867
 			}
868 868
 			$query_data = array(':filter_name' => $filter_name);
869 869
 		} else {
@@ -874,23 +874,23 @@  discard block
 block discarded – undo
874 874
 				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";
875 875
 				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";
876 876
 			}
877
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
877
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
878 878
 		}
879 879
 		try {
880 880
 			$sth = $this->db->prepare($query);
881 881
 			$sth->execute($query_data);
882
-		} catch(PDOException $e) {
882
+		} catch (PDOException $e) {
883 883
 			echo "error : ".$e->getMessage();
884 884
 		}
885 885
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
886 886
 		if (empty($all)) {
887
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
888
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
887
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
888
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
889 889
 			} else {
890 890
 				$filters = array('airlines' => array($stats_airline));
891 891
 			}
892 892
 			if ($filter_name != '') {
893
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
893
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
894 894
 			}
895 895
 			$Spotter = new Spotter($this->db);
896 896
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 		return $all;
899 899
 	}
900 900
 
901
-	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
901
+	public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') {
902 902
 		global $globalDBdriver, $globalStatsFilters;
903 903
 		if ($filter_name == '') $filter_name = $this->filter_name;
904 904
 		if ($globalDBdriver == 'mysql') {
@@ -912,14 +912,14 @@  discard block
 block discarded – undo
912 912
 		try {
913 913
 			$sth = $this->db->prepare($query);
914 914
 			$sth->execute($query_data);
915
-		} catch(PDOException $e) {
915
+		} catch (PDOException $e) {
916 916
 			echo "error : ".$e->getMessage();
917 917
 		}
918 918
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
919 919
 		if (empty($all)) {
920 920
 			$filters = array();
921 921
 			if ($filter_name != '') {
922
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
922
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
923 923
 			}
924 924
 			$Marine = new Marine($this->db);
925 925
 			$all = $Marine->countAllMonthsLastYear($filters);
@@ -927,37 +927,37 @@  discard block
 block discarded – undo
927 927
 		return $all;
928 928
 	}
929 929
 	
930
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
930
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
931 931
 		global $globalStatsFilters;
932 932
 		if ($filter_name == '') $filter_name = $this->filter_name;
933
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
933
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
934 934
 			$Spotter = new Spotter($this->db);
935
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
935
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
936 936
 			$alliance_airlines = array();
937 937
 			foreach ($airlines as $airline) {
938
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
938
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
939 939
 			}
940
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
940
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
941 941
 			$query_data = array(':filter_name' => $filter_name);
942 942
 		} else {
943 943
 			$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";
944
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
944
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
945 945
 		}
946 946
 		try {
947 947
 			$sth = $this->db->prepare($query);
948 948
 			$sth->execute($query_data);
949
-		} catch(PDOException $e) {
949
+		} catch (PDOException $e) {
950 950
 			echo "error : ".$e->getMessage();
951 951
 		}
952 952
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
953 953
 		if (empty($all)) {
954
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
955
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
954
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
955
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
956 956
 			} else {
957 957
 				$filters = array('airlines' => array($stats_airline));
958 958
 			}
959 959
 			if ($filter_name != '') {
960
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
960
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
961 961
 			}
962 962
 			$Spotter = new Spotter($this->db);
963 963
 			$all = $Spotter->countAllDatesLastMonth($filters);
@@ -972,34 +972,34 @@  discard block
 block discarded – undo
972 972
 		try {
973 973
 			$sth = $this->db->prepare($query);
974 974
 			$sth->execute($query_data);
975
-		} catch(PDOException $e) {
975
+		} catch (PDOException $e) {
976 976
 			echo "error : ".$e->getMessage();
977 977
 		}
978 978
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
979 979
 		if (empty($all)) {
980 980
 			$filters = array();
981 981
 			if ($filter_name != '') {
982
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
982
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
983 983
 			}
984 984
 			$Marine = new Marine($this->db);
985 985
 			$all = $Marine->countAllDatesLastMonth($filters);
986 986
 		}
987 987
 		return $all;
988 988
 	}
989
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
989
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
990 990
 		global $globalDBdriver, $globalStatsFilters;
991 991
 		if ($filter_name == '') $filter_name = $this->filter_name;
992
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
992
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
993 993
 			$Spotter = new Spotter($this->db);
994
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
994
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
995 995
 			$alliance_airlines = array();
996 996
 			foreach ($airlines as $airline) {
997
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
997
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
998 998
 			}
999 999
 			if ($globalDBdriver == 'mysql') {
1000
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1000
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1001 1001
 			} else {
1002
-				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1002
+				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1003 1003
 			}
1004 1004
 			$query_data = array(':filter_name' => $filter_name);
1005 1005
 		} else {
@@ -1008,23 +1008,23 @@  discard block
 block discarded – undo
1008 1008
 			} else {
1009 1009
 				$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";
1010 1010
 			}
1011
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1011
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1012 1012
 		}
1013 1013
 		try {
1014 1014
 			$sth = $this->db->prepare($query);
1015 1015
 			$sth->execute($query_data);
1016
-		} catch(PDOException $e) {
1016
+		} catch (PDOException $e) {
1017 1017
 			echo "error : ".$e->getMessage();
1018 1018
 		}
1019 1019
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1020 1020
 		if (empty($all)) {
1021
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1022
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1021
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1022
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1023 1023
 			} else {
1024 1024
 				$filters = array('airlines' => array($stats_airline));
1025 1025
 			}
1026 1026
 			if ($filter_name != '') {
1027
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1027
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1028 1028
 			}
1029 1029
 			$Spotter = new Spotter($this->db);
1030 1030
 			$all = $Spotter->countAllDatesLast7Days($filters);
@@ -1043,51 +1043,51 @@  discard block
 block discarded – undo
1043 1043
 		try {
1044 1044
 			$sth = $this->db->prepare($query);
1045 1045
 			$sth->execute($query_data);
1046
-		} catch(PDOException $e) {
1046
+		} catch (PDOException $e) {
1047 1047
 			echo "error : ".$e->getMessage();
1048 1048
 		}
1049 1049
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1050 1050
 		if (empty($all)) {
1051 1051
 			$filters = array();
1052 1052
 			if ($filter_name != '') {
1053
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1053
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1054 1054
 			}
1055 1055
 			$Marine = new Marine($this->db);
1056 1056
 			$all = $Marine->countAllDatesLast7Days($filters);
1057 1057
 		}
1058 1058
 		return $all;
1059 1059
 	}
1060
-	public function countAllDates($stats_airline = '',$filter_name = '') {
1060
+	public function countAllDates($stats_airline = '', $filter_name = '') {
1061 1061
 		global $globalStatsFilters;
1062 1062
 		if ($filter_name == '') $filter_name = $this->filter_name;
1063
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1063
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1064 1064
 			$Spotter = new Spotter($this->db);
1065
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1065
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1066 1066
 			$alliance_airlines = array();
1067 1067
 			foreach ($airlines as $airline) {
1068
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1068
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1069 1069
 			}
1070
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1070
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1071 1071
 			$query_data = array(':filter_name' => $filter_name);
1072 1072
 		} else {
1073 1073
 			$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 ORDER BY date_count DESC";
1074
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1074
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1075 1075
 		}
1076 1076
 		try {
1077 1077
 			$sth = $this->db->prepare($query);
1078 1078
 			$sth->execute($query_data);
1079
-		} catch(PDOException $e) {
1079
+		} catch (PDOException $e) {
1080 1080
 			echo "error : ".$e->getMessage();
1081 1081
 		}
1082 1082
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1083 1083
 		if (empty($all)) {
1084
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1085
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1084
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1085
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1086 1086
 			} else {
1087 1087
 				$filters = array('airlines' => array($stats_airline));
1088 1088
 			}
1089 1089
 			if ($filter_name != '') {
1090
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1090
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1091 1091
 			}
1092 1092
 			$Spotter = new Spotter($this->db);
1093 1093
 			$all = $Spotter->countAllDates($filters);
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 		try {
1103 1103
 			$sth = $this->db->prepare($query);
1104 1104
 			$sth->execute($query_data);
1105
-		} catch(PDOException $e) {
1105
+		} catch (PDOException $e) {
1106 1106
 			echo "error : ".$e->getMessage();
1107 1107
 		}
1108 1108
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		try {
1125 1125
 			$sth = $this->db->prepare($query);
1126 1126
 			$sth->execute($query_data);
1127
-		} catch(PDOException $e) {
1127
+		} catch (PDOException $e) {
1128 1128
 			echo "error : ".$e->getMessage();
1129 1129
 		}
1130 1130
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1146,34 +1146,34 @@  discard block
 block discarded – undo
1146 1146
 		try {
1147 1147
 			$sth = $this->db->prepare($query);
1148 1148
 			$sth->execute($query_data);
1149
-		} catch(PDOException $e) {
1149
+		} catch (PDOException $e) {
1150 1150
 			echo "error : ".$e->getMessage();
1151 1151
 		}
1152 1152
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1153 1153
 		if (empty($all)) {
1154 1154
 			$filters = array();
1155 1155
 			if ($filter_name != '') {
1156
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1156
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1157 1157
 			}
1158 1158
 			$Spotter = new Spotter($this->db);
1159 1159
 			$all = $Spotter->countAllDatesByAirlines($filters);
1160 1160
 		}
1161 1161
 		return $all;
1162 1162
 	}
1163
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1163
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1164 1164
 		global $globalStatsFilters, $globalDBdriver;
1165 1165
 		if ($filter_name == '') $filter_name = $this->filter_name;
1166
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1166
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1167 1167
 			$Spotter = new Spotter($this->db);
1168
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1168
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1169 1169
 			$alliance_airlines = array();
1170 1170
 			foreach ($airlines as $airline) {
1171
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1171
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1172 1172
 			}
1173 1173
 			if ($globalDBdriver == 'mysql') {
1174
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1174
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1175 1175
 			} else {
1176
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1176
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1177 1177
 			}
1178 1178
 			$query_data = array(':filter_name' => $filter_name);
1179 1179
 		} else {
@@ -1187,18 +1187,18 @@  discard block
 block discarded – undo
1187 1187
 		try {
1188 1188
 			$sth = $this->db->prepare($query);
1189 1189
 			$sth->execute($query_data);
1190
-		} catch(PDOException $e) {
1190
+		} catch (PDOException $e) {
1191 1191
 			echo "error : ".$e->getMessage();
1192 1192
 		}
1193 1193
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1194 1194
 		if (empty($all)) {
1195
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1196
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1195
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1196
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1197 1197
 			} else {
1198 1198
 				$filters = array('airlines' => array($stats_airline));
1199 1199
 			}
1200 1200
 			if ($filter_name != '') {
1201
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1201
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1202 1202
 			}
1203 1203
 			$Spotter = new Spotter($this->db);
1204 1204
 			$all = $Spotter->countAllMonths($filters);
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 		try {
1216 1216
 			$sth = $this->db->prepare($query);
1217 1217
 			$sth->execute();
1218
-		} catch(PDOException $e) {
1218
+		} catch (PDOException $e) {
1219 1219
 			echo "error : ".$e->getMessage();
1220 1220
 		}
1221 1221
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		try {
1236 1236
 			$sth = $this->db->prepare($query);
1237 1237
 			$sth->execute();
1238
-		} catch(PDOException $e) {
1238
+		} catch (PDOException $e) {
1239 1239
 			echo "error : ".$e->getMessage();
1240 1240
 		}
1241 1241
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1252,32 +1252,32 @@  discard block
 block discarded – undo
1252 1252
 		try {
1253 1253
 			$sth = $this->db->prepare($query);
1254 1254
 			$sth->execute(array(':filter_name' => $filter_name));
1255
-		} catch(PDOException $e) {
1255
+		} catch (PDOException $e) {
1256 1256
 			echo "error : ".$e->getMessage();
1257 1257
 		}
1258 1258
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1259 1259
 		if (empty($all)) {
1260 1260
 			$filters = array();
1261 1261
 			if ($filter_name != '') {
1262
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1262
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1263 1263
 			}
1264 1264
 			$Spotter = new Spotter($this->db);
1265 1265
 			$all = $Spotter->countAllMilitaryMonths($filters);
1266 1266
 		}
1267 1267
 		return $all;
1268 1268
 	}
1269
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1269
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1270 1270
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1271 1271
 		if ($filter_name == '') $filter_name = $this->filter_name;
1272
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1272
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1273 1273
 			$Spotter = new Spotter($this->db);
1274
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1274
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1275 1275
 			$alliance_airlines = array();
1276 1276
 			foreach ($airlines as $airline) {
1277
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1277
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1278 1278
 			}
1279
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1280
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1279
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1280
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1281 1281
 			$query_data = array(':filter_name' => $filter_name);
1282 1282
 		} else {
1283 1283
 			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";
@@ -1295,25 +1295,25 @@  discard block
 block discarded – undo
1295 1295
 		try {
1296 1296
 			$sth = $this->db->prepare($query);
1297 1297
 			$sth->execute($query_data);
1298
-		} catch(PDOException $e) {
1298
+		} catch (PDOException $e) {
1299 1299
 			echo "error : ".$e->getMessage();
1300 1300
 		}
1301 1301
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1302 1302
 		if (empty($all)) {
1303
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1304
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1303
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1304
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1305 1305
 			} else {
1306 1306
 				$filters = array('airlines' => array($stats_airline));
1307 1307
 			}
1308 1308
 			if ($filter_name != '') {
1309
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1309
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1310 1310
 			}
1311 1311
 			$Spotter = new Spotter($this->db);
1312
-			$all = $Spotter->countAllHours($orderby,$filters);
1312
+			$all = $Spotter->countAllHours($orderby, $filters);
1313 1313
 		}
1314 1314
 		return $all;
1315 1315
 	}
1316
-	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1316
+	public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') {
1317 1317
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1318 1318
 		if ($filter_name == '') $filter_name = $this->filter_name;
1319 1319
 		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1330,33 +1330,33 @@  discard block
 block discarded – undo
1330 1330
 		try {
1331 1331
 			$sth = $this->db->prepare($query);
1332 1332
 			$sth->execute($query_data);
1333
-		} catch(PDOException $e) {
1333
+		} catch (PDOException $e) {
1334 1334
 			echo "error : ".$e->getMessage();
1335 1335
 		}
1336 1336
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1337 1337
 		if (empty($all)) {
1338 1338
 			$filters = array();
1339 1339
 			if ($filter_name != '') {
1340
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1340
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1341 1341
 			}
1342 1342
 			$Marine = new Marine($this->db);
1343
-			$all = $Marine->countAllHours($orderby,$filters);
1343
+			$all = $Marine->countAllHours($orderby, $filters);
1344 1344
 		}
1345 1345
 		return $all;
1346 1346
 	}
1347
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1347
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1348 1348
 		global $globalStatsFilters;
1349 1349
 		if ($filter_name == '') $filter_name = $this->filter_name;
1350 1350
 		if ($year == '') $year = date('Y');
1351
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1351
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1352 1352
 		if (empty($all)) {
1353
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1354
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1353
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1354
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1355 1355
 			} else {
1356
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1356
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1357 1357
 			}
1358 1358
 			if ($filter_name != '') {
1359
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1359
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1360 1360
 			}
1361 1361
 			$Spotter = new Spotter($this->db);
1362 1362
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1364,15 +1364,15 @@  discard block
 block discarded – undo
1364 1364
 		}
1365 1365
 		return $all;
1366 1366
 	}
1367
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1367
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1368 1368
 		global $globalStatsFilters;
1369 1369
 		if ($filter_name == '') $filter_name = $this->filter_name;
1370 1370
 		if ($year == '') $year = date('Y');
1371
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1371
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1372 1372
 		if (empty($all)) {
1373
-			$filters = array('year' => $year,'month' => $month);
1373
+			$filters = array('year' => $year, 'month' => $month);
1374 1374
 			if ($filter_name != '') {
1375
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1375
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1376 1376
 			}
1377 1377
 			$Marine = new Marine($this->db);
1378 1378
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1380,15 +1380,15 @@  discard block
 block discarded – undo
1380 1380
 		}
1381 1381
 		return $all;
1382 1382
 	}
1383
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1383
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1384 1384
 		global $globalStatsFilters;
1385 1385
 		if ($filter_name == '') $filter_name = $this->filter_name;
1386 1386
 		if ($year == '') $year = date('Y');
1387
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1387
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1388 1388
 		if (empty($all)) {
1389
-			$filters = array('year' => $year,'month' => $month);
1389
+			$filters = array('year' => $year, 'month' => $month);
1390 1390
 			if ($filter_name != '') {
1391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1392 1392
 			}
1393 1393
 			$Tracker = new Tracker($this->db);
1394 1394
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1396,16 +1396,16 @@  discard block
 block discarded – undo
1396 1396
 		}
1397 1397
 		return $all;
1398 1398
 	}
1399
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1399
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1400 1400
 		global $globalStatsFilters;
1401 1401
 		if ($filter_name == '') $filter_name = $this->filter_name;
1402 1402
 		if ($year == '') $year = date('Y');
1403
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1403
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1404 1404
 		if (empty($all)) {
1405 1405
 			$filters = array();
1406
-			$filters = array('year' => $year,'month' => $month);
1406
+			$filters = array('year' => $year, 'month' => $month);
1407 1407
 			if ($filter_name != '') {
1408
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1408
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1409 1409
 			}
1410 1410
 			$Spotter = new Spotter($this->db);
1411 1411
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1413,19 +1413,19 @@  discard block
 block discarded – undo
1413 1413
 		}
1414 1414
 		return $all;
1415 1415
 	}
1416
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1416
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1417 1417
 		global $globalStatsFilters;
1418 1418
 		if ($filter_name == '') $filter_name = $this->filter_name;
1419 1419
 		if ($year == '') $year = date('Y');
1420
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1420
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1421 1421
 		if (empty($all)) {
1422
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1423
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1422
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1423
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1424 1424
 			} else {
1425
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1425
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1426 1426
 			}
1427 1427
 			if ($filter_name != '') {
1428
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1428
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1429 1429
 			}
1430 1430
 			$Spotter = new Spotter($this->db);
1431 1431
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1433,48 +1433,48 @@  discard block
 block discarded – undo
1433 1433
 		}
1434 1434
 		return $all;
1435 1435
 	}
1436
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1436
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1437 1437
 		global $globalStatsFilters;
1438 1438
 		if ($filter_name == '') $filter_name = $this->filter_name;
1439
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1439
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1440 1440
 			$Spotter = new Spotter($this->db);
1441
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1441
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1442 1442
 			if ($year == '' && $month == '') {
1443 1443
 				$alliance_airlines = array();
1444 1444
 				foreach ($airlines as $airline) {
1445
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1445
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1446 1446
 				}
1447
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1447
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1448 1448
 				try {
1449 1449
 					$sth = $this->db->prepare($query);
1450 1450
 					$sth->execute(array(':filter_name' => $filter_name));
1451
-				} catch(PDOException $e) {
1451
+				} catch (PDOException $e) {
1452 1452
 					echo "error : ".$e->getMessage();
1453 1453
 				}
1454 1454
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1455 1455
 				$all = $result[0]['nb'];
1456
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1456
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1457 1457
 		} else {
1458 1458
 			if ($year == '' && $month == '') {
1459 1459
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1460 1460
 				try {
1461 1461
 					$sth = $this->db->prepare($query);
1462
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1463
-				} catch(PDOException $e) {
1462
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1463
+				} catch (PDOException $e) {
1464 1464
 					echo "error : ".$e->getMessage();
1465 1465
 				}
1466 1466
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1467 1467
 				$all = $result[0]['nb'];
1468
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1468
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1469 1469
 		}
1470 1470
 		if (empty($all)) {
1471
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1472
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1471
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1472
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1473 1473
 			} else {
1474
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1474
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1475 1475
 			}
1476 1476
 			if ($filter_name != '') {
1477
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1477
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1478 1478
 			}
1479 1479
 			$Spotter = new Spotter($this->db);
1480 1480
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 		}
1483 1483
 		return $all;
1484 1484
 	}
1485
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1485
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1486 1486
 		global $globalStatsFilters;
1487 1487
 		if ($filter_name == '') $filter_name = $this->filter_name;
1488 1488
 		if ($year == '' && $month == '') {
@@ -1490,17 +1490,17 @@  discard block
 block discarded – undo
1490 1490
 			try {
1491 1491
 				$sth = $this->db->prepare($query);
1492 1492
 				$sth->execute(array(':filter_name' => $filter_name));
1493
-			} catch(PDOException $e) {
1493
+			} catch (PDOException $e) {
1494 1494
 				echo "error : ".$e->getMessage();
1495 1495
 			}
1496 1496
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1497 1497
 			$all = $result[0]['nb_airline'];
1498
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1498
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1499 1499
 		if (empty($all)) {
1500 1500
 			$filters = array();
1501
-			$filters = array('year' => $year,'month' => $month);
1501
+			$filters = array('year' => $year, 'month' => $month);
1502 1502
 			if ($filter_name != '') {
1503
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1503
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1504 1504
 			}
1505 1505
 			$Spotter = new Spotter($this->db);
1506 1506
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 		}
1509 1509
 		return $all;
1510 1510
 	}
1511
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1511
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1512 1512
 		global $globalStatsFilters;
1513 1513
 		if ($filter_name == '') $filter_name = $this->filter_name;
1514 1514
 		$all = array();
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
 			try {
1518 1518
 				$sth = $this->db->prepare($query);
1519 1519
 				$sth->execute(array(':filter_name' => $filter_name));
1520
-			} catch(PDOException $e) {
1520
+			} catch (PDOException $e) {
1521 1521
 				echo "error : ".$e->getMessage();
1522 1522
 			}
1523 1523
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1525,9 +1525,9 @@  discard block
 block discarded – undo
1525 1525
 		}
1526 1526
 		if (empty($all)) {
1527 1527
 			$filters = array();
1528
-			$filters = array('year' => $year,'month' => $month);
1528
+			$filters = array('year' => $year, 'month' => $month);
1529 1529
 			if ($filter_name != '') {
1530
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1530
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1531 1531
 			}
1532 1532
 			$Marine = new Marine($this->db);
1533 1533
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1535,29 +1535,29 @@  discard block
 block discarded – undo
1535 1535
 		}
1536 1536
 		return $all;
1537 1537
 	}
1538
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1538
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1539 1539
 		global $globalStatsFilters;
1540 1540
 		if ($filter_name == '') $filter_name = $this->filter_name;
1541
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1541
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1542 1542
 			$Spotter = new Spotter($this->db);
1543
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1543
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1544 1544
 			if ($year == '' && $month == '') {
1545 1545
 				$alliance_airlines = array();
1546 1546
 				foreach ($airlines as $airline) {
1547
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1547
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1548 1548
 				}
1549
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1549
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1550 1550
 				$query_values = array(':filter_name' => $filter_name);
1551 1551
 				try {
1552 1552
 					$sth = $this->db->prepare($query);
1553 1553
 					$sth->execute($query_values);
1554
-				} catch(PDOException $e) {
1554
+				} catch (PDOException $e) {
1555 1555
 					echo "error : ".$e->getMessage();
1556 1556
 				}
1557 1557
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1558 1558
 				$all = $result[0]['nb'];
1559 1559
 			} else {
1560
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1560
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1561 1561
 			}
1562 1562
 		} else {
1563 1563
 			if ($year == '' && $month == '') {
@@ -1566,23 +1566,23 @@  discard block
 block discarded – undo
1566 1566
 				try {
1567 1567
 					$sth = $this->db->prepare($query);
1568 1568
 					$sth->execute($query_values);
1569
-				} catch(PDOException $e) {
1569
+				} catch (PDOException $e) {
1570 1570
 					echo "error : ".$e->getMessage();
1571 1571
 				}
1572 1572
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1573 1573
 				$all = $result[0]['nb'];
1574 1574
 			} else {
1575
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1575
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1576 1576
 			}
1577 1577
 		}
1578 1578
 		if (empty($all)) {
1579
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1580
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1579
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1580
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1581 1581
 			} else {
1582
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1582
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1583 1583
 			}
1584 1584
 			if ($filter_name != '') {
1585
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1585
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1586 1586
 			}
1587 1587
 			$Spotter = new Spotter($this->db);
1588 1588
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 		}
1591 1591
 		return $all;
1592 1592
 	}
1593
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1593
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1594 1594
 		global $globalStatsFilters;
1595 1595
 		if ($filter_name == '') $filter_name = $this->filter_name;
1596 1596
 		//if ($year == '') $year = date('Y');
@@ -1600,18 +1600,18 @@  discard block
 block discarded – undo
1600 1600
 			try {
1601 1601
 				$sth = $this->db->prepare($query);
1602 1602
 				$sth->execute($query_values);
1603
-			} catch(PDOException $e) {
1603
+			} catch (PDOException $e) {
1604 1604
 				echo "error : ".$e->getMessage();
1605 1605
 			}
1606 1606
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1607 1607
 			$all = $result[0]['nb'];
1608 1608
 		} else {
1609
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1609
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1610 1610
 		}
1611 1611
 		if (empty($all)) {
1612
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1612
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1613 1613
 			if ($filter_name != '') {
1614
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1614
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1615 1615
 			}
1616 1616
 			$Spotter = new Spotter($this->db);
1617 1617
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1620,104 +1620,104 @@  discard block
 block discarded – undo
1620 1620
 		return $all;
1621 1621
 	}
1622 1622
 
1623
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1623
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1624 1624
 		if ($filter_name == '') $filter_name = $this->filter_name;
1625
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1625
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1626 1626
 			$Spotter = new Spotter($this->db);
1627
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1627
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1628 1628
 			$alliance_airlines = array();
1629 1629
 			foreach ($airlines as $airline) {
1630
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1630
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1631 1631
 			}
1632
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1633
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1632
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1633
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1634 1634
 		} else {
1635 1635
 			$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";
1636
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1636
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1637 1637
 		}
1638 1638
 		try {
1639 1639
 			$sth = $this->db->prepare($query);
1640 1640
 			$sth->execute($query_values);
1641
-		} catch(PDOException $e) {
1641
+		} catch (PDOException $e) {
1642 1642
 			echo "error : ".$e->getMessage();
1643 1643
 		}
1644 1644
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1645 1645
 		return $all;
1646 1646
 	}
1647
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1647
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1648 1648
 		if ($filter_name == '') $filter_name = $this->filter_name;
1649 1649
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1650
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1650
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1651 1651
 		try {
1652 1652
 			$sth = $this->db->prepare($query);
1653 1653
 			$sth->execute($query_values);
1654
-		} catch(PDOException $e) {
1654
+		} catch (PDOException $e) {
1655 1655
 			echo "error : ".$e->getMessage();
1656 1656
 		}
1657 1657
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1658 1658
 		return $all;
1659 1659
 	}
1660
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1660
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1661 1661
 		if ($filter_name == '') $filter_name = $this->filter_name;
1662 1662
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1663
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1663
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1664 1664
 		try {
1665 1665
 			$sth = $this->db->prepare($query);
1666 1666
 			$sth->execute($query_values);
1667
-		} catch(PDOException $e) {
1667
+		} catch (PDOException $e) {
1668 1668
 			echo "error : ".$e->getMessage();
1669 1669
 		}
1670 1670
 	}
1671
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1671
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1672 1672
 		if ($filter_name == '') $filter_name = $this->filter_name;
1673 1673
 		global $globalArchiveMonths, $globalDBdriver;
1674
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1674
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1675 1675
 			$Spotter = new Spotter($this->db);
1676
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1676
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1677 1677
 			$alliance_airlines = array();
1678 1678
 			foreach ($airlines as $airline) {
1679
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1679
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1680 1680
 			}
1681 1681
 			if ($globalDBdriver == 'mysql') {
1682 1682
 				if ($month == '') {
1683
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1683
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1684 1684
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1685 1685
 				} else {
1686
-					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1687
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1686
+					$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1687
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1688 1688
 				}
1689 1689
 			} else {
1690 1690
 				if ($month == '') {
1691
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1691
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1692 1692
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1693 1693
 				} else {
1694
-					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1695
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1694
+					$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1695
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1696 1696
 				}
1697 1697
 			}
1698 1698
 		} else {
1699 1699
 			if ($globalDBdriver == 'mysql') {
1700 1700
 				if ($month == '') {
1701 1701
 					$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";
1702
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1702
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1703 1703
 				} else {
1704 1704
 					$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";
1705
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1705
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1706 1706
 				}
1707 1707
 			} else {
1708 1708
 				if ($month == '') {
1709 1709
 					$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";
1710
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1710
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1711 1711
 				} else {
1712 1712
 					$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";
1713
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1713
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1714 1714
 				}
1715 1715
 			}
1716 1716
 		}
1717 1717
 		try {
1718 1718
 			$sth = $this->db->prepare($query);
1719 1719
 			$sth->execute($query_values);
1720
-		} catch(PDOException $e) {
1720
+		} catch (PDOException $e) {
1721 1721
 			echo "error : ".$e->getMessage();
1722 1722
 		}
1723 1723
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1726,17 +1726,17 @@  discard block
 block discarded – undo
1726 1726
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1727 1727
 		global $globalArchiveMonths, $globalDBdriver;
1728 1728
 		if ($filter_name == '') $filter_name = $this->filter_name;
1729
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1729
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1730 1730
 			$Spotter = new Spotter($this->db);
1731
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1731
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1732 1732
 			$alliance_airlines = array();
1733 1733
 			foreach ($airlines as $airline) {
1734
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1734
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1735 1735
 			}
1736 1736
 			if ($globalDBdriver == 'mysql') {
1737
-				$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1737
+				$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1738 1738
 			} else {
1739
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1739
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1740 1740
 			}
1741 1741
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1742 1742
 		} else {
@@ -1750,7 +1750,7 @@  discard block
 block discarded – undo
1750 1750
 		try {
1751 1751
 			$sth = $this->db->prepare($query);
1752 1752
 			$sth->execute($query_values);
1753
-		} catch(PDOException $e) {
1753
+		} catch (PDOException $e) {
1754 1754
 			echo "error : ".$e->getMessage();
1755 1755
 		}
1756 1756
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1759,17 +1759,17 @@  discard block
 block discarded – undo
1759 1759
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1760 1760
 		global $globalArchiveMonths, $globalDBdriver;
1761 1761
 		if ($filter_name == '') $filter_name = $this->filter_name;
1762
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1762
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1763 1763
 			$Spotter = new Spotter($this->db);
1764
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1764
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1765 1765
 			$alliance_airlines = array();
1766 1766
 			foreach ($airlines as $airline) {
1767
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1767
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1768 1768
 			}
1769 1769
 			if ($globalDBdriver == 'mysql') {
1770
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1770
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1771 1771
 			} else {
1772
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1772
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1773 1773
 			}
1774 1774
 		} else {
1775 1775
 			if ($globalDBdriver == 'mysql') {
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
 		try {
1782 1782
 			$sth = $this->db->prepare($query);
1783 1783
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1784
-		} catch(PDOException $e) {
1784
+		} catch (PDOException $e) {
1785 1785
 			echo "error : ".$e->getMessage();
1786 1786
 		}
1787 1787
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
 		try {
1799 1799
 			$sth = $this->db->prepare($query);
1800 1800
 			$sth->execute(array(':filter_name' => $filter_name));
1801
-		} catch(PDOException $e) {
1801
+		} catch (PDOException $e) {
1802 1802
 			echo "error : ".$e->getMessage();
1803 1803
 		}
1804 1804
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1815,20 +1815,20 @@  discard block
 block discarded – undo
1815 1815
 		try {
1816 1816
 			$sth = $this->db->prepare($query);
1817 1817
 			$sth->execute(array(':filter_name' => $filter_name));
1818
-		} catch(PDOException $e) {
1818
+		} catch (PDOException $e) {
1819 1819
 			echo "error : ".$e->getMessage();
1820 1820
 		}
1821 1821
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1822 1822
 		return $all[0]['total'];
1823 1823
 	}
1824
-	public function getStatsOwner($owner_name,$filter_name = '') {
1824
+	public function getStatsOwner($owner_name, $filter_name = '') {
1825 1825
 		global $globalArchiveMonths, $globalDBdriver;
1826 1826
 		if ($filter_name == '') $filter_name = $this->filter_name;
1827 1827
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1828 1828
 		try {
1829 1829
 			$sth = $this->db->prepare($query);
1830
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1831
-		} catch(PDOException $e) {
1830
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1831
+		} catch (PDOException $e) {
1832 1832
 			echo "error : ".$e->getMessage();
1833 1833
 		}
1834 1834
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1846,20 +1846,20 @@  discard block
 block discarded – undo
1846 1846
 		try {
1847 1847
 			$sth = $this->db->prepare($query);
1848 1848
 			$sth->execute(array(':filter_name' => $filter_name));
1849
-		} catch(PDOException $e) {
1849
+		} catch (PDOException $e) {
1850 1850
 			echo "error : ".$e->getMessage();
1851 1851
 		}
1852 1852
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1853 1853
 		return $all[0]['total'];
1854 1854
 	}
1855
-	public function getStatsPilot($pilot,$filter_name = '') {
1855
+	public function getStatsPilot($pilot, $filter_name = '') {
1856 1856
 		global $globalArchiveMonths, $globalDBdriver;
1857 1857
 		if ($filter_name == '') $filter_name = $this->filter_name;
1858 1858
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1859 1859
 		try {
1860 1860
 			$sth = $this->db->prepare($query);
1861
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1862
-		} catch(PDOException $e) {
1861
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1862
+		} catch (PDOException $e) {
1863 1863
 			echo "error : ".$e->getMessage();
1864 1864
 		}
1865 1865
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
 		else return 0;
1868 1868
 	}
1869 1869
 
1870
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1870
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1871 1871
 		global $globalDBdriver;
1872 1872
 		if ($filter_name == '') $filter_name = $this->filter_name;
1873 1873
 		if ($globalDBdriver == 'mysql') {
@@ -1875,15 +1875,15 @@  discard block
 block discarded – undo
1875 1875
 		} else {
1876 1876
 			$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);"; 
1877 1877
 		}
1878
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1878
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1879 1879
 		try {
1880 1880
 			$sth = $this->db->prepare($query);
1881 1881
 			$sth->execute($query_values);
1882
-		} catch(PDOException $e) {
1882
+		} catch (PDOException $e) {
1883 1883
 			return "error : ".$e->getMessage();
1884 1884
 		}
1885 1885
 	}
1886
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1886
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1887 1887
 		global $globalDBdriver;
1888 1888
 		if ($filter_name == '') $filter_name = $this->filter_name;
1889 1889
 		if ($globalDBdriver == 'mysql') {
@@ -1892,11 +1892,11 @@  discard block
 block discarded – undo
1892 1892
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1893 1893
 			$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);"; 
1894 1894
 		}
1895
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1895
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1896 1896
 		try {
1897 1897
 			$sth = $this->db->prepare($query);
1898 1898
 			$sth->execute($query_values);
1899
-		} catch(PDOException $e) {
1899
+		} catch (PDOException $e) {
1900 1900
 			return "error : ".$e->getMessage();
1901 1901
 		}
1902 1902
 	}
@@ -1920,95 +1920,95 @@  discard block
 block discarded – undo
1920 1920
         }
1921 1921
         */
1922 1922
 
1923
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1923
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1924 1924
 		global $globalDBdriver;
1925 1925
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1926 1926
 		$query_values = array();
1927 1927
 		if ($globalDBdriver == 'mysql') {
1928 1928
 			if ($year != '') {
1929 1929
 				$query .= ' AND YEAR(stats_date) = :year';
1930
-				$query_values = array_merge($query_values,array(':year' => $year));
1930
+				$query_values = array_merge($query_values, array(':year' => $year));
1931 1931
 			}
1932 1932
 			if ($month != '') {
1933 1933
 				$query .= ' AND MONTH(stats_date) = :month';
1934
-				$query_values = array_merge($query_values,array(':month' => $month));
1934
+				$query_values = array_merge($query_values, array(':month' => $month));
1935 1935
 			}
1936 1936
 			if ($day != '') {
1937 1937
 				$query .= ' AND DAY(stats_date) = :day';
1938
-				$query_values = array_merge($query_values,array(':day' => $day));
1938
+				$query_values = array_merge($query_values, array(':day' => $day));
1939 1939
 			}
1940 1940
 		} else {
1941 1941
 			if ($year != '') {
1942 1942
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1943
-				$query_values = array_merge($query_values,array(':year' => $year));
1943
+				$query_values = array_merge($query_values, array(':year' => $year));
1944 1944
 			}
1945 1945
 			if ($month != '') {
1946 1946
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1947
-				$query_values = array_merge($query_values,array(':month' => $month));
1947
+				$query_values = array_merge($query_values, array(':month' => $month));
1948 1948
 			}
1949 1949
 			if ($day != '') {
1950 1950
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1951
-				$query_values = array_merge($query_values,array(':day' => $day));
1951
+				$query_values = array_merge($query_values, array(':day' => $day));
1952 1952
 			}
1953 1953
 		}
1954 1954
 		$query .= " ORDER BY source_name";
1955
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1955
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1956 1956
 		try {
1957 1957
 			$sth = $this->db->prepare($query);
1958 1958
 			$sth->execute($query_values);
1959
-		} catch(PDOException $e) {
1959
+		} catch (PDOException $e) {
1960 1960
 			echo "error : ".$e->getMessage();
1961 1961
 		}
1962 1962
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1963 1963
 		return $all;
1964 1964
 	}
1965 1965
 
1966
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1966
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1967 1967
 		global $globalDBdriver;
1968 1968
 		if ($globalDBdriver == 'mysql') {
1969 1969
 			$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";
1970 1970
 		} else {
1971 1971
 			$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);"; 
1972 1972
 		}
1973
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1973
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1974 1974
 		try {
1975 1975
 			$sth = $this->db->prepare($query);
1976 1976
 			$sth->execute($query_values);
1977
-		} catch(PDOException $e) {
1977
+		} catch (PDOException $e) {
1978 1978
 			return "error : ".$e->getMessage();
1979 1979
 		}
1980 1980
 	}
1981
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1981
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1982 1982
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1983
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1983
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1984 1984
 		try {
1985 1985
 			$sth = $this->db->prepare($query);
1986 1986
 			$sth->execute($query_values);
1987
-		} catch(PDOException $e) {
1987
+		} catch (PDOException $e) {
1988 1988
 			return "error : ".$e->getMessage();
1989 1989
 		}
1990 1990
 	}
1991
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1991
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
1992 1992
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1993
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1993
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1994 1994
 		try {
1995 1995
 			$sth = $this->db->prepare($query);
1996 1996
 			$sth->execute($query_values);
1997
-		} catch(PDOException $e) {
1997
+		} catch (PDOException $e) {
1998 1998
 			return "error : ".$e->getMessage();
1999 1999
 		}
2000 2000
 	}
2001
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
2001
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
2002 2002
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2003
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2003
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2004 2004
 		try {
2005 2005
 			$sth = $this->db->prepare($query);
2006 2006
 			$sth->execute($query_values);
2007
-		} catch(PDOException $e) {
2007
+		} catch (PDOException $e) {
2008 2008
 			return "error : ".$e->getMessage();
2009 2009
 		}
2010 2010
 	}
2011
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
2011
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
2012 2012
 		global $globalDBdriver;
2013 2013
 		if ($globalDBdriver == 'mysql') {
2014 2014
 			if ($reset) {
@@ -2023,15 +2023,15 @@  discard block
 block discarded – undo
2023 2023
 				$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);"; 
2024 2024
 			}
2025 2025
 		}
2026
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2026
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2027 2027
 		try {
2028 2028
 			$sth = $this->db->prepare($query);
2029 2029
 			$sth->execute($query_values);
2030
-		} catch(PDOException $e) {
2030
+		} catch (PDOException $e) {
2031 2031
 			return "error : ".$e->getMessage();
2032 2032
 		}
2033 2033
 	}
2034
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
2034
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2035 2035
 		global $globalDBdriver;
2036 2036
 		if ($globalDBdriver == 'mysql') {
2037 2037
 			if ($reset) {
@@ -2046,15 +2046,15 @@  discard block
 block discarded – undo
2046 2046
 				$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);"; 
2047 2047
 			}
2048 2048
 		}
2049
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
2049
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
2050 2050
 		try {
2051 2051
 			$sth = $this->db->prepare($query);
2052 2052
 			$sth->execute($query_values);
2053
-		} catch(PDOException $e) {
2053
+		} catch (PDOException $e) {
2054 2054
 			return "error : ".$e->getMessage();
2055 2055
 		}
2056 2056
 	}
2057
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
2057
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2058 2058
 		global $globalDBdriver;
2059 2059
 		if ($globalDBdriver == 'mysql') {
2060 2060
 			if ($reset) {
@@ -2069,15 +2069,15 @@  discard block
 block discarded – undo
2069 2069
 				$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);"; 
2070 2070
 			}
2071 2071
 		}
2072
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
2072
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
2073 2073
 		try {
2074 2074
 			$sth = $this->db->prepare($query);
2075 2075
 			$sth->execute($query_values);
2076
-		} catch(PDOException $e) {
2076
+		} catch (PDOException $e) {
2077 2077
 			return "error : ".$e->getMessage();
2078 2078
 		}
2079 2079
 	}
2080
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2080
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2081 2081
 		global $globalDBdriver;
2082 2082
 		if ($globalDBdriver == 'mysql') {
2083 2083
 			if ($reset) {
@@ -2092,15 +2092,15 @@  discard block
 block discarded – undo
2092 2092
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2093 2093
 			}
2094 2094
 		}
2095
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2095
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2096 2096
 		try {
2097 2097
 			$sth = $this->db->prepare($query);
2098 2098
 			$sth->execute($query_values);
2099
-		} catch(PDOException $e) {
2099
+		} catch (PDOException $e) {
2100 2100
 			return "error : ".$e->getMessage();
2101 2101
 		}
2102 2102
 	}
2103
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2103
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2104 2104
 		global $globalDBdriver;
2105 2105
 		if ($globalDBdriver == 'mysql') {
2106 2106
 			if ($reset) {
@@ -2115,15 +2115,15 @@  discard block
 block discarded – undo
2115 2115
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2116 2116
 			}
2117 2117
 		}
2118
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2118
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2119 2119
 		try {
2120 2120
 			$sth = $this->db->prepare($query);
2121 2121
 			$sth->execute($query_values);
2122
-		} catch(PDOException $e) {
2122
+		} catch (PDOException $e) {
2123 2123
 			return "error : ".$e->getMessage();
2124 2124
 		}
2125 2125
 	}
2126
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2126
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2127 2127
 		global $globalDBdriver;
2128 2128
 		if ($globalDBdriver == 'mysql') {
2129 2129
 			if ($reset) {
@@ -2138,15 +2138,15 @@  discard block
 block discarded – undo
2138 2138
 				$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);"; 
2139 2139
 			}
2140 2140
 		}
2141
-		$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);
2141
+		$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);
2142 2142
 		try {
2143 2143
 			$sth = $this->db->prepare($query);
2144 2144
 			$sth->execute($query_values);
2145
-		} catch(PDOException $e) {
2145
+		} catch (PDOException $e) {
2146 2146
 			return "error : ".$e->getMessage();
2147 2147
 		}
2148 2148
 	}
2149
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2149
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2150 2150
 		global $globalDBdriver;
2151 2151
 		if ($globalDBdriver == 'mysql') {
2152 2152
 			if ($reset) {
@@ -2161,15 +2161,15 @@  discard block
 block discarded – undo
2161 2161
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2162 2162
 			}
2163 2163
 		}
2164
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2164
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2165 2165
 		try {
2166 2166
 			$sth = $this->db->prepare($query);
2167 2167
 			$sth->execute($query_values);
2168
-		} catch(PDOException $e) {
2168
+		} catch (PDOException $e) {
2169 2169
 			return "error : ".$e->getMessage();
2170 2170
 		}
2171 2171
 	}
2172
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2172
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2173 2173
 		global $globalDBdriver;
2174 2174
 		if ($globalDBdriver == 'mysql') {
2175 2175
 			if ($reset) {
@@ -2184,15 +2184,15 @@  discard block
 block discarded – undo
2184 2184
 				$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);"; 
2185 2185
 			}
2186 2186
 		}
2187
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2187
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2188 2188
 		try {
2189 2189
 			$sth = $this->db->prepare($query);
2190 2190
 			$sth->execute($query_values);
2191
-		} catch(PDOException $e) {
2191
+		} catch (PDOException $e) {
2192 2192
 			return "error : ".$e->getMessage();
2193 2193
 		}
2194 2194
 	}
2195
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2195
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2196 2196
 		global $globalDBdriver;
2197 2197
 		if ($globalDBdriver == 'mysql') {
2198 2198
 			if ($reset) {
@@ -2207,15 +2207,15 @@  discard block
 block discarded – undo
2207 2207
 				$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);"; 
2208 2208
 			}
2209 2209
 		}
2210
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2210
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2211 2211
 		try {
2212 2212
 			$sth = $this->db->prepare($query);
2213 2213
 			$sth->execute($query_values);
2214
-		} catch(PDOException $e) {
2214
+		} catch (PDOException $e) {
2215 2215
 			return "error : ".$e->getMessage();
2216 2216
 		}
2217 2217
 	}
2218
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2218
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2219 2219
 		global $globalDBdriver;
2220 2220
 		if ($globalDBdriver == 'mysql') {
2221 2221
 			if ($reset) {
@@ -2230,15 +2230,15 @@  discard block
 block discarded – undo
2230 2230
 				$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);"; 
2231 2231
 			}
2232 2232
 		}
2233
-		$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);
2233
+		$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);
2234 2234
 		try {
2235 2235
 			$sth = $this->db->prepare($query);
2236 2236
 			$sth->execute($query_values);
2237
-		} catch(PDOException $e) {
2237
+		} catch (PDOException $e) {
2238 2238
 			return "error : ".$e->getMessage();
2239 2239
 		}
2240 2240
 	}
2241
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2241
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2242 2242
 		global $globalDBdriver;
2243 2243
 		if ($airport_icao != '') {
2244 2244
 			if ($globalDBdriver == 'mysql') {
@@ -2254,16 +2254,16 @@  discard block
 block discarded – undo
2254 2254
 					$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);"; 
2255 2255
 				}
2256 2256
 			}
2257
-			$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);
2257
+			$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);
2258 2258
 			try {
2259 2259
 				$sth = $this->db->prepare($query);
2260 2260
 				$sth->execute($query_values);
2261
-			} catch(PDOException $e) {
2261
+			} catch (PDOException $e) {
2262 2262
 				return "error : ".$e->getMessage();
2263 2263
 			}
2264 2264
 		}
2265 2265
 	}
2266
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2266
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2267 2267
 		global $globalDBdriver;
2268 2268
 		if ($airport_icao != '') {
2269 2269
 			if ($globalDBdriver == 'mysql') {
@@ -2271,16 +2271,16 @@  discard block
 block discarded – undo
2271 2271
 			} else {
2272 2272
 				$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);"; 
2273 2273
 			}
2274
-			$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);
2274
+			$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);
2275 2275
 			 try {
2276 2276
 				$sth = $this->db->prepare($query);
2277 2277
 				$sth->execute($query_values);
2278
-			} catch(PDOException $e) {
2278
+			} catch (PDOException $e) {
2279 2279
 				return "error : ".$e->getMessage();
2280 2280
 			}
2281 2281
 		}
2282 2282
 	}
2283
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2283
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2284 2284
 		global $globalDBdriver;
2285 2285
 		if ($airport_icao != '') {
2286 2286
 			if ($globalDBdriver == 'mysql') {
@@ -2296,16 +2296,16 @@  discard block
 block discarded – undo
2296 2296
 					$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);"; 
2297 2297
 				}
2298 2298
 			}
2299
-			$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);
2299
+			$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);
2300 2300
 			try {
2301 2301
 				$sth = $this->db->prepare($query);
2302 2302
 				$sth->execute($query_values);
2303
-			} catch(PDOException $e) {
2303
+			} catch (PDOException $e) {
2304 2304
 				return "error : ".$e->getMessage();
2305 2305
 			}
2306 2306
 		}
2307 2307
 	}
2308
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2308
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2309 2309
 		global $globalDBdriver;
2310 2310
 		if ($airport_icao != '') {
2311 2311
 			if ($globalDBdriver == 'mysql') {
@@ -2313,11 +2313,11 @@  discard block
 block discarded – undo
2313 2313
 			} else {
2314 2314
 				$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);"; 
2315 2315
 			}
2316
-			$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);
2316
+			$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);
2317 2317
 			try {
2318 2318
 				$sth = $this->db->prepare($query);
2319 2319
 				$sth->execute($query_values);
2320
-			} catch(PDOException $e) {
2320
+			} catch (PDOException $e) {
2321 2321
 				return "error : ".$e->getMessage();
2322 2322
 			}
2323 2323
 		}
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 		try {
2330 2330
 			$sth = $this->db->prepare($query);
2331 2331
 			$sth->execute($query_values);
2332
-		} catch(PDOException $e) {
2332
+		} catch (PDOException $e) {
2333 2333
 			return "error : ".$e->getMessage();
2334 2334
 		}
2335 2335
 	}
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 		try {
2340 2340
 			$sth = $this->db->prepare($query);
2341 2341
 			$sth->execute($query_values);
2342
-		} catch(PDOException $e) {
2342
+		} catch (PDOException $e) {
2343 2343
 			return "error : ".$e->getMessage();
2344 2344
 		}
2345 2345
 	}
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
 		try {
2350 2350
 			$sth = $this->db->prepare($query);
2351 2351
 			$sth->execute($query_values);
2352
-		} catch(PDOException $e) {
2352
+		} catch (PDOException $e) {
2353 2353
 			return "error : ".$e->getMessage();
2354 2354
 		}
2355 2355
 	}
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
 		try {
2360 2360
 			$sth = $this->db->prepare($query);
2361 2361
 			$sth->execute($query_values);
2362
-		} catch(PDOException $e) {
2362
+		} catch (PDOException $e) {
2363 2363
 			return "error : ".$e->getMessage();
2364 2364
 		}
2365 2365
 	}
@@ -2369,13 +2369,13 @@  discard block
 block discarded – undo
2369 2369
 		try {
2370 2370
 			$sth = $this->db->prepare($query);
2371 2371
 			$sth->execute($query_values);
2372
-		} catch(PDOException $e) {
2372
+		} catch (PDOException $e) {
2373 2373
 			return "error : ".$e->getMessage();
2374 2374
 		}
2375 2375
 	}
2376 2376
 
2377 2377
 	public function addOldStats() {
2378
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2378
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2379 2379
 		$Common = new Common();
2380 2380
 		$Connection = new Connection($this->db);
2381 2381
 		date_default_timezone_set('UTC');
@@ -2390,9 +2390,9 @@  discard block
 block discarded – undo
2390 2390
 			$filtername = 'marine';
2391 2391
 			if ($Connection->tableExists('countries')) {
2392 2392
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2393
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2393
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2394 2394
 				foreach ($alldata as $number) {
2395
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2395
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2396 2396
 				}
2397 2397
 			}
2398 2398
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2402,44 +2402,44 @@  discard block
 block discarded – undo
2402 2402
 			$lastyear = false;
2403 2403
 			foreach ($alldata as $number) {
2404 2404
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2405
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2405
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2406 2406
 			}
2407 2407
 			echo 'Marine data...'."\n";
2408 2408
 			$this->deleteStatMarine('month');
2409 2409
 			echo '-> countAllDatesLastMonth...'."\n";
2410 2410
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2411 2411
 			foreach ($alldata as $number) {
2412
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2412
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2413 2413
 			}
2414 2414
 			echo '-> countAllDates...'."\n";
2415 2415
 			$previousdata = $this->countAllDatesMarine();
2416 2416
 			$this->deleteStatMarine('date');
2417
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2417
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2418 2418
 			$values = array();
2419 2419
 			foreach ($alldata as $cnt) {
2420 2420
 				$values[] = $cnt['date_count'];
2421 2421
 			}
2422
-			array_multisort($values,SORT_DESC,$alldata);
2423
-			array_splice($alldata,11);
2422
+			array_multisort($values, SORT_DESC, $alldata);
2423
+			array_splice($alldata, 11);
2424 2424
 			foreach ($alldata as $number) {
2425
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2425
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2426 2426
 			}
2427 2427
 			
2428 2428
 			$this->deleteStatMarine('hour');
2429 2429
 			echo '-> countAllHours...'."\n";
2430
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2430
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2431 2431
 			foreach ($alldata as $number) {
2432
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2432
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2433 2433
 			}
2434 2434
 			if ($globalDebug) echo 'Count all types...'."\n";
2435
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2435
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2436 2436
 			foreach ($alldata as $number) {
2437
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2437
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2438 2438
 			}
2439 2439
 
2440 2440
 			echo 'Insert last stats update date...'."\n";
2441 2441
 			date_default_timezone_set('UTC');
2442
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2442
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2443 2443
 		}
2444 2444
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2445 2445
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2451,9 +2451,9 @@  discard block
 block discarded – undo
2451 2451
 			$Tracker = new Tracker($this->db);
2452 2452
 			if ($Connection->tableExists('countries')) {
2453 2453
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2454
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2454
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2455 2455
 				foreach ($alldata as $number) {
2456
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2456
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2457 2457
 				}
2458 2458
 			}
2459 2459
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2463,38 +2463,38 @@  discard block
 block discarded – undo
2463 2463
 			$lastyear = false;
2464 2464
 			foreach ($alldata as $number) {
2465 2465
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2466
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2466
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2467 2467
 			}
2468 2468
 			echo 'Tracker data...'."\n";
2469 2469
 			$this->deleteStatTracker('month');
2470 2470
 			echo '-> countAllDatesLastMonth...'."\n";
2471 2471
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2472 2472
 			foreach ($alldata as $number) {
2473
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2473
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2474 2474
 			}
2475 2475
 			echo '-> countAllDates...'."\n";
2476 2476
 			$previousdata = $this->countAllDatesTracker();
2477 2477
 			$this->deleteStatTracker('date');
2478
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2478
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2479 2479
 			$values = array();
2480 2480
 			foreach ($alldata as $cnt) {
2481 2481
 				$values[] = $cnt['date_count'];
2482 2482
 			}
2483
-			array_multisort($values,SORT_DESC,$alldata);
2484
-			array_splice($alldata,11);
2483
+			array_multisort($values, SORT_DESC, $alldata);
2484
+			array_splice($alldata, 11);
2485 2485
 			foreach ($alldata as $number) {
2486
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2486
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2487 2487
 			}
2488 2488
 			
2489 2489
 			$this->deleteStatTracker('hour');
2490 2490
 			echo '-> countAllHours...'."\n";
2491
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2491
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2492 2492
 			foreach ($alldata as $number) {
2493
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2493
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2494 2494
 			}
2495 2495
 			echo 'Insert last stats update date...'."\n";
2496 2496
 			date_default_timezone_set('UTC');
2497
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2497
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2498 2498
 		}
2499 2499
 
2500 2500
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2512,41 +2512,41 @@  discard block
 block discarded – undo
2512 2512
 			$Spotter = new Spotter($this->db);
2513 2513
 
2514 2514
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2515
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2515
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2516 2516
 			foreach ($alldata as $number) {
2517
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2517
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2518 2518
 			}
2519 2519
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2520
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2520
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2521 2521
 			foreach ($alldata as $number) {
2522
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2522
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2523 2523
 			}
2524 2524
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2525
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2525
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2526 2526
 			foreach ($alldata as $number) {
2527
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2527
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2528 2528
 			}
2529 2529
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2530
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2530
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2531 2531
 			foreach ($alldata as $number) {
2532
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2532
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2533 2533
 			}
2534 2534
 			if ($globalDebug) echo 'Count all owners...'."\n";
2535
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2535
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2536 2536
 			foreach ($alldata as $number) {
2537
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2537
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2538 2538
 			}
2539 2539
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2540
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2540
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2541 2541
 			foreach ($alldata as $number) {
2542 2542
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2543
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2543
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2544 2544
 			}
2545 2545
 			
2546 2546
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2547
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2547
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2548 2548
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2549
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2549
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2550 2550
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2551 2551
 			$alldata = array();
2552 2552
 			foreach ($pall as $value) {
@@ -2563,14 +2563,14 @@  discard block
 block discarded – undo
2563 2563
 			foreach ($alldata as $key => $row) {
2564 2564
 				$count[$key] = $row['airport_departure_icao_count'];
2565 2565
 			}
2566
-			array_multisort($count,SORT_DESC,$alldata);
2566
+			array_multisort($count, SORT_DESC, $alldata);
2567 2567
 			foreach ($alldata as $number) {
2568
-				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);
2568
+				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);
2569 2569
 			}
2570 2570
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2571
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2571
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2572 2572
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2573
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2573
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2574 2574
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2575 2575
 			$alldata = array();
2576 2576
 			foreach ($pall as $value) {
@@ -2587,18 +2587,18 @@  discard block
 block discarded – undo
2587 2587
 			foreach ($alldata as $key => $row) {
2588 2588
 				$count[$key] = $row['airport_arrival_icao_count'];
2589 2589
 			}
2590
-			array_multisort($count,SORT_DESC,$alldata);
2590
+			array_multisort($count, SORT_DESC, $alldata);
2591 2591
 			foreach ($alldata as $number) {
2592
-				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);
2592
+				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);
2593 2593
 			}
2594 2594
 			if ($Connection->tableExists('countries')) {
2595 2595
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2596 2596
 				//$SpotterArchive = new SpotterArchive();
2597 2597
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2598 2598
 				$Spotter = new Spotter($this->db);
2599
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2599
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2600 2600
 				foreach ($alldata as $number) {
2601
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2601
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2602 2602
 				}
2603 2603
 			}
2604 2604
 			
@@ -2608,12 +2608,12 @@  discard block
 block discarded – undo
2608 2608
 				$this->deleteStatsByType('fatalities_byyear');
2609 2609
 				$alldata = $Accident->countFatalitiesByYear();
2610 2610
 				foreach ($alldata as $number) {
2611
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2611
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2612 2612
 				}
2613 2613
 				$this->deleteStatsByType('fatalities_bymonth');
2614 2614
 				$alldata = $Accident->countFatalitiesLast12Months();
2615 2615
 				foreach ($alldata as $number) {
2616
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2616
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2617 2617
 				}
2618 2618
 			}
2619 2619
 
@@ -2627,37 +2627,37 @@  discard block
 block discarded – undo
2627 2627
 			$lastyear = false;
2628 2628
 			foreach ($alldata as $number) {
2629 2629
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2630
-				$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'])));
2630
+				$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'])));
2631 2631
 			}
2632 2632
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2633 2633
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2634 2634
 			foreach ($alldata as $number) {
2635
-				$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'])));
2635
+				$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'])));
2636 2636
 			}
2637 2637
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2638 2638
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2639 2639
 			foreach ($alldata as $number) {
2640
-				$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'])));
2640
+				$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'])));
2641 2641
 			}
2642 2642
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2643 2643
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2644 2644
 			foreach ($alldata as $number) {
2645
-				$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'])));
2645
+				$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'])));
2646 2646
 			}
2647 2647
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2648 2648
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2649 2649
 			foreach ($alldata as $number) {
2650
-				$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'])));
2650
+				$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'])));
2651 2651
 			}
2652 2652
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2653 2653
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2654 2654
 			foreach ($alldata as $number) {
2655
-				$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'])));
2655
+				$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'])));
2656 2656
 			}
2657 2657
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2658 2658
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2659 2659
 			foreach ($alldata as $number) {
2660
-				$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'])));
2660
+				$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'])));
2661 2661
 			}
2662 2662
 			if ($globalDebug) echo 'Airports data...'."\n";
2663 2663
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
 			}
2703 2703
 			$alldata = $pall;
2704 2704
 			foreach ($alldata as $number) {
2705
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2705
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2706 2706
 			}
2707 2707
 			echo '...Arrival'."\n";
2708 2708
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2743,7 +2743,7 @@  discard block
 block discarded – undo
2743 2743
 			}
2744 2744
 			$alldata = $pall;
2745 2745
 			foreach ($alldata as $number) {
2746
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2746
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2747 2747
 			}
2748 2748
 
2749 2749
 			echo 'Flights data...'."\n";
@@ -2751,28 +2751,28 @@  discard block
 block discarded – undo
2751 2751
 			echo '-> countAllDatesLastMonth...'."\n";
2752 2752
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2753 2753
 			foreach ($alldata as $number) {
2754
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2754
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2755 2755
 			}
2756 2756
 			echo '-> countAllDates...'."\n";
2757 2757
 			$previousdata = $this->countAllDates();
2758 2758
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2759 2759
 			$this->deleteStatFlight('date');
2760
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2760
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2761 2761
 			$values = array();
2762 2762
 			foreach ($alldata as $cnt) {
2763 2763
 				$values[] = $cnt['date_count'];
2764 2764
 			}
2765
-			array_multisort($values,SORT_DESC,$alldata);
2766
-			array_splice($alldata,11);
2765
+			array_multisort($values, SORT_DESC, $alldata);
2766
+			array_splice($alldata, 11);
2767 2767
 			foreach ($alldata as $number) {
2768
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2768
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2769 2769
 			}
2770 2770
 			
2771 2771
 			$this->deleteStatFlight('hour');
2772 2772
 			echo '-> countAllHours...'."\n";
2773
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2773
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2774 2774
 			foreach ($alldata as $number) {
2775
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2775
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2776 2776
 			}
2777 2777
 
2778 2778
 			// Count by airlines
@@ -2781,42 +2781,42 @@  discard block
 block discarded – undo
2781 2781
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2782 2782
 				$SpotterArchive = new SpotterArchive($this->db);
2783 2783
 				//$Spotter = new Spotter($this->db);
2784
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2784
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2785 2785
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2786 2786
 				foreach ($alldata as $number) {
2787
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2787
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2788 2788
 				}
2789 2789
 			}
2790 2790
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2791 2791
 			$Spotter = new Spotter($this->db);
2792
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2792
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2793 2793
 			foreach ($alldata as $number) {
2794
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2794
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2795 2795
 			}
2796 2796
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2797
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2797
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2798 2798
 			foreach ($alldata as $number) {
2799
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2799
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2800 2800
 			}
2801 2801
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2802
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2802
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2803 2803
 			foreach ($alldata as $number) {
2804
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2804
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2805 2805
 			}
2806 2806
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2807
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2807
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2808 2808
 			foreach ($alldata as $number) {
2809
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2809
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2810 2810
 			}
2811 2811
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2812
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2812
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2813 2813
 			foreach ($alldata as $number) {
2814
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2814
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2815 2815
 			}
2816 2816
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2817
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2817
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2818 2818
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2819
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2819
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2820 2820
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2821 2821
 			//$alldata = array();
2822 2822
 			foreach ($dall as $value) {
@@ -2836,12 +2836,12 @@  discard block
 block discarded – undo
2836 2836
 			}
2837 2837
 			$alldata = $pall;
2838 2838
 			foreach ($alldata as $number) {
2839
-				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);
2839
+				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);
2840 2840
 			}
2841 2841
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2842
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2842
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2843 2843
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2844
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2844
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2845 2845
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2846 2846
 			//$alldata = array();
2847 2847
 			foreach ($dall as $value) {
@@ -2861,7 +2861,7 @@  discard block
 block discarded – undo
2861 2861
 			}
2862 2862
 			$alldata = $pall;
2863 2863
 			foreach ($alldata as $number) {
2864
-				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);
2864
+				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);
2865 2865
 			}
2866 2866
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2867 2867
 			$Spotter = new Spotter($this->db);
@@ -2869,27 +2869,27 @@  discard block
 block discarded – undo
2869 2869
 			$lastyear = false;
2870 2870
 			foreach ($alldata as $number) {
2871 2871
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2872
-				$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']);
2872
+				$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']);
2873 2873
 			}
2874 2874
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2875 2875
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2876 2876
 			foreach ($alldata as $number) {
2877
-				$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']);
2877
+				$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']);
2878 2878
 			}
2879 2879
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2880 2880
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2881 2881
 			foreach ($alldata as $number) {
2882
-				$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']);
2882
+				$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']);
2883 2883
 			}
2884 2884
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2885 2885
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2886 2886
 			foreach ($alldata as $number) {
2887
-				$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']);
2887
+				$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']);
2888 2888
 			}
2889 2889
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2890 2890
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2891 2891
 			foreach ($alldata as $number) {
2892
-				$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']);
2892
+				$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']);
2893 2893
 			}
2894 2894
 			if ($globalDebug) echo '...Departure'."\n";
2895 2895
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -2912,7 +2912,7 @@  discard block
 block discarded – undo
2912 2912
 			}
2913 2913
 			$alldata = $pall;
2914 2914
 			foreach ($alldata as $number) {
2915
-				$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']);
2915
+				$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']);
2916 2916
 			}
2917 2917
 			if ($globalDebug) echo '...Arrival'."\n";
2918 2918
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -2935,32 +2935,32 @@  discard block
 block discarded – undo
2935 2935
 			}
2936 2936
 			$alldata = $pall;
2937 2937
 			foreach ($alldata as $number) {
2938
-				$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']);
2938
+				$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']);
2939 2939
 			}
2940 2940
 
2941 2941
 			if ($globalDebug) echo 'Flights data...'."\n";
2942 2942
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2943 2943
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2944 2944
 			foreach ($alldata as $number) {
2945
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2945
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
2946 2946
 			}
2947 2947
 			if ($globalDebug) echo '-> countAllDates...'."\n";
2948 2948
 			//$previousdata = $this->countAllDatesByAirlines();
2949
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2949
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
2950 2950
 			$values = array();
2951 2951
 			foreach ($alldata as $cnt) {
2952 2952
 				$values[] = $cnt['date_count'];
2953 2953
 			}
2954
-			array_multisort($values,SORT_DESC,$alldata);
2955
-			array_splice($alldata,11);
2954
+			array_multisort($values, SORT_DESC, $alldata);
2955
+			array_splice($alldata, 11);
2956 2956
 			foreach ($alldata as $number) {
2957
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2957
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
2958 2958
 			}
2959 2959
 			
2960 2960
 			if ($globalDebug) echo '-> countAllHours...'."\n";
2961
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2961
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
2962 2962
 			foreach ($alldata as $number) {
2963
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2963
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
2964 2964
 			}
2965 2965
 
2966 2966
 			// Stats by filters
@@ -2984,7 +2984,7 @@  discard block
 block discarded – undo
2984 2984
 							$last_update_day = date('Y').'-01-01 00:00:00';
2985 2985
 						}
2986 2986
 					}
2987
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2987
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2988 2988
 						$last_update_day = date('Y').'-01-01 00:00:00';
2989 2989
 						$reset = true;
2990 2990
 					}
@@ -2992,38 +2992,38 @@  discard block
 block discarded – undo
2992 2992
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2993 2993
 					$Spotter = new Spotter($this->db);
2994 2994
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
2995
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2995
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2996 2996
 					foreach ($alldata as $number) {
2997
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2997
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2998 2998
 					}
2999 2999
 					if ($globalDebug) echo 'Count all airlines...'."\n";
3000
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3000
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
3001 3001
 					foreach ($alldata as $number) {
3002
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3002
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
3003 3003
 					}
3004 3004
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3005
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3005
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
3006 3006
 					foreach ($alldata as $number) {
3007
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3007
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
3008 3008
 					}
3009 3009
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
3010
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3010
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
3011 3011
 					foreach ($alldata as $number) {
3012
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3012
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
3013 3013
 					}
3014 3014
 					if ($globalDebug) echo 'Count all owners...'."\n";
3015
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3015
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
3016 3016
 					foreach ($alldata as $number) {
3017
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3017
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
3018 3018
 					}
3019 3019
 					if ($globalDebug) echo 'Count all pilots...'."\n";
3020
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3020
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
3021 3021
 					foreach ($alldata as $number) {
3022
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3022
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
3023 3023
 					}
3024 3024
 					if ($globalDebug) echo 'Count departure airports...'."\n";
3025
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3026
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3025
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
3026
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
3027 3027
 					$alldata = array();
3028 3028
 					foreach ($pall as $value) {
3029 3029
 						$icao = $value['airport_departure_icao'];
@@ -3039,13 +3039,13 @@  discard block
 block discarded – undo
3039 3039
 					foreach ($alldata as $key => $row) {
3040 3040
 						$count[$key] = $row['airport_departure_icao_count'];
3041 3041
 					}
3042
-					array_multisort($count,SORT_DESC,$alldata);
3042
+					array_multisort($count, SORT_DESC, $alldata);
3043 3043
 					foreach ($alldata as $number) {
3044
-						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);
3044
+						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);
3045 3045
 					}
3046 3046
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3047
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3048
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3047
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
3048
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
3049 3049
 					$alldata = array();
3050 3050
 					foreach ($pall as $value) {
3051 3051
 						$icao = $value['airport_arrival_icao'];
@@ -3061,9 +3061,9 @@  discard block
 block discarded – undo
3061 3061
 					foreach ($alldata as $key => $row) {
3062 3062
 						$count[$key] = $row['airport_arrival_icao_count'];
3063 3063
 					}
3064
-					array_multisort($count,SORT_DESC,$alldata);
3064
+					array_multisort($count, SORT_DESC, $alldata);
3065 3065
 					foreach ($alldata as $number) {
3066
-						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);
3066
+						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);
3067 3067
 					}
3068 3068
 					if ($globalDebug) echo 'Count all months...'."\n";
3069 3069
 					$Spotter = new Spotter($this->db);
@@ -3071,36 +3071,36 @@  discard block
 block discarded – undo
3071 3071
 					$lastyear = false;
3072 3072
 					foreach ($alldata as $number) {
3073 3073
 						if ($number['year_name'] != date('Y')) $lastyear = true;
3074
-						$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);
3074
+						$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);
3075 3075
 					}
3076 3076
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
3077 3077
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3078 3078
 					foreach ($alldata as $number) {
3079
-						$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);
3079
+						$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);
3080 3080
 					}
3081 3081
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3082 3082
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3083 3083
 					foreach ($alldata as $number) {
3084
-						$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);
3084
+						$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);
3085 3085
 					}
3086 3086
 					if ($globalDebug) echo 'Count all military by months...'."\n";
3087 3087
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3088 3088
 					foreach ($alldata as $number) {
3089
-						$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);
3089
+						$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);
3090 3090
 					}
3091 3091
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3092 3092
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3093 3093
 				    	foreach ($alldata as $number) {
3094
-			    			$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);
3094
+			    			$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);
3095 3095
 					}
3096 3096
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3097 3097
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3098 3098
 					foreach ($alldata as $number) {
3099
-						$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);
3099
+						$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);
3100 3100
 					}
3101 3101
 					echo '...Departure'."\n";
3102
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
3103
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
3102
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
3103
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
3104 3104
 					foreach ($dall as $value) {
3105 3105
 						$icao = $value['departure_airport_icao'];
3106 3106
 						$ddate = $value['date'];
@@ -3118,11 +3118,11 @@  discard block
 block discarded – undo
3118 3118
 					}
3119 3119
 					$alldata = $pall;
3120 3120
 					foreach ($alldata as $number) {
3121
-						$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);
3121
+						$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);
3122 3122
 					}
3123 3123
 					echo '...Arrival'."\n";
3124
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3125
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3124
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3125
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3126 3126
 					foreach ($dall as $value) {
3127 3127
 						$icao = $value['arrival_airport_icao'];
3128 3128
 						$ddate = $value['date'];
@@ -3140,39 +3140,39 @@  discard block
 block discarded – undo
3140 3140
 					}
3141 3141
 					$alldata = $pall;
3142 3142
 					foreach ($alldata as $number) {
3143
-						$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);
3143
+						$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);
3144 3144
 					}
3145 3145
 					echo 'Flights data...'."\n";
3146 3146
 					echo '-> countAllDatesLastMonth...'."\n";
3147 3147
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3148 3148
 					foreach ($alldata as $number) {
3149
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3149
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3150 3150
 					}
3151 3151
 					echo '-> countAllDates...'."\n";
3152
-					$previousdata = $this->countAllDates('',$filter_name);
3153
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3152
+					$previousdata = $this->countAllDates('', $filter_name);
3153
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3154 3154
 					$values = array();
3155 3155
 					foreach ($alldata as $cnt) {
3156 3156
 						$values[] = $cnt['date_count'];
3157 3157
 					}
3158
-					array_multisort($values,SORT_DESC,$alldata);
3159
-					array_splice($alldata,11);
3158
+					array_multisort($values, SORT_DESC, $alldata);
3159
+					array_splice($alldata, 11);
3160 3160
 					foreach ($alldata as $number) {
3161
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3161
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3162 3162
 					}
3163 3163
 				
3164 3164
 					echo '-> countAllHours...'."\n";
3165
-					$alldata = $Spotter->countAllHours('hour',$filter);
3165
+					$alldata = $Spotter->countAllHours('hour', $filter);
3166 3166
 					foreach ($alldata as $number) {
3167
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3167
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3168 3168
 					}
3169 3169
 					echo 'Insert last stats update date...'."\n";
3170 3170
 					date_default_timezone_set('UTC');
3171
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3171
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3172 3172
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3173
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3173
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3174 3174
 							$this->deleteOldStats($filter_name);
3175
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3175
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3176 3176
 						}
3177 3177
 					}
3178 3178
 				}
@@ -3185,16 +3185,16 @@  discard block
 block discarded – undo
3185 3185
 				// SUM all previous month to put as year
3186 3186
 				$previous_year = date('Y');
3187 3187
 				$previous_year--;
3188
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3189
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3190
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3191
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3188
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3189
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3190
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3191
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3192 3192
 				$allairlines = $this->getAllAirlineNames();
3193 3193
 				foreach ($allairlines as $data) {
3194
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3195
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3196
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3197
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3194
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3195
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3196
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3197
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3198 3198
 				}
3199 3199
 				
3200 3200
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3203,21 +3203,21 @@  discard block
 block discarded – undo
3203 3203
 						try {
3204 3204
 							$sth = $this->db->prepare($query);
3205 3205
 							$sth->execute();
3206
-						} catch(PDOException $e) {
3206
+						} catch (PDOException $e) {
3207 3207
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3208 3208
 						}
3209 3209
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3210 3210
 						try {
3211 3211
 							$sth = $this->db->prepare($query);
3212 3212
 							$sth->execute();
3213
-						} catch(PDOException $e) {
3213
+						} catch (PDOException $e) {
3214 3214
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3215 3215
 						}
3216 3216
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3217 3217
 						try {
3218 3218
 							$sth = $this->db->prepare($query);
3219 3219
 							$sth->execute();
3220
-						} catch(PDOException $e) {
3220
+						} catch (PDOException $e) {
3221 3221
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3222 3222
 						}
3223 3223
 					}
@@ -3230,7 +3230,7 @@  discard block
 block discarded – undo
3230 3230
 					try {
3231 3231
 						$sth = $this->db->prepare($query);
3232 3232
 						$sth->execute();
3233
-					} catch(PDOException $e) {
3233
+					} catch (PDOException $e) {
3234 3234
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3235 3235
 					}
3236 3236
 					if ($globalDBdriver == 'mysql') {
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
 					try {
3242 3242
 						$sth = $this->db->prepare($query);
3243 3243
 						$sth->execute();
3244
-					} catch(PDOException $e) {
3244
+					} catch (PDOException $e) {
3245 3245
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3246 3246
 					}
3247 3247
 					if ($globalDBdriver == 'mysql') {
@@ -3252,15 +3252,15 @@  discard block
 block discarded – undo
3252 3252
 					try {
3253 3253
 						$sth = $this->db->prepare($query);
3254 3254
 						$sth->execute();
3255
-					} catch(PDOException $e) {
3255
+					} catch (PDOException $e) {
3256 3256
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3257 3257
 					}
3258 3258
 				}
3259 3259
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3260 3260
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3261
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3261
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3262 3262
 						$this->deleteOldStats();
3263
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3263
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3264 3264
 						$lastyearupdate = true;
3265 3265
 					}
3266 3266
 				}
@@ -3282,7 +3282,7 @@  discard block
 block discarded – undo
3282 3282
 					try {
3283 3283
 						$sth = $this->db->prepare($query);
3284 3284
 						$sth->execute();
3285
-					} catch(PDOException $e) {
3285
+					} catch (PDOException $e) {
3286 3286
 						return "error : ".$e->getMessage();
3287 3287
 					}
3288 3288
 					echo 'Archive old tracker data...'."\n";
@@ -3298,7 +3298,7 @@  discard block
 block discarded – undo
3298 3298
 					try {
3299 3299
 						$sth = $this->db->prepare($query);
3300 3300
 						$sth->execute();
3301
-					} catch(PDOException $e) {
3301
+					} catch (PDOException $e) {
3302 3302
 						return "error : ".$e->getMessage();
3303 3303
 					}
3304 3304
 					echo 'Archive old marine data...'."\n";
@@ -3314,7 +3314,7 @@  discard block
 block discarded – undo
3314 3314
 					try {
3315 3315
 						$sth = $this->db->prepare($query);
3316 3316
 						$sth->execute();
3317
-					} catch(PDOException $e) {
3317
+					} catch (PDOException $e) {
3318 3318
 						return "error : ".$e->getMessage();
3319 3319
 					}
3320 3320
 				}
@@ -3327,7 +3327,7 @@  discard block
 block discarded – undo
3327 3327
 				try {
3328 3328
 					$sth = $this->db->prepare($query);
3329 3329
 					$sth->execute();
3330
-				} catch(PDOException $e) {
3330
+				} catch (PDOException $e) {
3331 3331
 					return "error : ".$e->getMessage();
3332 3332
 				}
3333 3333
 				echo 'Deleting old tracker data...'."\n";
@@ -3339,7 +3339,7 @@  discard block
 block discarded – undo
3339 3339
 				try {
3340 3340
 					$sth = $this->db->prepare($query);
3341 3341
 					$sth->execute();
3342
-				} catch(PDOException $e) {
3342
+				} catch (PDOException $e) {
3343 3343
 					return "error : ".$e->getMessage();
3344 3344
 				}
3345 3345
 				echo 'Deleting old marine data...'."\n";
@@ -3351,14 +3351,14 @@  discard block
 block discarded – undo
3351 3351
 				try {
3352 3352
 					$sth = $this->db->prepare($query);
3353 3353
 					$sth->execute();
3354
-				} catch(PDOException $e) {
3354
+				} catch (PDOException $e) {
3355 3355
 					return "error : ".$e->getMessage();
3356 3356
 				}
3357 3357
 			}
3358 3358
 			if (!isset($lastyearupdate)) {
3359 3359
 				echo 'Insert last stats update date...'."\n";
3360 3360
 				date_default_timezone_set('UTC');
3361
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3361
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3362 3362
 			}
3363 3363
 			if ($globalStatsResetYear) {
3364 3364
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +745 added lines, -261 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$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";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$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";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				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 aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$filters = array('year' => $year,'month' => $month);
237 272
 			if ($filter_name != '') {
@@ -245,10 +280,15 @@  discard block
 block discarded – undo
245 280
 	}
246 281
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
247 282
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
249 286
 		if ($year == '' && $month == '') {
250
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
251
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
287
+			if ($limit) {
288
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
289
+			} else {
290
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
291
+			}
252 292
 			try {
253 293
 				$sth = $this->db->prepare($query);
254 294
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -256,7 +296,9 @@  discard block
 block discarded – undo
256 296
 				echo "error : ".$e->getMessage();
257 297
 			}
258 298
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
259
-		} else $all = array();
299
+		} else {
300
+			$all = array();
301
+		}
260 302
 		if (empty($all)) {
261 303
 			$Spotter = new Spotter($this->db);
262 304
 			$filters = array();
@@ -271,7 +313,9 @@  discard block
 block discarded – undo
271 313
 	}
272 314
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
273 315
 		global $globalStatsFilters;
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
316
+		if ($filter_name == '') {
317
+			$filter_name = $this->filter_name;
318
+		}
275 319
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
276 320
 			$Spotter = new Spotter($this->db);
277 321
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -280,8 +324,11 @@  discard block
 block discarded – undo
280 324
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
281 325
 			}
282 326
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
327
+				if ($limit) {
328
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
329
+				} else {
330
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
331
+				}
285 332
 				try {
286 333
 					$sth = $this->db->prepare($query);
287 334
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -289,11 +336,16 @@  discard block
 block discarded – undo
289 336
 					echo "error : ".$e->getMessage();
290 337
 				}
291 338
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
292
-			} else $all = array();
339
+			} else {
340
+				$all = array();
341
+			}
293 342
 		} else {
294 343
 			if ($year == '' && $month == '') {
295
-				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";
296
-				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";
344
+				if ($limit) {
345
+					$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";
346
+				} else {
347
+					$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";
348
+				}
297 349
 				try {
298 350
 					$sth = $this->db->prepare($query);
299 351
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -301,7 +353,9 @@  discard block
 block discarded – undo
301 353
 					echo "error : ".$e->getMessage();
302 354
 				}
303 355
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-			} else $all = array();
356
+			} else {
357
+				$all = array();
358
+			}
305 359
 		}
306 360
 		if (empty($all)) {
307 361
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -321,7 +375,9 @@  discard block
 block discarded – undo
321 375
 
322 376
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
323 377
 		global $globalStatsFilters;
324
-		if ($filter_name == '') $filter_name = $this->filter_name;
378
+		if ($filter_name == '') {
379
+			$filter_name = $this->filter_name;
380
+		}
325 381
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
326 382
 			$Spotter = new Spotter($this->db);
327 383
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -330,8 +386,11 @@  discard block
 block discarded – undo
330 386
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
331 387
 			}
332 388
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
389
+				if ($limit) {
390
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
391
+				} else {
392
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
393
+				}
335 394
 				try {
336 395
 					$sth = $this->db->prepare($query);
337 396
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -339,11 +398,16 @@  discard block
 block discarded – undo
339 398
 					echo "error : ".$e->getMessage();
340 399
 				}
341 400
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-			} else $all = array();
401
+			} else {
402
+				$all = array();
403
+			}
343 404
 		} else {
344 405
 			if ($year == '' && $month == '') {
345
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
346
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
406
+				if ($limit) {
407
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
408
+				} else {
409
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
410
+				}
347 411
 				try {
348 412
 					$sth = $this->db->prepare($query);
349 413
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -351,7 +415,9 @@  discard block
 block discarded – undo
351 415
 					echo "error : ".$e->getMessage();
352 416
 				}
353 417
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-			} else $all = array();
418
+			} else {
419
+				$all = array();
420
+			}
355 421
 		}
356 422
 		if (empty($all)) {
357 423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -370,7 +436,9 @@  discard block
 block discarded – undo
370 436
 	}
371 437
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 438
 		global $globalStatsFilters;
373
-		if ($filter_name == '') $filter_name = $this->filter_name;
439
+		if ($filter_name == '') {
440
+			$filter_name = $this->filter_name;
441
+		}
374 442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
375 443
 			$Spotter = new Spotter($this->db);
376 444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -378,12 +446,18 @@  discard block
 block discarded – undo
378 446
 			foreach ($airlines as $airline) {
379 447
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
380 448
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
449
+			if ($limit) {
450
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
451
+			} else {
452
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
453
+			}
383 454
 			$query_values = array(':filter_name' => $filter_name);
384 455
 		} else {
385
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
387 461
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
388 462
 		}
389 463
 		try {
@@ -411,17 +485,29 @@  discard block
 block discarded – undo
411 485
 
412 486
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
413 487
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
415 491
 		if ($year == '' && $month == '') {
416
-			if ($globalVATSIM) $forsource = 'vatsim';
417
-			if ($globalIVAO) $forsource = 'ivao';
492
+			if ($globalVATSIM) {
493
+				$forsource = 'vatsim';
494
+			}
495
+			if ($globalIVAO) {
496
+				$forsource = 'ivao';
497
+			}
418 498
 			if (isset($forsource)) {
419
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
499
+				if ($limit) {
500
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
501
+				} else {
502
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
503
+				}
421 504
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
422 505
 			} else {
423
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
510
+				}
425 511
 				$query_values = array(':filter_name' => $filter_name);
426 512
 			}
427 513
 			try {
@@ -431,7 +517,9 @@  discard block
 block discarded – undo
431 517
 				echo "error : ".$e->getMessage();
432 518
 			}
433 519
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
520
+		} else {
521
+			$all = array();
522
+		}
435 523
                 if (empty($all)) {
436 524
 	                $Spotter = new Spotter($this->db);
437 525
             		$filters = array();
@@ -446,7 +534,9 @@  discard block
 block discarded – undo
446 534
 	}
447 535
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 536
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
537
+		if ($filter_name == '') {
538
+			$filter_name = $this->filter_name;
539
+		}
450 540
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
451 541
 			$Spotter = new Spotter($this->db);
452 542
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -455,8 +545,11 @@  discard block
 block discarded – undo
455 545
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
456 546
 			}
457 547
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
548
+				if ($limit) {
549
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
550
+				} else {
551
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
552
+				}
460 553
 				try {
461 554
 					$sth = $this->db->prepare($query);
462 555
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -464,11 +557,16 @@  discard block
 block discarded – undo
464 557
 					echo "error : ".$e->getMessage();
465 558
 				}
466 559
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-			} else $all = array();
560
+			} else {
561
+				$all = array();
562
+			}
468 563
 		} else {
469 564
 			if ($year == '' && $month == '') {
470
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
471
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
565
+				if ($limit) {
566
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
567
+				} else {
568
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
569
+				}
472 570
 				try {
473 571
 					$sth = $this->db->prepare($query);
474 572
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -476,7 +574,9 @@  discard block
 block discarded – undo
476 574
 					echo "error : ".$e->getMessage();
477 575
 				}
478 576
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479
-			} else $all = array();
577
+			} else {
578
+				$all = array();
579
+			}
480 580
 		}
481 581
 		if (empty($all)) {
482 582
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -495,7 +595,9 @@  discard block
 block discarded – undo
495 595
 	}
496 596
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
497 597
 		global $globalStatsFilters;
498
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
499 601
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
500 602
 			$Spotter = new Spotter($this->db);
501 603
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -504,8 +606,11 @@  discard block
 block discarded – undo
504 606
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
505 607
 			}
506 608
 			if ($year == '' && $month == '') {
507
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
609
+				if ($limit) {
610
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
611
+				} else {
612
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
613
+				}
509 614
 				 try {
510 615
 					$sth = $this->db->prepare($query);
511 616
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -513,11 +618,16 @@  discard block
 block discarded – undo
513 618
 					echo "error : ".$e->getMessage();
514 619
 				}
515 620
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
516
-			} else $all = array();
621
+			} else {
622
+				$all = array();
623
+			}
517 624
 		} else {
518 625
 			if ($year == '' && $month == '') {
519
-				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";
520
-				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";
626
+				if ($limit) {
627
+					$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";
628
+				} else {
629
+					$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";
630
+				}
521 631
 				 try {
522 632
 					$sth = $this->db->prepare($query);
523 633
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -525,7 +635,9 @@  discard block
 block discarded – undo
525 635
 					echo "error : ".$e->getMessage();
526 636
 				}
527 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528
-			} else $all = array();
638
+			} else {
639
+				$all = array();
640
+			}
529 641
 		}
530 642
 		if (empty($all)) {
531 643
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -544,7 +656,9 @@  discard block
 block discarded – undo
544 656
 	}
545 657
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
546 658
 		$Connection = new Connection($this->db);
547
-		if ($filter_name == '') $filter_name = $this->filter_name;
659
+		if ($filter_name == '') {
660
+			$filter_name = $this->filter_name;
661
+		}
548 662
 		if ($Connection->tableExists('countries')) {
549 663
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
550 664
 				$Spotter = new Spotter($this->db);
@@ -554,8 +668,11 @@  discard block
 block discarded – undo
554 668
 					foreach ($airlines as $airline) {
555 669
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
556 670
 					}
557
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
671
+					if ($limit) {
672
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
673
+					} else {
674
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
675
+					}
559 676
 					 try {
560 677
 						$sth = $this->db->prepare($query);
561 678
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -564,11 +681,16 @@  discard block
 block discarded – undo
564 681
 					}
565 682
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
566 683
 					return $all;
567
-				} else return array();
684
+				} else {
685
+					return array();
686
+				}
568 687
 			} else {
569 688
 				if ($year == '' && $month == '') {
570
-					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";
571
-					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";
689
+					if ($limit) {
690
+						$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";
691
+					} else {
692
+						$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";
693
+					}
572 694
 					 try {
573 695
 						$sth = $this->db->prepare($query);
574 696
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,20 +699,29 @@  discard block
 block discarded – undo
577 699
 					}
578 700
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 701
 					return $all;
580
-				} else return array();
702
+				} else {
703
+					return array();
704
+				}
581 705
 			}
582 706
 			$Spotter = new Spotter($this->db);
583 707
 			return $Spotter->countAllFlightOverCountries($limit);
584
-		} else return array();
708
+		} else {
709
+			return array();
710
+		}
585 711
 	}
586 712
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
587 713
 		$Connection = new Connection($this->db);
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
589 717
 		if ($Connection->tableExists('countries')) {
590 718
 			$all = array();
591 719
 			if ($year == '' && $month == '') {
592
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
593
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
720
+				if ($limit) {
721
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
722
+				} else {
723
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
724
+				}
594 725
 				 try {
595 726
 					$sth = $this->db->prepare($query);
596 727
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -608,17 +739,24 @@  discard block
 block discarded – undo
608 739
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
609 740
 			}
610 741
 			return $all;
611
-		} else return array();
742
+		} else {
743
+			return array();
744
+		}
612 745
 	}
613 746
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
614 747
 		global $globalStatsFilters;
615 748
 		$Connection = new Connection($this->db);
616
-		if ($filter_name == '') $filter_name = $this->filter_name;
749
+		if ($filter_name == '') {
750
+			$filter_name = $this->filter_name;
751
+		}
617 752
 		if ($Connection->tableExists('countries')) {
618 753
 			$all = array();
619 754
 			if ($year == '' && $month == '') {
620
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
621
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
755
+				if ($limit) {
756
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
757
+				} else {
758
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
759
+				}
622 760
 				 try {
623 761
 					$sth = $this->db->prepare($query);
624 762
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -637,14 +775,21 @@  discard block
 block discarded – undo
637 775
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
638 776
 			}
639 777
 			return $all;
640
-		} else return array();
778
+		} else {
779
+			return array();
780
+		}
641 781
 	}
642 782
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
643 783
 		global $globalStatsFilters;
644
-		if ($filter_name == '') $filter_name = $this->filter_name;
784
+		if ($filter_name == '') {
785
+			$filter_name = $this->filter_name;
786
+		}
645 787
 		if ($year == '' && $month == '') {
646
-			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";
647
-			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";
788
+			if ($limit) {
789
+				$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";
790
+			} else {
791
+				$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";
792
+			}
648 793
 			try {
649 794
 				$sth = $this->db->prepare($query);
650 795
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -652,7 +797,9 @@  discard block
 block discarded – undo
652 797
 				echo "error : ".$e->getMessage();
653 798
 			}
654 799
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655
-		} else $all = array();
800
+		} else {
801
+			$all = array();
802
+		}
656 803
 		if (empty($all)) {
657 804
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
658 805
 			if ($filter_name != '') {
@@ -667,7 +814,9 @@  discard block
 block discarded – undo
667 814
 
668 815
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
669 816
 		global $globalStatsFilters;
670
-		if ($filter_name == '') $filter_name = $this->filter_name;
817
+		if ($filter_name == '') {
818
+			$filter_name = $this->filter_name;
819
+		}
671 820
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
672 821
 			$Spotter = new Spotter($this->db);
673 822
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -676,8 +825,11 @@  discard block
 block discarded – undo
676 825
 				foreach ($airlines as $airline) {
677 826
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
678 827
 				}
679
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
680
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
828
+				if ($limit) {
829
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
830
+				} else {
831
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
832
+				}
681 833
 				try {
682 834
 					$sth = $this->db->prepare($query);
683 835
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -685,11 +837,16 @@  discard block
 block discarded – undo
685 837
 					echo "error : ".$e->getMessage();
686 838
 				}
687 839
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
688
-			} else $all = array();
840
+			} else {
841
+				$all = array();
842
+			}
689 843
 		} else {
690 844
 			if ($year == '' && $month == '') {
691
-				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";
692
-				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";
845
+				if ($limit) {
846
+					$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";
847
+				} else {
848
+					$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";
849
+				}
693 850
 				try {
694 851
 					$sth = $this->db->prepare($query);
695 852
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -697,7 +854,9 @@  discard block
 block discarded – undo
697 854
 					echo "error : ".$e->getMessage();
698 855
 				}
699 856
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
700
-			} else $all = array();
857
+			} else {
858
+				$all = array();
859
+			}
701 860
 		}
702 861
 		if (empty($all)) {
703 862
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -716,7 +875,9 @@  discard block
 block discarded – undo
716 875
 	}
717 876
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
718 877
 		global $globalStatsFilters;
719
-		if ($filter_name == '') $filter_name = $this->filter_name;
878
+		if ($filter_name == '') {
879
+			$filter_name = $this->filter_name;
880
+		}
720 881
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
721 882
 			$Spotter = new Spotter($this->db);
722 883
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -725,8 +886,11 @@  discard block
 block discarded – undo
725 886
 				foreach ($airlines as $airline) {
726 887
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
727 888
 				}
728
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
729
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
889
+				if ($limit) {
890
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
891
+				} else {
892
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
893
+				}
730 894
 				try {
731 895
 					$sth = $this->db->prepare($query);
732 896
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -734,11 +898,16 @@  discard block
 block discarded – undo
734 898
 					echo "error : ".$e->getMessage();
735 899
 				}
736 900
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
737
-			} else $all = array();
901
+			} else {
902
+				$all = array();
903
+			}
738 904
 		} else {
739 905
 			if ($year == '' && $month == '') {
740
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
741
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
906
+				if ($limit) {
907
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
908
+				} else {
909
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
910
+				}
742 911
 				try {
743 912
 					$sth = $this->db->prepare($query);
744 913
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -746,7 +915,9 @@  discard block
 block discarded – undo
746 915
 					echo "error : ".$e->getMessage();
747 916
 				}
748 917
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
749
-			} else $all = array();
918
+			} else {
919
+				$all = array();
920
+			}
750 921
 		}
751 922
 		if (empty($all)) {
752 923
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -771,7 +942,9 @@  discard block
 block discarded – undo
771 942
 				$icao = $value['airport_departure_icao'];
772 943
 				if (isset($all[$icao])) {
773 944
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
774
-				} else $all[$icao] = $value;
945
+				} else {
946
+					$all[$icao] = $value;
947
+				}
775 948
 			}
776 949
 			$count = array();
777 950
 			foreach ($all as $key => $row) {
@@ -783,7 +956,9 @@  discard block
 block discarded – undo
783 956
 	}
784 957
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
785 958
 		global $globalStatsFilters;
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
959
+		if ($filter_name == '') {
960
+			$filter_name = $this->filter_name;
961
+		}
787 962
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
788 963
 			$Spotter = new Spotter($this->db);
789 964
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -792,8 +967,11 @@  discard block
 block discarded – undo
792 967
 				foreach ($airlines as $airline) {
793 968
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
794 969
 				}
795
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
796
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
970
+				if ($limit) {
971
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
972
+				} else {
973
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
974
+				}
797 975
 				try {
798 976
 					$sth = $this->db->prepare($query);
799 977
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -801,11 +979,16 @@  discard block
 block discarded – undo
801 979
 					echo "error : ".$e->getMessage();
802 980
 				}
803 981
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
804
-			} else $all = array();
982
+			} else {
983
+				$all = array();
984
+			}
805 985
 		} else {
806 986
 			if ($year == '' && $month == '') {
807
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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";
808
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
987
+				if ($limit) {
988
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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";
989
+				} else {
990
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
991
+				}
809 992
 				try {
810 993
 					$sth = $this->db->prepare($query);
811 994
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -813,7 +996,9 @@  discard block
 block discarded – undo
813 996
 					echo "error : ".$e->getMessage();
814 997
 				}
815 998
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
816
-			} else $all = array();
999
+			} else {
1000
+				$all = array();
1001
+			}
817 1002
 		}
818 1003
 		if (empty($all)) {
819 1004
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -838,7 +1023,9 @@  discard block
 block discarded – undo
838 1023
 				$icao = $value['airport_arrival_icao'];
839 1024
 				if (isset($all[$icao])) {
840 1025
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
841
-				} else $all[$icao] = $value;
1026
+				} else {
1027
+					$all[$icao] = $value;
1028
+				}
842 1029
 			}
843 1030
 			$count = array();
844 1031
 			foreach ($all as $key => $row) {
@@ -850,7 +1037,9 @@  discard block
 block discarded – undo
850 1037
 	}
851 1038
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
852 1039
 		global $globalDBdriver, $globalStatsFilters;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
1040
+		if ($filter_name == '') {
1041
+			$filter_name = $this->filter_name;
1042
+		}
854 1043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
855 1044
 			$Spotter = new Spotter($this->db);
856 1045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -859,20 +1048,32 @@  discard block
 block discarded – undo
859 1048
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
860 1049
 			}
861 1050
 			if ($globalDBdriver == 'mysql') {
862
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1051
+				if ($limit) {
1052
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1053
+				} else {
1054
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1055
+				}
864 1056
 			} else {
865
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1057
+				if ($limit) {
1058
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1059
+				} else {
1060
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1061
+				}
867 1062
 			}
868 1063
 			$query_data = array(':filter_name' => $filter_name);
869 1064
 		} else {
870 1065
 			if ($globalDBdriver == 'mysql') {
871
-				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";
872
-				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";
1066
+				if ($limit) {
1067
+					$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";
1068
+				} else {
1069
+					$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";
1070
+				}
873 1071
 			} else {
874
-				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";
875
-				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";
1072
+				if ($limit) {
1073
+					$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";
1074
+				} else {
1075
+					$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";
1076
+				}
876 1077
 			}
877 1078
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
878 1079
 		}
@@ -900,13 +1101,21 @@  discard block
 block discarded – undo
900 1101
 
901 1102
 	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
902 1103
 		global $globalDBdriver, $globalStatsFilters;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1104
+		if ($filter_name == '') {
1105
+			$filter_name = $this->filter_name;
1106
+		}
904 1107
 		if ($globalDBdriver == 'mysql') {
905
-			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 = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
906
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1108
+			if ($limit) {
1109
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1110
+			} else {
1111
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1112
+			}
907 1113
 		} else {
908
-			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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
909
-			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 = 'marine_bymonth' AND filter_name = :filter_name";
1114
+			if ($limit) {
1115
+				$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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1116
+			} else {
1117
+				$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 = 'marine_bymonth' AND filter_name = :filter_name";
1118
+			}
910 1119
 		}
911 1120
 		$query_data = array(':filter_name' => $filter_name);
912 1121
 		try {
@@ -929,7 +1138,9 @@  discard block
 block discarded – undo
929 1138
 	
930 1139
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
931 1140
 		global $globalStatsFilters;
932
-		if ($filter_name == '') $filter_name = $this->filter_name;
1141
+		if ($filter_name == '') {
1142
+			$filter_name = $this->filter_name;
1143
+		}
933 1144
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
934 1145
 			$Spotter = new Spotter($this->db);
935 1146
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -966,7 +1177,9 @@  discard block
 block discarded – undo
966 1177
 	}
967 1178
 	public function countAllMarineDatesLastMonth($filter_name = '') {
968 1179
 		global $globalStatsFilters;
969
-		if ($filter_name == '') $filter_name = $this->filter_name;
1180
+		if ($filter_name == '') {
1181
+			$filter_name = $this->filter_name;
1182
+		}
970 1183
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name";
971 1184
 		$query_data = array(':filter_name' => $filter_name);
972 1185
 		try {
@@ -988,7 +1201,9 @@  discard block
 block discarded – undo
988 1201
 	}
989 1202
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
990 1203
 		global $globalDBdriver, $globalStatsFilters;
991
-		if ($filter_name == '') $filter_name = $this->filter_name;
1204
+		if ($filter_name == '') {
1205
+			$filter_name = $this->filter_name;
1206
+		}
992 1207
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
993 1208
 			$Spotter = new Spotter($this->db);
994 1209
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1033,7 +1248,9 @@  discard block
 block discarded – undo
1033 1248
 	}
1034 1249
 	public function countAllMarineDatesLast7Days($filter_name = '') {
1035 1250
 		global $globalDBdriver, $globalStatsFilters;
1036
-		if ($filter_name == '') $filter_name = $this->filter_name;
1251
+		if ($filter_name == '') {
1252
+			$filter_name = $this->filter_name;
1253
+		}
1037 1254
 		if ($globalDBdriver == 'mysql') {
1038 1255
 			$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1039 1256
 		} else {
@@ -1059,7 +1276,9 @@  discard block
 block discarded – undo
1059 1276
 	}
1060 1277
 	public function countAllDates($stats_airline = '',$filter_name = '') {
1061 1278
 		global $globalStatsFilters;
1062
-		if ($filter_name == '') $filter_name = $this->filter_name;
1279
+		if ($filter_name == '') {
1280
+			$filter_name = $this->filter_name;
1281
+		}
1063 1282
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1064 1283
 			$Spotter = new Spotter($this->db);
1065 1284
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1096,7 +1315,9 @@  discard block
 block discarded – undo
1096 1315
 	}
1097 1316
 	public function countAllDatesMarine($filter_name = '') {
1098 1317
 		global $globalStatsFilters;
1099
-		if ($filter_name == '') $filter_name = $this->filter_name;
1318
+		if ($filter_name == '') {
1319
+			$filter_name = $this->filter_name;
1320
+		}
1100 1321
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1101 1322
 		$query_data = array(':filter_name' => $filter_name);
1102 1323
 		try {
@@ -1118,7 +1339,9 @@  discard block
 block discarded – undo
1118 1339
 	}
1119 1340
 	public function countAllDatesTracker($filter_name = '') {
1120 1341
 		global $globalStatsFilters;
1121
-		if ($filter_name == '') $filter_name = $this->filter_name;
1342
+		if ($filter_name == '') {
1343
+			$filter_name = $this->filter_name;
1344
+		}
1122 1345
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1123 1346
 		$query_data = array(':filter_name' => $filter_name);
1124 1347
 		try {
@@ -1140,7 +1363,9 @@  discard block
 block discarded – undo
1140 1363
 	}
1141 1364
 	public function countAllDatesByAirlines($filter_name = '') {
1142 1365
 		global $globalStatsFilters;
1143
-		if ($filter_name == '') $filter_name = $this->filter_name;
1366
+		if ($filter_name == '') {
1367
+			$filter_name = $this->filter_name;
1368
+		}
1144 1369
 		$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";
1145 1370
 		$query_data = array('filter_name' => $filter_name);
1146 1371
 		try {
@@ -1162,7 +1387,9 @@  discard block
 block discarded – undo
1162 1387
 	}
1163 1388
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1164 1389
 		global $globalStatsFilters, $globalDBdriver;
1165
-		if ($filter_name == '') $filter_name = $this->filter_name;
1390
+		if ($filter_name == '') {
1391
+			$filter_name = $this->filter_name;
1392
+		}
1166 1393
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1167 1394
 			$Spotter = new Spotter($this->db);
1168 1395
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1247,7 +1474,9 @@  discard block
 block discarded – undo
1247 1474
 	}
1248 1475
 	public function countAllMilitaryMonths($filter_name = '') {
1249 1476
 		global $globalStatsFilters;
1250
-		if ($filter_name == '') $filter_name = $this->filter_name;
1477
+		if ($filter_name == '') {
1478
+			$filter_name = $this->filter_name;
1479
+		}
1251 1480
 		$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";
1252 1481
 		try {
1253 1482
 			$sth = $this->db->prepare($query);
@@ -1268,7 +1497,9 @@  discard block
 block discarded – undo
1268 1497
 	}
1269 1498
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1270 1499
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1271
-		if ($filter_name == '') $filter_name = $this->filter_name;
1500
+		if ($filter_name == '') {
1501
+			$filter_name = $this->filter_name;
1502
+		}
1272 1503
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1273 1504
 			$Spotter = new Spotter($this->db);
1274 1505
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1276,12 +1507,18 @@  discard block
 block discarded – undo
1276 1507
 			foreach ($airlines as $airline) {
1277 1508
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1278 1509
 			}
1279
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1280
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1510
+			if ($limit) {
1511
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1512
+			} else {
1513
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1514
+			}
1281 1515
 			$query_data = array(':filter_name' => $filter_name);
1282 1516
 		} else {
1283
-			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";
1284
-			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";
1517
+			if ($limit) {
1518
+				$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";
1519
+			} else {
1520
+				$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";
1521
+			}
1285 1522
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1286 1523
 		}
1287 1524
 		if ($orderby == 'hour') {
@@ -1291,7 +1528,9 @@  discard block
 block discarded – undo
1291 1528
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1292 1529
 			}
1293 1530
 		}
1294
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1531
+		if ($orderby == 'count') {
1532
+			$query .= " ORDER BY hour_count DESC";
1533
+		}
1295 1534
 		try {
1296 1535
 			$sth = $this->db->prepare($query);
1297 1536
 			$sth->execute($query_data);
@@ -1315,9 +1554,14 @@  discard block
 block discarded – undo
1315 1554
 	}
1316 1555
 	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1317 1556
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1318
-		if ($filter_name == '') $filter_name = $this->filter_name;
1319
-		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1320
-		else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1557
+		if ($filter_name == '') {
1558
+			$filter_name = $this->filter_name;
1559
+		}
1560
+		if ($limit) {
1561
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1562
+		} else {
1563
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1564
+		}
1321 1565
 		$query_data = array(':filter_name' => $filter_name);
1322 1566
 		if ($orderby == 'hour') {
1323 1567
 			if ($globalDBdriver == 'mysql') {
@@ -1326,7 +1570,9 @@  discard block
 block discarded – undo
1326 1570
 				$query .= " ORDER BY CAST(marine_date AS integer) ASC";
1327 1571
 			}
1328 1572
 		}
1329
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1573
+		if ($orderby == 'count') {
1574
+			$query .= " ORDER BY hour_count DESC";
1575
+		}
1330 1576
 		try {
1331 1577
 			$sth = $this->db->prepare($query);
1332 1578
 			$sth->execute($query_data);
@@ -1346,8 +1592,12 @@  discard block
 block discarded – undo
1346 1592
 	}
1347 1593
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1348 1594
 		global $globalStatsFilters;
1349
-		if ($filter_name == '') $filter_name = $this->filter_name;
1350
-		if ($year == '') $year = date('Y');
1595
+		if ($filter_name == '') {
1596
+			$filter_name = $this->filter_name;
1597
+		}
1598
+		if ($year == '') {
1599
+			$year = date('Y');
1600
+		}
1351 1601
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1352 1602
 		if (empty($all)) {
1353 1603
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1366,8 +1616,12 @@  discard block
 block discarded – undo
1366 1616
 	}
1367 1617
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1368 1618
 		global $globalStatsFilters;
1369
-		if ($filter_name == '') $filter_name = $this->filter_name;
1370
-		if ($year == '') $year = date('Y');
1619
+		if ($filter_name == '') {
1620
+			$filter_name = $this->filter_name;
1621
+		}
1622
+		if ($year == '') {
1623
+			$year = date('Y');
1624
+		}
1371 1625
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1372 1626
 		if (empty($all)) {
1373 1627
 			$filters = array('year' => $year,'month' => $month);
@@ -1382,8 +1636,12 @@  discard block
 block discarded – undo
1382 1636
 	}
1383 1637
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1384 1638
 		global $globalStatsFilters;
1385
-		if ($filter_name == '') $filter_name = $this->filter_name;
1386
-		if ($year == '') $year = date('Y');
1639
+		if ($filter_name == '') {
1640
+			$filter_name = $this->filter_name;
1641
+		}
1642
+		if ($year == '') {
1643
+			$year = date('Y');
1644
+		}
1387 1645
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1388 1646
 		if (empty($all)) {
1389 1647
 			$filters = array('year' => $year,'month' => $month);
@@ -1398,8 +1656,12 @@  discard block
 block discarded – undo
1398 1656
 	}
1399 1657
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1400 1658
 		global $globalStatsFilters;
1401
-		if ($filter_name == '') $filter_name = $this->filter_name;
1402
-		if ($year == '') $year = date('Y');
1659
+		if ($filter_name == '') {
1660
+			$filter_name = $this->filter_name;
1661
+		}
1662
+		if ($year == '') {
1663
+			$year = date('Y');
1664
+		}
1403 1665
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1404 1666
 		if (empty($all)) {
1405 1667
 			$filters = array();
@@ -1415,8 +1677,12 @@  discard block
 block discarded – undo
1415 1677
 	}
1416 1678
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1417 1679
 		global $globalStatsFilters;
1418
-		if ($filter_name == '') $filter_name = $this->filter_name;
1419
-		if ($year == '') $year = date('Y');
1680
+		if ($filter_name == '') {
1681
+			$filter_name = $this->filter_name;
1682
+		}
1683
+		if ($year == '') {
1684
+			$year = date('Y');
1685
+		}
1420 1686
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1421 1687
 		if (empty($all)) {
1422 1688
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1435,7 +1701,9 @@  discard block
 block discarded – undo
1435 1701
 	}
1436 1702
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1437 1703
 		global $globalStatsFilters;
1438
-		if ($filter_name == '') $filter_name = $this->filter_name;
1704
+		if ($filter_name == '') {
1705
+			$filter_name = $this->filter_name;
1706
+		}
1439 1707
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1440 1708
 			$Spotter = new Spotter($this->db);
1441 1709
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1453,7 +1721,9 @@  discard block
 block discarded – undo
1453 1721
 				}
1454 1722
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1455 1723
 				$all = $result[0]['nb'];
1456
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1724
+			} else {
1725
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1726
+			}
1457 1727
 		} else {
1458 1728
 			if ($year == '' && $month == '') {
1459 1729
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1465,7 +1735,9 @@  discard block
 block discarded – undo
1465 1735
 				}
1466 1736
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1467 1737
 				$all = $result[0]['nb'];
1468
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1738
+			} else {
1739
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1740
+			}
1469 1741
 		}
1470 1742
 		if (empty($all)) {
1471 1743
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1484,7 +1756,9 @@  discard block
 block discarded – undo
1484 1756
 	}
1485 1757
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1486 1758
 		global $globalStatsFilters;
1487
-		if ($filter_name == '') $filter_name = $this->filter_name;
1759
+		if ($filter_name == '') {
1760
+			$filter_name = $this->filter_name;
1761
+		}
1488 1762
 		if ($year == '' && $month == '') {
1489 1763
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1490 1764
 			try {
@@ -1495,7 +1769,9 @@  discard block
 block discarded – undo
1495 1769
 			}
1496 1770
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1497 1771
 			$all = $result[0]['nb_airline'];
1498
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1772
+		} else {
1773
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1774
+		}
1499 1775
 		if (empty($all)) {
1500 1776
 			$filters = array();
1501 1777
 			$filters = array('year' => $year,'month' => $month);
@@ -1510,7 +1786,9 @@  discard block
 block discarded – undo
1510 1786
 	}
1511 1787
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1512 1788
 		global $globalStatsFilters;
1513
-		if ($filter_name == '') $filter_name = $this->filter_name;
1789
+		if ($filter_name == '') {
1790
+			$filter_name = $this->filter_name;
1791
+		}
1514 1792
 		$all = array();
1515 1793
 		if ($year == '' && $month == '') {
1516 1794
 			$query = "SELECT SUM(cnt) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1537,7 +1815,9 @@  discard block
 block discarded – undo
1537 1815
 	}
1538 1816
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1539 1817
 		global $globalStatsFilters;
1540
-		if ($filter_name == '') $filter_name = $this->filter_name;
1818
+		if ($filter_name == '') {
1819
+			$filter_name = $this->filter_name;
1820
+		}
1541 1821
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1542 1822
 			$Spotter = new Spotter($this->db);
1543 1823
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1592,7 +1872,9 @@  discard block
 block discarded – undo
1592 1872
 	}
1593 1873
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1594 1874
 		global $globalStatsFilters;
1595
-		if ($filter_name == '') $filter_name = $this->filter_name;
1875
+		if ($filter_name == '') {
1876
+			$filter_name = $this->filter_name;
1877
+		}
1596 1878
 		//if ($year == '') $year = date('Y');
1597 1879
 		if ($year == '' && $month == '') {
1598 1880
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1621,7 +1903,9 @@  discard block
 block discarded – undo
1621 1903
 	}
1622 1904
 
1623 1905
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1624
-		if ($filter_name == '') $filter_name = $this->filter_name;
1906
+		if ($filter_name == '') {
1907
+			$filter_name = $this->filter_name;
1908
+		}
1625 1909
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1626 1910
 			$Spotter = new Spotter($this->db);
1627 1911
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1645,7 +1929,9 @@  discard block
 block discarded – undo
1645 1929
 		return $all;
1646 1930
 	}
1647 1931
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1648
-		if ($filter_name == '') $filter_name = $this->filter_name;
1932
+		if ($filter_name == '') {
1933
+			$filter_name = $this->filter_name;
1934
+		}
1649 1935
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1650 1936
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1651 1937
 		try {
@@ -1658,7 +1944,9 @@  discard block
 block discarded – undo
1658 1944
 		return $all;
1659 1945
 	}
1660 1946
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1661
-		if ($filter_name == '') $filter_name = $this->filter_name;
1947
+		if ($filter_name == '') {
1948
+			$filter_name = $this->filter_name;
1949
+		}
1662 1950
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1663 1951
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1664 1952
 		try {
@@ -1669,7 +1957,9 @@  discard block
 block discarded – undo
1669 1957
 		}
1670 1958
 	}
1671 1959
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1672
-		if ($filter_name == '') $filter_name = $this->filter_name;
1960
+		if ($filter_name == '') {
1961
+			$filter_name = $this->filter_name;
1962
+		}
1673 1963
 		global $globalArchiveMonths, $globalDBdriver;
1674 1964
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1675 1965
 			$Spotter = new Spotter($this->db);
@@ -1725,7 +2015,9 @@  discard block
 block discarded – undo
1725 2015
 	}
1726 2016
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1727 2017
 		global $globalArchiveMonths, $globalDBdriver;
1728
-		if ($filter_name == '') $filter_name = $this->filter_name;
2018
+		if ($filter_name == '') {
2019
+			$filter_name = $this->filter_name;
2020
+		}
1729 2021
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1730 2022
 			$Spotter = new Spotter($this->db);
1731 2023
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1758,7 +2050,9 @@  discard block
 block discarded – undo
1758 2050
 	}
1759 2051
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1760 2052
 		global $globalArchiveMonths, $globalDBdriver;
1761
-		if ($filter_name == '') $filter_name = $this->filter_name;
2053
+		if ($filter_name == '') {
2054
+			$filter_name = $this->filter_name;
2055
+		}
1762 2056
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1763 2057
 			$Spotter = new Spotter($this->db);
1764 2058
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1789,7 +2083,9 @@  discard block
 block discarded – undo
1789 2083
 	}
1790 2084
 	public function getStatsAirlineTotal($filter_name = '') {
1791 2085
 		global $globalArchiveMonths, $globalDBdriver;
1792
-		if ($filter_name == '') $filter_name = $this->filter_name;
2086
+		if ($filter_name == '') {
2087
+			$filter_name = $this->filter_name;
2088
+		}
1793 2089
 		if ($globalDBdriver == 'mysql') {
1794 2090
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1795 2091
 		} else {
@@ -1806,7 +2102,9 @@  discard block
 block discarded – undo
1806 2102
 	}
1807 2103
 	public function getStatsOwnerTotal($filter_name = '') {
1808 2104
 		global $globalArchiveMonths, $globalDBdriver;
1809
-		if ($filter_name == '') $filter_name = $this->filter_name;
2105
+		if ($filter_name == '') {
2106
+			$filter_name = $this->filter_name;
2107
+		}
1810 2108
 		if ($globalDBdriver == 'mysql') {
1811 2109
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1812 2110
 		} else {
@@ -1823,7 +2121,9 @@  discard block
 block discarded – undo
1823 2121
 	}
1824 2122
 	public function getStatsOwner($owner_name,$filter_name = '') {
1825 2123
 		global $globalArchiveMonths, $globalDBdriver;
1826
-		if ($filter_name == '') $filter_name = $this->filter_name;
2124
+		if ($filter_name == '') {
2125
+			$filter_name = $this->filter_name;
2126
+		}
1827 2127
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1828 2128
 		try {
1829 2129
 			$sth = $this->db->prepare($query);
@@ -1832,12 +2132,17 @@  discard block
 block discarded – undo
1832 2132
 			echo "error : ".$e->getMessage();
1833 2133
 		}
1834 2134
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1835
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1836
-		else return 0;
2135
+		if (isset($all[0]['cnt'])) {
2136
+			return $all[0]['cnt'];
2137
+		} else {
2138
+			return 0;
2139
+		}
1837 2140
 	}
1838 2141
 	public function getStatsPilotTotal($filter_name = '') {
1839 2142
 		global $globalArchiveMonths, $globalDBdriver;
1840
-		if ($filter_name == '') $filter_name = $this->filter_name;
2143
+		if ($filter_name == '') {
2144
+			$filter_name = $this->filter_name;
2145
+		}
1841 2146
 		if ($globalDBdriver == 'mysql') {
1842 2147
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1843 2148
 		} else {
@@ -1854,7 +2159,9 @@  discard block
 block discarded – undo
1854 2159
 	}
1855 2160
 	public function getStatsPilot($pilot,$filter_name = '') {
1856 2161
 		global $globalArchiveMonths, $globalDBdriver;
1857
-		if ($filter_name == '') $filter_name = $this->filter_name;
2162
+		if ($filter_name == '') {
2163
+			$filter_name = $this->filter_name;
2164
+		}
1858 2165
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1859 2166
 		try {
1860 2167
 			$sth = $this->db->prepare($query);
@@ -1863,13 +2170,18 @@  discard block
 block discarded – undo
1863 2170
 			echo "error : ".$e->getMessage();
1864 2171
 		}
1865 2172
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1866
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1867
-		else return 0;
2173
+		if (isset($all[0]['cnt'])) {
2174
+			return $all[0]['cnt'];
2175
+		} else {
2176
+			return 0;
2177
+		}
1868 2178
 	}
1869 2179
 
1870 2180
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1871 2181
 		global $globalDBdriver;
1872
-		if ($filter_name == '') $filter_name = $this->filter_name;
2182
+		if ($filter_name == '') {
2183
+			$filter_name = $this->filter_name;
2184
+		}
1873 2185
 		if ($globalDBdriver == 'mysql') {
1874 2186
 			$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";
1875 2187
 		} else {
@@ -1885,7 +2197,9 @@  discard block
 block discarded – undo
1885 2197
 	}
1886 2198
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1887 2199
 		global $globalDBdriver;
1888
-		if ($filter_name == '') $filter_name = $this->filter_name;
2200
+		if ($filter_name == '') {
2201
+			$filter_name = $this->filter_name;
2202
+		}
1889 2203
 		if ($globalDBdriver == 'mysql') {
1890 2204
 			$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";
1891 2205
 		} else {
@@ -2381,27 +2695,37 @@  discard block
 block discarded – undo
2381 2695
 		date_default_timezone_set('UTC');
2382 2696
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2383 2697
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2384
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2698
+			if ($globalDebug) {
2699
+				echo '!!! Update Marine stats !!!'."\n";
2700
+			}
2385 2701
 			if (isset($last_update[0]['value'])) {
2386 2702
 				$last_update_day = $last_update[0]['value'];
2387
-			} else $last_update_day = '2012-12-12 12:12:12';
2703
+			} else {
2704
+				$last_update_day = '2012-12-12 12:12:12';
2705
+			}
2388 2706
 			$reset = false;
2389 2707
 			$Marine = new Marine($this->db);
2390 2708
 			$filtername = 'marine';
2391 2709
 			if ($Connection->tableExists('countries')) {
2392
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2710
+				if ($globalDebug) {
2711
+					echo 'Count all vessels by countries...'."\n";
2712
+				}
2393 2713
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2394 2714
 				foreach ($alldata as $number) {
2395 2715
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2396 2716
 				}
2397 2717
 			}
2398
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2718
+			if ($globalDebug) {
2719
+				echo 'Count all vessels by months...'."\n";
2720
+			}
2399 2721
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2400 2722
 			$filter_last_month = array('since_date' => $last_month);
2401 2723
 			$alldata = $Marine->countAllMonths($filter_last_month);
2402 2724
 			$lastyear = false;
2403 2725
 			foreach ($alldata as $number) {
2404
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2726
+				if ($number['year_name'] != date('Y')) {
2727
+					$lastyear = true;
2728
+				}
2405 2729
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2406 2730
 			}
2407 2731
 			echo 'Marine data...'."\n";
@@ -2431,7 +2755,9 @@  discard block
 block discarded – undo
2431 2755
 			foreach ($alldata as $number) {
2432 2756
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2433 2757
 			}
2434
-			if ($globalDebug) echo 'Count all types...'."\n";
2758
+			if ($globalDebug) {
2759
+				echo 'Count all types...'."\n";
2760
+			}
2435 2761
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2436 2762
 			foreach ($alldata as $number) {
2437 2763
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2443,26 +2769,36 @@  discard block
 block discarded – undo
2443 2769
 		}
2444 2770
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2445 2771
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2446
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2772
+			if ($globalDebug) {
2773
+				echo '!!! Update tracker stats !!!'."\n";
2774
+			}
2447 2775
 			if (isset($last_update[0]['value'])) {
2448 2776
 				$last_update_day = $last_update[0]['value'];
2449
-			} else $last_update_day = '2012-12-12 12:12:12';
2777
+			} else {
2778
+				$last_update_day = '2012-12-12 12:12:12';
2779
+			}
2450 2780
 			$reset = false;
2451 2781
 			$Tracker = new Tracker($this->db);
2452 2782
 			if ($Connection->tableExists('countries')) {
2453
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2783
+				if ($globalDebug) {
2784
+					echo 'Count all trackers by countries...'."\n";
2785
+				}
2454 2786
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2455 2787
 				foreach ($alldata as $number) {
2456 2788
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2457 2789
 				}
2458 2790
 			}
2459
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2791
+			if ($globalDebug) {
2792
+				echo 'Count all vessels by months...'."\n";
2793
+			}
2460 2794
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2461 2795
 			$filter_last_month = array('since_date' => $last_month);
2462 2796
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2463 2797
 			$lastyear = false;
2464 2798
 			foreach ($alldata as $number) {
2465
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2799
+				if ($number['year_name'] != date('Y')) {
2800
+					$lastyear = true;
2801
+				}
2466 2802
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2467 2803
 			}
2468 2804
 			echo 'Tracker data...'."\n";
@@ -2499,10 +2835,14 @@  discard block
 block discarded – undo
2499 2835
 
2500 2836
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2501 2837
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2502
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2838
+			if ($globalDebug) {
2839
+				echo '!!! Update aicraft stats !!!'."\n";
2840
+			}
2503 2841
 			if (isset($last_update[0]['value'])) {
2504 2842
 				$last_update_day = $last_update[0]['value'];
2505
-			} else $last_update_day = '2012-12-12 12:12:12';
2843
+			} else {
2844
+				$last_update_day = '2012-12-12 12:12:12';
2845
+			}
2506 2846
 			$reset = false;
2507 2847
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2508 2848
 			if ($globalStatsResetYear) {
@@ -2511,43 +2851,63 @@  discard block
 block discarded – undo
2511 2851
 			}
2512 2852
 			$Spotter = new Spotter($this->db);
2513 2853
 
2514
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2854
+			if ($globalDebug) {
2855
+				echo 'Count all aircraft types...'."\n";
2856
+			}
2515 2857
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2516 2858
 			foreach ($alldata as $number) {
2517 2859
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2518 2860
 			}
2519
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2861
+			if ($globalDebug) {
2862
+				echo 'Count all airlines...'."\n";
2863
+			}
2520 2864
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2521 2865
 			foreach ($alldata as $number) {
2522 2866
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2523 2867
 			}
2524
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2868
+			if ($globalDebug) {
2869
+				echo 'Count all registrations...'."\n";
2870
+			}
2525 2871
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2526 2872
 			foreach ($alldata as $number) {
2527 2873
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2528 2874
 			}
2529
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2875
+			if ($globalDebug) {
2876
+				echo 'Count all callsigns...'."\n";
2877
+			}
2530 2878
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2531 2879
 			foreach ($alldata as $number) {
2532 2880
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2533 2881
 			}
2534
-			if ($globalDebug) echo 'Count all owners...'."\n";
2882
+			if ($globalDebug) {
2883
+				echo 'Count all owners...'."\n";
2884
+			}
2535 2885
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2536 2886
 			foreach ($alldata as $number) {
2537 2887
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2538 2888
 			}
2539
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2889
+			if ($globalDebug) {
2890
+				echo 'Count all pilots...'."\n";
2891
+			}
2540 2892
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2541 2893
 			foreach ($alldata as $number) {
2542
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2894
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2895
+					$number['pilot_id'] = $number['pilot_name'];
2896
+				}
2543 2897
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2544 2898
 			}
2545 2899
 			
2546
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2900
+			if ($globalDebug) {
2901
+				echo 'Count all departure airports...'."\n";
2902
+			}
2547 2903
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2548
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2904
+			if ($globalDebug) {
2905
+				echo 'Count all detected departure airports...'."\n";
2906
+			}
2549 2907
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2550
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2908
+			if ($globalDebug) {
2909
+				echo 'Order departure airports...'."\n";
2910
+			}
2551 2911
 			$alldata = array();
2552 2912
 			foreach ($pall as $value) {
2553 2913
 				$icao = $value['airport_departure_icao'];
@@ -2557,7 +2917,9 @@  discard block
 block discarded – undo
2557 2917
 				$icao = $value['airport_departure_icao'];
2558 2918
 				if (isset($alldata[$icao])) {
2559 2919
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2560
-				} else $alldata[$icao] = $value;
2920
+				} else {
2921
+					$alldata[$icao] = $value;
2922
+				}
2561 2923
 			}
2562 2924
 			$count = array();
2563 2925
 			foreach ($alldata as $key => $row) {
@@ -2567,11 +2929,17 @@  discard block
 block discarded – undo
2567 2929
 			foreach ($alldata as $number) {
2568 2930
 				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);
2569 2931
 			}
2570
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2932
+			if ($globalDebug) {
2933
+				echo 'Count all arrival airports...'."\n";
2934
+			}
2571 2935
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2572
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2936
+			if ($globalDebug) {
2937
+				echo 'Count all detected arrival airports...'."\n";
2938
+			}
2573 2939
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2574
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2940
+			if ($globalDebug) {
2941
+				echo 'Order arrival airports...'."\n";
2942
+			}
2575 2943
 			$alldata = array();
2576 2944
 			foreach ($pall as $value) {
2577 2945
 				$icao = $value['airport_arrival_icao'];
@@ -2581,7 +2949,9 @@  discard block
 block discarded – undo
2581 2949
 				$icao = $value['airport_arrival_icao'];
2582 2950
 				if (isset($alldata[$icao])) {
2583 2951
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2584
-				} else $alldata[$icao] = $value;
2952
+				} else {
2953
+					$alldata[$icao] = $value;
2954
+				}
2585 2955
 			}
2586 2956
 			$count = array();
2587 2957
 			foreach ($alldata as $key => $row) {
@@ -2592,7 +2962,9 @@  discard block
 block discarded – undo
2592 2962
 				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);
2593 2963
 			}
2594 2964
 			if ($Connection->tableExists('countries')) {
2595
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2965
+				if ($globalDebug) {
2966
+					echo 'Count all flights by countries...'."\n";
2967
+				}
2596 2968
 				//$SpotterArchive = new SpotterArchive();
2597 2969
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2598 2970
 				$Spotter = new Spotter($this->db);
@@ -2603,7 +2975,9 @@  discard block
 block discarded – undo
2603 2975
 			}
2604 2976
 			
2605 2977
 			if (isset($globalAccidents) && $globalAccidents) {
2606
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2978
+				if ($globalDebug) {
2979
+					echo 'Count fatalities stats...'."\n";
2980
+				}
2607 2981
 				$Accident = new Accident($this->db);
2608 2982
 				$this->deleteStatsByType('fatalities_byyear');
2609 2983
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2619,48 +2993,68 @@  discard block
 block discarded – undo
2619 2993
 
2620 2994
 			// Add by month using getstat if month finish...
2621 2995
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2622
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2996
+			if ($globalDebug) {
2997
+				echo 'Count all flights by months...'."\n";
2998
+			}
2623 2999
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2624 3000
 			$filter_last_month = array('since_date' => $last_month);
2625 3001
 			$Spotter = new Spotter($this->db);
2626 3002
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2627 3003
 			$lastyear = false;
2628 3004
 			foreach ($alldata as $number) {
2629
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3005
+				if ($number['year_name'] != date('Y')) {
3006
+					$lastyear = true;
3007
+				}
2630 3008
 				$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'])));
2631 3009
 			}
2632
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
3010
+			if ($globalDebug) {
3011
+				echo 'Count all military flights by months...'."\n";
3012
+			}
2633 3013
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2634 3014
 			foreach ($alldata as $number) {
2635 3015
 				$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'])));
2636 3016
 			}
2637
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
3017
+			if ($globalDebug) {
3018
+				echo 'Count all owners by months...'."\n";
3019
+			}
2638 3020
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2639 3021
 			foreach ($alldata as $number) {
2640 3022
 				$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'])));
2641 3023
 			}
2642
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
3024
+			if ($globalDebug) {
3025
+				echo 'Count all pilots by months...'."\n";
3026
+			}
2643 3027
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2644 3028
 			foreach ($alldata as $number) {
2645 3029
 				$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'])));
2646 3030
 			}
2647
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
3031
+			if ($globalDebug) {
3032
+				echo 'Count all airlines by months...'."\n";
3033
+			}
2648 3034
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2649 3035
 			foreach ($alldata as $number) {
2650 3036
 				$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'])));
2651 3037
 			}
2652
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3038
+			if ($globalDebug) {
3039
+				echo 'Count all aircrafts by months...'."\n";
3040
+			}
2653 3041
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2654 3042
 			foreach ($alldata as $number) {
2655 3043
 				$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'])));
2656 3044
 			}
2657
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3045
+			if ($globalDebug) {
3046
+				echo 'Count all real arrivals by months...'."\n";
3047
+			}
2658 3048
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2659 3049
 			foreach ($alldata as $number) {
2660 3050
 				$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'])));
2661 3051
 			}
2662
-			if ($globalDebug) echo 'Airports data...'."\n";
2663
-			if ($globalDebug) echo '...Departure'."\n";
3052
+			if ($globalDebug) {
3053
+				echo 'Airports data...'."\n";
3054
+			}
3055
+			if ($globalDebug) {
3056
+				echo '...Departure'."\n";
3057
+			}
2664 3058
 			$this->deleteStatAirport('daily');
2665 3059
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2666 3060
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2778,7 +3172,9 @@  discard block
 block discarded – undo
2778 3172
 			// Count by airlines
2779 3173
 			echo '--- Stats by airlines ---'."\n";
2780 3174
 			if ($Connection->tableExists('countries')) {
2781
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3175
+				if ($globalDebug) {
3176
+					echo 'Count all flights by countries by airlines...'."\n";
3177
+				}
2782 3178
 				$SpotterArchive = new SpotterArchive($this->db);
2783 3179
 				//$Spotter = new Spotter($this->db);
2784 3180
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2787,37 +3183,53 @@  discard block
 block discarded – undo
2787 3183
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2788 3184
 				}
2789 3185
 			}
2790
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3186
+			if ($globalDebug) {
3187
+				echo 'Count all aircraft types by airlines...'."\n";
3188
+			}
2791 3189
 			$Spotter = new Spotter($this->db);
2792 3190
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2793 3191
 			foreach ($alldata as $number) {
2794 3192
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2795 3193
 			}
2796
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3194
+			if ($globalDebug) {
3195
+				echo 'Count all aircraft registrations by airlines...'."\n";
3196
+			}
2797 3197
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2798 3198
 			foreach ($alldata as $number) {
2799 3199
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2800 3200
 			}
2801
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3201
+			if ($globalDebug) {
3202
+				echo 'Count all callsigns by airlines...'."\n";
3203
+			}
2802 3204
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2803 3205
 			foreach ($alldata as $number) {
2804 3206
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2805 3207
 			}
2806
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3208
+			if ($globalDebug) {
3209
+				echo 'Count all owners by airlines...'."\n";
3210
+			}
2807 3211
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2808 3212
 			foreach ($alldata as $number) {
2809 3213
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2810 3214
 			}
2811
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3215
+			if ($globalDebug) {
3216
+				echo 'Count all pilots by airlines...'."\n";
3217
+			}
2812 3218
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2813 3219
 			foreach ($alldata as $number) {
2814 3220
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2815 3221
 			}
2816
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3222
+			if ($globalDebug) {
3223
+				echo 'Count all departure airports by airlines...'."\n";
3224
+			}
2817 3225
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2818
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3226
+			if ($globalDebug) {
3227
+				echo 'Count all detected departure airports by airlines...'."\n";
3228
+			}
2819 3229
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2820
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3230
+			if ($globalDebug) {
3231
+				echo 'Order detected departure airports by airlines...'."\n";
3232
+			}
2821 3233
 			//$alldata = array();
2822 3234
 			foreach ($dall as $value) {
2823 3235
 				$icao = $value['airport_departure_icao'];
@@ -2838,11 +3250,17 @@  discard block
 block discarded – undo
2838 3250
 			foreach ($alldata as $number) {
2839 3251
 				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);
2840 3252
 			}
2841
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3253
+			if ($globalDebug) {
3254
+				echo 'Count all arrival airports by airlines...'."\n";
3255
+			}
2842 3256
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2843
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3257
+			if ($globalDebug) {
3258
+				echo 'Count all detected arrival airports by airlines...'."\n";
3259
+			}
2844 3260
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2845
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3261
+			if ($globalDebug) {
3262
+				echo 'Order arrival airports by airlines...'."\n";
3263
+			}
2846 3264
 			//$alldata = array();
2847 3265
 			foreach ($dall as $value) {
2848 3266
 				$icao = $value['airport_arrival_icao'];
@@ -2861,37 +3279,53 @@  discard block
 block discarded – undo
2861 3279
 			}
2862 3280
 			$alldata = $pall;
2863 3281
 			foreach ($alldata as $number) {
2864
-				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);
3282
+				if ($number['airline_icao'] != '') {
3283
+					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);
3284
+				}
3285
+			}
3286
+			if ($globalDebug) {
3287
+				echo 'Count all flights by months by airlines...'."\n";
2865 3288
 			}
2866
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2867 3289
 			$Spotter = new Spotter($this->db);
2868 3290
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2869 3291
 			$lastyear = false;
2870 3292
 			foreach ($alldata as $number) {
2871
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3293
+				if ($number['year_name'] != date('Y')) {
3294
+					$lastyear = true;
3295
+				}
2872 3296
 				$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']);
2873 3297
 			}
2874
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3298
+			if ($globalDebug) {
3299
+				echo 'Count all owners by months by airlines...'."\n";
3300
+			}
2875 3301
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2876 3302
 			foreach ($alldata as $number) {
2877 3303
 				$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']);
2878 3304
 			}
2879
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3305
+			if ($globalDebug) {
3306
+				echo 'Count all pilots by months by airlines...'."\n";
3307
+			}
2880 3308
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2881 3309
 			foreach ($alldata as $number) {
2882 3310
 				$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']);
2883 3311
 			}
2884
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3312
+			if ($globalDebug) {
3313
+				echo 'Count all aircrafts by months by airlines...'."\n";
3314
+			}
2885 3315
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2886 3316
 			foreach ($alldata as $number) {
2887 3317
 				$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']);
2888 3318
 			}
2889
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3319
+			if ($globalDebug) {
3320
+				echo 'Count all real arrivals by months by airlines...'."\n";
3321
+			}
2890 3322
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2891 3323
 			foreach ($alldata as $number) {
2892 3324
 				$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']);
2893 3325
 			}
2894
-			if ($globalDebug) echo '...Departure'."\n";
3326
+			if ($globalDebug) {
3327
+				echo '...Departure'."\n";
3328
+			}
2895 3329
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2896 3330
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2897 3331
 			foreach ($dall as $value) {
@@ -2914,7 +3348,9 @@  discard block
 block discarded – undo
2914 3348
 			foreach ($alldata as $number) {
2915 3349
 				$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']);
2916 3350
 			}
2917
-			if ($globalDebug) echo '...Arrival'."\n";
3351
+			if ($globalDebug) {
3352
+				echo '...Arrival'."\n";
3353
+			}
2918 3354
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2919 3355
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2920 3356
 			foreach ($dall as $value) {
@@ -2938,13 +3374,19 @@  discard block
 block discarded – undo
2938 3374
 				$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']);
2939 3375
 			}
2940 3376
 
2941
-			if ($globalDebug) echo 'Flights data...'."\n";
2942
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3377
+			if ($globalDebug) {
3378
+				echo 'Flights data...'."\n";
3379
+			}
3380
+			if ($globalDebug) {
3381
+				echo '-> countAllDatesLastMonth...'."\n";
3382
+			}
2943 3383
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2944 3384
 			foreach ($alldata as $number) {
2945 3385
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2946 3386
 			}
2947
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3387
+			if ($globalDebug) {
3388
+				echo '-> countAllDates...'."\n";
3389
+			}
2948 3390
 			//$previousdata = $this->countAllDatesByAirlines();
2949 3391
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2950 3392
 			$values = array();
@@ -2957,14 +3399,18 @@  discard block
 block discarded – undo
2957 3399
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2958 3400
 			}
2959 3401
 			
2960
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3402
+			if ($globalDebug) {
3403
+				echo '-> countAllHours...'."\n";
3404
+			}
2961 3405
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2962 3406
 			foreach ($alldata as $number) {
2963 3407
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2964 3408
 			}
2965 3409
 
2966 3410
 			// Stats by filters
2967
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3411
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3412
+				$globalStatsFilters = array();
3413
+			}
2968 3414
 			foreach ($globalStatsFilters as $name => $filter) {
2969 3415
 				if (!empty($filter)) {
2970 3416
 					//$filter_name = $filter['name'];
@@ -2972,7 +3418,9 @@  discard block
 block discarded – undo
2972 3418
 					$reset = false;
2973 3419
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2974 3420
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2975
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3421
+						if ($globalDebug) {
3422
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3423
+						}
2976 3424
 						$this->deleteOldStats($filter_name);
2977 3425
 						unset($last_update);
2978 3426
 					}
@@ -2989,39 +3437,55 @@  discard block
 block discarded – undo
2989 3437
 						$reset = true;
2990 3438
 					}
2991 3439
 					// Count by filter
2992
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3440
+					if ($globalDebug) {
3441
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3442
+					}
2993 3443
 					$Spotter = new Spotter($this->db);
2994
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3444
+					if ($globalDebug) {
3445
+						echo 'Count all aircraft types...'."\n";
3446
+					}
2995 3447
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2996 3448
 					foreach ($alldata as $number) {
2997 3449
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2998 3450
 					}
2999
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3451
+					if ($globalDebug) {
3452
+						echo 'Count all airlines...'."\n";
3453
+					}
3000 3454
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3001 3455
 					foreach ($alldata as $number) {
3002 3456
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3003 3457
 					}
3004
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3458
+					if ($globalDebug) {
3459
+						echo 'Count all aircraft registrations...'."\n";
3460
+					}
3005 3461
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3006 3462
 					foreach ($alldata as $number) {
3007 3463
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3008 3464
 					}
3009
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3465
+					if ($globalDebug) {
3466
+						echo 'Count all callsigns...'."\n";
3467
+					}
3010 3468
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3011 3469
 					foreach ($alldata as $number) {
3012 3470
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3013 3471
 					}
3014
-					if ($globalDebug) echo 'Count all owners...'."\n";
3472
+					if ($globalDebug) {
3473
+						echo 'Count all owners...'."\n";
3474
+					}
3015 3475
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3016 3476
 					foreach ($alldata as $number) {
3017 3477
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3018 3478
 					}
3019
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3479
+					if ($globalDebug) {
3480
+						echo 'Count all pilots...'."\n";
3481
+					}
3020 3482
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3021 3483
 					foreach ($alldata as $number) {
3022 3484
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3023 3485
 					}
3024
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3486
+					if ($globalDebug) {
3487
+						echo 'Count departure airports...'."\n";
3488
+					}
3025 3489
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3026 3490
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3027 3491
 					$alldata = array();
@@ -3033,7 +3497,9 @@  discard block
 block discarded – undo
3033 3497
 						$icao = $value['airport_departure_icao'];
3034 3498
 						if (isset($alldata[$icao])) {
3035 3499
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
3036
-						} else $alldata[$icao] = $value;
3500
+						} else {
3501
+							$alldata[$icao] = $value;
3502
+						}
3037 3503
 					}
3038 3504
 					$count = array();
3039 3505
 					foreach ($alldata as $key => $row) {
@@ -3043,7 +3509,9 @@  discard block
 block discarded – undo
3043 3509
 					foreach ($alldata as $number) {
3044 3510
 						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);
3045 3511
 					}
3046
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3512
+					if ($globalDebug) {
3513
+						echo 'Count all arrival airports...'."\n";
3514
+					}
3047 3515
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3048 3516
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3049 3517
 					$alldata = array();
@@ -3055,7 +3523,9 @@  discard block
 block discarded – undo
3055 3523
 						$icao = $value['airport_arrival_icao'];
3056 3524
 						if (isset($alldata[$icao])) {
3057 3525
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
3058
-						} else $alldata[$icao] = $value;
3526
+						} else {
3527
+							$alldata[$icao] = $value;
3528
+						}
3059 3529
 					}
3060 3530
 					$count = array();
3061 3531
 					foreach ($alldata as $key => $row) {
@@ -3065,35 +3535,49 @@  discard block
 block discarded – undo
3065 3535
 					foreach ($alldata as $number) {
3066 3536
 						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);
3067 3537
 					}
3068
-					if ($globalDebug) echo 'Count all months...'."\n";
3538
+					if ($globalDebug) {
3539
+						echo 'Count all months...'."\n";
3540
+					}
3069 3541
 					$Spotter = new Spotter($this->db);
3070 3542
 					$alldata = $Spotter->countAllMonths($filter);
3071 3543
 					$lastyear = false;
3072 3544
 					foreach ($alldata as $number) {
3073
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3545
+						if ($number['year_name'] != date('Y')) {
3546
+							$lastyear = true;
3547
+						}
3074 3548
 						$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);
3075 3549
 					}
3076
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3550
+					if ($globalDebug) {
3551
+						echo 'Count all owners by months...'."\n";
3552
+					}
3077 3553
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3078 3554
 					foreach ($alldata as $number) {
3079 3555
 						$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);
3080 3556
 					}
3081
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3557
+					if ($globalDebug) {
3558
+						echo 'Count all pilots by months...'."\n";
3559
+					}
3082 3560
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3083 3561
 					foreach ($alldata as $number) {
3084 3562
 						$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);
3085 3563
 					}
3086
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3564
+					if ($globalDebug) {
3565
+						echo 'Count all military by months...'."\n";
3566
+					}
3087 3567
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3088 3568
 					foreach ($alldata as $number) {
3089 3569
 						$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);
3090 3570
 					}
3091
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3571
+					if ($globalDebug) {
3572
+						echo 'Count all aircrafts by months...'."\n";
3573
+					}
3092 3574
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3093 3575
 				    	foreach ($alldata as $number) {
3094 3576
 			    			$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);
3095 3577
 					}
3096
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3578
+					if ($globalDebug) {
3579
+						echo 'Count all real arrivals by months...'."\n";
3580
+					}
3097 3581
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3098 3582
 					foreach ($alldata as $number) {
3099 3583
 						$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);
Please login to merge, or discard this patch.
statistics.php 2 patches
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 }
24 24
 
25 25
 if (!isset($filter_name)) $filter_name = '';
26
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
26
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
27 27
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28 28
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29 29
 }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33 33
 	if (isset($airline_info[0]['name'])) {
34 34
 		$airline_name = $airline_info[0]['name'];
35
-	} elseif (strpos($airline_icao,'alliance_') !== FALSE) {
35
+	} elseif (strpos($airline_icao, 'alliance_') !== FALSE) {
36 36
 		$alliance_name = $airline_icao;
37 37
 	}
38 38
 }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	$title = _("Statistics");
43 43
 }
44 44
 
45
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
45
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 
48 48
 require_once('header.php');
49 49
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	date_default_timezone_set('UTC');
75 75
 	$lastupdate = strtotime($last_update[0]['value']);
76 76
 	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
77
-	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
77
+	print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
78 78
 }
79 79
 
80 80
 ?>
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
 <?php
87 87
 if ($type == 'aircraft') {
88 88
 ?>
89
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
90
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
90
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
93 93
 <?php
94 94
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
95 95
 ?>
96
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
97
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
97
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
98 98
 <?php
99 99
 	}
100 100
 	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
101 101
 ?>
102
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
103
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
102
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
103
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
104 104
 <?php
105 105
 	}
106 106
 ?>
107
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
107
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
109 109
 <?php
110 110
 	if ($airline_icao == '') {
111 111
 ?>
112
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
113
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
112
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
113
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
114 114
 <?php
115 115
 	}
116 116
 ?>
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
119 119
 		if ($airline_icao == '' || $airline_icao == 'all') {
120 120
 ?>
121
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
122
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
121
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
122
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
123 123
 <?php
124 124
 		}
125 125
 	}
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
 <?php
128 128
 } elseif ($type == 'marine') {
129 129
 ?>
130
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
131
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
132
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
133
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
131
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
132
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name, $year, $month)); ?></span> <?php echo _("Types"); ?></span>
133
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
134 134
 <?php
135 135
 } elseif ($type == 'tracker') {
136 136
 ?>
137
-	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
138
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
139
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
140
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137
+	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
138
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
139
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
140
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
141 141
 <?php
142 142
 }
143 143
 ?>
144 144
     </p>
145
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
145
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
146 146
     <div class="specific-stats">
147 147
 <?php
148 148
 if ($type == 'aircraft') {
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
             <div class="col-md-6">
152 152
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
153 153
 <?php
154
-	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
154
+	$aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
155 155
 	if (count($aircraft_array) == 0) {
156 156
 		print _("No data available");
157 157
 	} else {
158 158
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 159
 		$aircraft_data = '';
160
-		foreach($aircraft_array as $aircraft_item) {
160
+		foreach ($aircraft_array as $aircraft_item) {
161 161
 			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162 162
 			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
163 163
 		}
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
 ?>
187 187
                 </div>
188 188
             </div>
189
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
189
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
190 190
 <?php
191 191
 	if ($airline_icao == '' || $airline_icao == 'all') {
192
-		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
192
+		$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
193 193
 		if (count($airline_array) > 0) {
194 194
 			print '<div class="col-md-6">';
195 195
 			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
196 196
 			print '<div id="chart2" class="chart" width="100%"></div><script>';
197 197
 			$airline_data = '';
198
-			foreach($airline_array as $airline_item) {
198
+			foreach ($airline_array as $airline_item) {
199 199
 				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
200 200
 			}
201 201
 			$airline_data = substr($airline_data, 0, -1);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 ?>
222 222
         </div>
223
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
223
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
224 224
 <?php
225 225
 	}
226 226
 }
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
             <div class="col-md-6">
233 233
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 234
 <?php
235
-	$marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
235
+	$marine_array = $Stats->countAllMarineTypes(true, $filter_name, $year, $month);
236 236
 	if (count($marine_array) == 0) print _("No data available");
237 237
 	else {
238 238
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 239
 		$marine_data = '';
240
-		foreach($marine_array as $marine_item) {
240
+		foreach ($marine_array as $marine_item) {
241 241
 			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
242 242
 		}
243 243
 		$marine_data = substr($marine_data, 0, -1);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             	    ?>
267 267
                 </div>
268 268
             </div>
269
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
269
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
270 270
 <!--	</div>-->
271 271
 <?php
272 272
 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
             <div class="col-md-6">
277 277
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 278
 <?php
279
-	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
279
+	$tracker_array = $Tracker->countAllTrackerTypes(true, 0, '', array(), $year, $month);
280 280
 	if (count($tracker_array) == 0) print _("No data available");
281 281
 	else {
282 282
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 283
 		$tracker_data = '';
284
-		foreach($tracker_array as $tracker_item) {
284
+		foreach ($tracker_array as $tracker_item) {
285 285
 			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
286 286
 		}
287 287
 		$tracker_data = substr($tracker_data, 0, -1);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             	    ?>
312 312
                 </div>
313 313
             </div>
314
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
314
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
315 315
 <!--	</div>-->
316 316
 <?php
317 317
 }
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		else {
327 327
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 328
 			$owner_data = '';
329
-			foreach($owner_array as $owner_item) {
329
+			foreach ($owner_array as $owner_item) {
330 330
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
331 331
 			}
332 332
 			$owner_data = substr($owner_data, 0, -1);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                 </div>
347 347
                 -->
348 348
             </div>
349
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
349
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
350 350
             <div class="col-md-6">
351 351
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 352
 <?php
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		else {
356 356
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 357
 			$owner_data = '';
358
-			foreach($countries_array as $owner_item) {
358
+			foreach ($countries_array as $owner_item) {
359 359
 				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
360 360
 			}
361 361
 			$owner_data = substr($owner_data, 0, -1);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 -->
377 377
             </div>
378 378
             
379
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
379
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
380 380
 ²	</div>
381 381
         <div class="row column">
382 382
             <div class="col-md-6">
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		else {
388 388
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 389
 			$launch_site_data = '';
390
-			foreach($launch_site_array as $launch_site_item) {
390
+			foreach ($launch_site_array as $launch_site_item) {
391 391
 				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
392 392
 			}
393 393
 			$launch_site_data = substr($launch_site_data, 0, -1);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 ?>
415 415
         <div class="row column">
416 416
 <?php
417
-	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
417
+	$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
418 418
 	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
419 419
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
420 420
 		if (empty($flightover_array)) {
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 ?>
426 426
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 427
 <?php
428
-		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
428
+		$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
429 429
 		if (count($pilot_array) == 0) print _("No data available");
430 430
 		else {
431 431
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 432
 			$pilot_data = '';
433
-			foreach($pilot_array as $pilot_item) {
433
+			foreach ($pilot_array as $pilot_item) {
434 434
 				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
435 435
 			}
436 436
 			$pilot_data = substr($pilot_data, 0, -1);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 ?>
452 452
             </div>
453 453
 
454
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
454
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
455 455
 <?php
456 456
 	}
457 457
 	// else {
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
             <div class="col-md-6">
461 461
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 462
 <?php
463
-		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
463
+		$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
464 464
 		if (count($owner_array) == 0) print _("No data available");
465 465
 		else {
466 466
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 467
 			$owner_data = '';
468
-			foreach($owner_array as $owner_item) {
468
+			foreach ($owner_array as $owner_item) {
469 469
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
470 470
 			}
471 471
 			$owner_data = substr($owner_data, 0, -1);
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                 </div>
485 485
             </div>
486 486
         
487
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
487
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
488 488
 <?php
489 489
 	}
490 490
 	if (!empty($flightover_array)) {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 499
 			print 'var series = [';
500 500
 			$flightover_data = '';
501
-			foreach($flightover_array as $flightover_item) {
501
+			foreach ($flightover_array as $flightover_item) {
502 502
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
503 503
 			}
504 504
 			$flightover_data = substr($flightover_data, 0, -1);
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
 	}
544 544
 ?>
545 545
         </div>
546
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
546
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
547 547
         </div>
548 548
 <?php
549 549
 }
550 550
 if ($type == 'marine') {
551
-	$flightover_array = $Stats->countAllMarineOverCountries(true,$filter_name,$year,$month);
551
+	$flightover_array = $Stats->countAllMarineOverCountries(true, $filter_name, $year, $month);
552 552
 ?>
553 553
 <!--    <div class="row column">-->
554 554
 	<div class="col-md-6">
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 560
 		print 'var series = [';
561 561
 		$flightover_data = '';
562
-		foreach($flightover_array as $flightover_item) {
562
+		foreach ($flightover_array as $flightover_item) {
563 563
 			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
564 564
 		}
565 565
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
                 <div class="more">
600 600
                     <a href="<?php print $globalURL; ?>/marine/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
601 601
                 </div>
602
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
602
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
603 603
             </div>
604 604
         </div>
605 605
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 618
 		print 'var series = [';
619 619
 		$flightover_data = '';
620
-		foreach($flightover_array as $flightover_item) {
620
+		foreach ($flightover_array as $flightover_item) {
621 621
 			$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
622 622
 		}
623 623
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -667,14 +667,14 @@  discard block
 block discarded – undo
667 667
         <div class="row column">
668 668
             <div class="col-md-6">
669 669
 <?php
670
-	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
670
+	$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
671 671
 	if (count($airport_airport_array) > 0) {
672 672
 		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
673 673
 		print '<div id="chart3" class="chart" width="100%"></div><script>';
674 674
 		print "\n";
675 675
 		print 'var series = [';
676 676
 		$airport_data = '';
677
-		foreach($airport_airport_array as $airport_item) {
677
+		foreach ($airport_airport_array as $airport_item) {
678 678
 			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
679 679
 		}
680 680
 		$airport_data = substr($airport_data, 0, -1);
@@ -724,18 +724,18 @@  discard block
 block discarded – undo
724 724
 	}
725 725
 ?>
726 726
             </div>
727
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
727
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
728 728
 
729 729
             <div class="col-md-6">
730 730
 <?php
731
-	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
731
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
732 732
 	if (count($airport_airport_array2) > 0) {
733 733
 		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
734 734
 		print '<div id="chart4" class="chart" width="100%"></div><script>';
735 735
 		print "\n";
736 736
 		print 'var series = [';
737 737
 		$airport_data = '';
738
-		foreach($airport_airport_array2 as $airport_item)
738
+		foreach ($airport_airport_array2 as $airport_item)
739 739
 		{
740 740
 			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
741 741
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 ?>
790 790
             </div>
791 791
         </div>
792
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
792
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
793 793
 <?php 
794 794
 }
795 795
 if ($type == 'aircraft') {
@@ -801,18 +801,18 @@  discard block
 block discarded – undo
801 801
             <div class="col-md-6">
802 802
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
803 803
 <?php
804
-		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
804
+		$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
805 805
 		if (count($year_array) == 0) print _("No data available");
806 806
 		else {
807 807
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
808 808
 			$year_data = '';
809 809
 			$year_cnt = '';
810
-			foreach($year_array as $year_item) {
810
+			foreach ($year_array as $year_item) {
811 811
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
812 812
 				$year_cnt .= $year_item['date_count'].',';
813 813
 			}
814 814
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
815
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
815
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
816 816
 			print 'c3.generate({
817 817
 			    bindto: "#chart8",
818 818
 			    data: { x: "x",
@@ -825,22 +825,22 @@  discard block
 block discarded – undo
825 825
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
826 826
                 </div>
827 827
             </div>
828
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
828
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
829 829
             <div class="col-md-6">
830 830
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
831 831
 <?php
832
-		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
832
+		$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
833 833
 		if (count($month_array) == 0) print _("No data available");
834 834
 		else {
835 835
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
836 836
 			$month_data = '';
837 837
 			$month_cnt = '';
838
-			foreach($month_array as $month_item) {
838
+			foreach ($month_array as $month_item) {
839 839
 				$month_data .= '"'.$month_item['date_name'].'",';
840 840
 				$month_cnt .= $month_item['date_count'].',';
841 841
 			}
842 842
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
843
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
843
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
844 844
 			print 'c3.generate({
845 845
 			    bindto: "#chart9",
846 846
 			    data: { x: "x",
@@ -853,23 +853,23 @@  discard block
 block discarded – undo
853 853
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
854 854
                 </div>
855 855
             </div>
856
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
856
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
857 857
 
858 858
             <div class="col-md-6">
859 859
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
860 860
 <?php
861
-		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
861
+		$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
862 862
 		if (empty($date_array)) print _("No data available");
863 863
 		else {
864 864
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
865 865
 			$date_data = '';
866 866
 			$date_cnt = '';
867
-			foreach($date_array as $date_item) {
867
+			foreach ($date_array as $date_item) {
868 868
 				$date_data .= '"'.$date_item['date_name'].'",';
869 869
 				$date_cnt .= $date_item['date_count'].',';
870 870
 			}
871 871
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
872
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
872
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
873 873
 			print 'c3.generate({
874 874
 			    bindto: "#chart5",
875 875
 			    data: { x: "x",
@@ -882,22 +882,22 @@  discard block
 block discarded – undo
882 882
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
883 883
                 </div>
884 884
             </div>
885
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
885
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
886 886
             <div class="col-md-6">
887 887
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
888 888
 <?php
889
-		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
889
+		$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
890 890
 		if (empty($hour_array)) print _("No data available");
891 891
 		else {
892 892
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
893 893
 			$hour_data = '';
894 894
 			$hour_cnt = '';
895
-			foreach($hour_array as $hour_item) {
895
+			foreach ($hour_array as $hour_item) {
896 896
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
897 897
 				$hour_cnt .= $hour_item['hour_count'].',';
898 898
 			}
899 899
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
900
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
900
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
901 901
 			print 'c3.generate({
902 902
 			    bindto: "#chart6",
903 903
 			    data: {
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911 911
                 </div>
912 912
             </div>
913
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
913
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
914 914
         </div>
915 915
 <?php
916 916
 	}
@@ -926,18 +926,18 @@  discard block
 block discarded – undo
926 926
             <div class="col-md-6">
927 927
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
928 928
 <?php
929
-		$year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name);
929
+		$year_array = $Stats->countAllMarineMonthsLastYear(true, $filter_name);
930 930
 		if (count($year_array) == 0) print _("No data available");
931 931
 		else {
932 932
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
933 933
 			$year_data = '';
934 934
 			$year_cnt = '';
935
-			foreach($year_array as $year_item) {
935
+			foreach ($year_array as $year_item) {
936 936
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
937 937
 				$year_cnt .= $year_item['date_count'].',';
938 938
 			}
939 939
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
940
-			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
940
+			$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
941 941
 			print 'c3.generate({
942 942
 			    bindto: "#chart8",
943 943
 			    data: { x: "x",
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
                 </div>
952 952
             </div>
953 953
             
954
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
954
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
955 955
             <div class="col-md-6">
956 956
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
957 957
 <?php
@@ -961,12 +961,12 @@  discard block
 block discarded – undo
961 961
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
962 962
 			$month_data = '';
963 963
 			$month_cnt = '';
964
-			foreach($month_array as $month_item) {
964
+			foreach ($month_array as $month_item) {
965 965
 				$month_data .= '"'.$month_item['date_name'].'",';
966 966
 				$month_cnt .= $month_item['date_count'].',';
967 967
 			}
968 968
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
969
-			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
969
+			$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
970 970
 			print 'c3.generate({
971 971
 			    bindto: "#chart9",
972 972
 			    data: { x: "x",
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
980 980
                 </div>
981 981
             </div>
982
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
982
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
983 983
 
984 984
             <div class="col-md-6">
985 985
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -990,12 +990,12 @@  discard block
 block discarded – undo
990 990
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
991 991
 			$date_data = '';
992 992
 			$date_cnt = '';
993
-			foreach($date_array as $date_item) {
993
+			foreach ($date_array as $date_item) {
994 994
 				$date_data .= '"'.$date_item['date_name'].'",';
995 995
 				$date_cnt .= $date_item['date_count'].',';
996 996
 			}
997 997
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
998
-			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
998
+			$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
999 999
 			print 'c3.generate({
1000 1000
 			    bindto: "#chart5",
1001 1001
 			    data: { x: "x",
@@ -1008,22 +1008,22 @@  discard block
 block discarded – undo
1008 1008
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1009 1009
                 </div>
1010 1010
             </div>
1011
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1011
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1012 1012
             <div class="col-md-6">
1013 1013
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1014 1014
 <?php
1015
-		$hour_array = $Stats->countAllMarineHours('hour',true,$filter_name);
1015
+		$hour_array = $Stats->countAllMarineHours('hour', true, $filter_name);
1016 1016
 		if (empty($hour_array)) print _("No data available");
1017 1017
 		else {
1018 1018
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1019 1019
 			$hour_data = '';
1020 1020
 			$hour_cnt = '';
1021
-			foreach($hour_array as $hour_item) {
1021
+			foreach ($hour_array as $hour_item) {
1022 1022
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1023 1023
 				$hour_cnt .= $hour_item['hour_count'].',';
1024 1024
 			}
1025 1025
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1026
-			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1026
+			$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
1027 1027
 			print 'c3.generate({
1028 1028
 			    bindto: "#chart6",
1029 1029
 			    data: {
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1037 1037
                 </div>
1038 1038
             </div>
1039
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1039
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1040 1040
         </div>
1041 1041
 <?php
1042 1042
 	}
@@ -1058,12 +1058,12 @@  discard block
 block discarded – undo
1058 1058
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1059 1059
 			$year_data = '';
1060 1060
 			$year_cnt = '';
1061
-			foreach($year_array as $year_item) {
1061
+			foreach ($year_array as $year_item) {
1062 1062
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1063 1063
 				$year_cnt .= $year_item['date_count'].',';
1064 1064
 			}
1065 1065
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1066
-			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1066
+			$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
1067 1067
 			print 'c3.generate({
1068 1068
 			    bindto: "#chart8",
1069 1069
 			    data: { x: "x",
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
                 </div>
1078 1078
             </div>
1079 1079
             
1080
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1080
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1081 1081
             <div class="col-md-6">
1082 1082
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1083 1083
 <?php
@@ -1087,12 +1087,12 @@  discard block
 block discarded – undo
1087 1087
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1088 1088
 			$month_data = '';
1089 1089
 			$month_cnt = '';
1090
-			foreach($month_array as $month_item) {
1090
+			foreach ($month_array as $month_item) {
1091 1091
 				$month_data .= '"'.$month_item['date_name'].'",';
1092 1092
 				$month_cnt .= $month_item['date_count'].',';
1093 1093
 			}
1094 1094
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
1095
-			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1095
+			$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1096 1096
 			print 'c3.generate({
1097 1097
 			    bindto: "#chart9",
1098 1098
 			    data: { x: "x",
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1106 1106
                 </div>
1107 1107
             </div>
1108
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1108
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1109 1109
 
1110 1110
             <div class="col-md-6">
1111 1111
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1116,12 +1116,12 @@  discard block
 block discarded – undo
1116 1116
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1117 1117
 			$date_data = '';
1118 1118
 			$date_cnt = '';
1119
-			foreach($date_array as $date_item) {
1119
+			foreach ($date_array as $date_item) {
1120 1120
 				$date_data .= '"'.$date_item['date_name'].'",';
1121 1121
 				$date_cnt .= $date_item['date_count'].',';
1122 1122
 			}
1123 1123
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
1124
-			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1124
+			$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1125 1125
 			print 'c3.generate({
1126 1126
 			    bindto: "#chart5",
1127 1127
 			    data: { x: "x",
@@ -1134,22 +1134,22 @@  discard block
 block discarded – undo
1134 1134
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1135 1135
                 </div>
1136 1136
             </div>
1137
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1137
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1138 1138
             <div class="col-md-6">
1139 1139
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1140 1140
 <?php
1141
-		$hour_array = $Tracker->countAllHours('hour',true);
1141
+		$hour_array = $Tracker->countAllHours('hour', true);
1142 1142
 		if (empty($hour_array)) print _("No data available");
1143 1143
 		else {
1144 1144
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1145 1145
 			$hour_data = '';
1146 1146
 			$hour_cnt = '';
1147
-			foreach($hour_array as $hour_item) {
1147
+			foreach ($hour_array as $hour_item) {
1148 1148
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1149 1149
 				$hour_cnt .= $hour_item['hour_count'].',';
1150 1150
 			}
1151 1151
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1152
-			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1152
+			$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1153 1153
 			print 'c3.generate({
1154 1154
 			    bindto: "#chart6",
1155 1155
 			    data: {
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1163 1163
                 </div>
1164 1164
             </div>
1165
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1165
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1166 1166
         </div>
1167 1167
 <?php
1168 1168
 	}
@@ -1184,12 +1184,12 @@  discard block
 block discarded – undo
1184 1184
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1185 1185
 			$year_data = '';
1186 1186
 			$year_cnt = '';
1187
-			foreach($year_array as $year_item) {
1187
+			foreach ($year_array as $year_item) {
1188 1188
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1189 1189
 				$year_cnt .= $year_item['date_count'].',';
1190 1190
 			}
1191 1191
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1192
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1192
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1193 1193
 			print 'c3.generate({
1194 1194
 			    bindto: "#chart21",
1195 1195
 			    data: { x: "x",
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
             -->
1206 1206
             </div>
1207 1207
             
1208
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1208
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1209 1209
             <div class="col-md-6">
1210 1210
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1211 1211
 <?php
@@ -1215,12 +1215,12 @@  discard block
 block discarded – undo
1215 1215
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1216 1216
 			$year_data = '';
1217 1217
 			$year_cnt = '';
1218
-			foreach($year_array as $year_item) {
1218
+			foreach ($year_array as $year_item) {
1219 1219
 				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1220 1220
 				$year_cnt .= $year_item['date_count'].',';
1221 1221
 			}
1222 1222
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1223
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1223
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1224 1224
 			print 'c3.generate({
1225 1225
 			    bindto: "#chart22",
1226 1226
 			    data: { x: "x",
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
             -->
1237 1237
             </div>
1238 1238
             
1239
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1239
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1240 1240
         </div>
1241 1241
 <?php
1242 1242
 	}
@@ -1258,12 +1258,12 @@  discard block
 block discarded – undo
1258 1258
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1259 1259
 			$year_data = '';
1260 1260
 			$year_cnt = '';
1261
-			foreach($year_array as $year_item) {
1261
+			foreach ($year_array as $year_item) {
1262 1262
 				$year_data .= '"'.$year_item['year'].'-01-01",';
1263 1263
 				$year_cnt .= $year_item['count'].',';
1264 1264
 			}
1265 1265
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1266
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1266
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1267 1267
 			print 'c3.generate({
1268 1268
 			    bindto: "#chart32",
1269 1269
 			    data: { x: "x",
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1277 1277
                 </div>
1278 1278
             </div>
1279
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1279
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1280 1280
 
1281 1281
         <div class="row column">
1282 1282
             <div class="col-md-6">
@@ -1288,12 +1288,12 @@  discard block
 block discarded – undo
1288 1288
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1289 1289
 			$year_data = '';
1290 1290
 			$year_cnt = '';
1291
-			foreach($year_array as $year_item) {
1291
+			foreach ($year_array as $year_item) {
1292 1292
 				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1293 1293
 				$year_cnt .= $year_item['count'].',';
1294 1294
 			}
1295 1295
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1296
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1296
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1297 1297
 			print 'c3.generate({
1298 1298
 			    bindto: "#chart33",
1299 1299
 			    data: { x: "x",
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1307 1307
                 </div>
1308 1308
             </div>
1309
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1309
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1310 1310
 <br/>
1311 1311
 <?php
1312 1312
 	}
@@ -1320,19 +1320,19 @@  discard block
 block discarded – undo
1320 1320
 	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1321 1321
 	if ($year == '' && $month == '') {
1322 1322
 		if ($type == 'aircraft') {
1323
-			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1323
+			$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1324 1324
 		} elseif ($type == 'marine') {
1325
-			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1325
+			$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1326 1326
 		} elseif ($type == 'tracker') {
1327
-			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1327
+			$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1328 1328
 		}
1329 1329
 	} else {
1330 1330
 		if ($type == 'aircraft') {
1331
-			$polar = $Stats->getStatsSource('polar',$year,$month);
1331
+			$polar = $Stats->getStatsSource('polar', $year, $month);
1332 1332
 		} elseif ($type == 'marine') {
1333
-			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1333
+			$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1334 1334
 		} elseif ($type == 'tracker') {
1335
-			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1335
+			$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1336 1336
 		}
1337 1337
 	}
1338 1338
 	if (!empty($polar)) {
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 			unset($polar_data);
1342 1342
 			$Spotter = new Spotter();
1343 1343
 			$data = json_decode($eachpolar['source_data']);
1344
-			foreach($data as $value => $key) {
1344
+			foreach ($data as $value => $key) {
1345 1345
 				$direction = $Spotter->parseDirection(($value*22.5));
1346 1346
 				$distance = $key;
1347 1347
 				$unit = 'km';
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 ?>
1362 1362
             <div class="col-md-6">
1363 1363
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1364
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1364
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1365 1365
         	<script>
1366 1366
         	    (function() {
1367 1367
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		      color: color,
1386 1386
 		      unit: '<?php echo $unit; ?>'
1387 1387
 		    };
1388
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1388
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1389 1389
 		    })();
1390 1390
 		</script>
1391 1391
             </div>
@@ -1400,19 +1400,19 @@  discard block
 block discarded – undo
1400 1400
 	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1401 1401
 	if ($year == '' && $month == '') {
1402 1402
 		if ($type == 'aircraft') {
1403
-			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1403
+			$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1404 1404
 		} elseif ($type == 'marine') {
1405
-			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1405
+			$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1406 1406
 		} elseif ($type == 'tracker') {
1407
-			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1407
+			$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1408 1408
 		}
1409 1409
 	} else {
1410 1410
 		if ($type == 'aircraft') {
1411
-			$msg = $Stats->getStatsSource('msg',$year,$month);
1411
+			$msg = $Stats->getStatsSource('msg', $year, $month);
1412 1412
 		} elseif ($type == 'marine') {
1413
-			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1413
+			$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1414 1414
 		} elseif ($type == 'tracker') {
1415
-			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1415
+			$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1416 1416
 		}
1417 1417
 	}
1418 1418
 	if (!empty($msg)) {
@@ -1420,13 +1420,13 @@  discard block
 block discarded – undo
1420 1420
 		foreach ($msg as $eachmsg) {
1421 1421
 			//$eachmsg = $msg[0];
1422 1422
 			$data = $eachmsg['source_data'];
1423
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1423
+			if ($data > 500) $max = (round(($data + 100)/100))*100;
1424 1424
 			else $max = 500;
1425 1425
 ?>
1426
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1427 1427
         	<script>
1428 1428
 		      var g = new JustGage({
1429
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1429
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1430 1430
 			    value: <?php echo $data; ?>,
1431 1431
 			    min: 0,
1432 1432
 			    max: <?php print $max; ?>,
@@ -1448,19 +1448,19 @@  discard block
 block discarded – undo
1448 1448
 	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1449 1449
 	if ($year == '' && $month == '') {
1450 1450
 		if ($type == 'aircraft') {
1451
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1451
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1452 1452
 		} elseif ($type == 'marine') {
1453
-			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1453
+			$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1454 1454
 		} elseif ($type == 'tracker') {
1455
-			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1455
+			$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1456 1456
 		}
1457 1457
 	} else {
1458 1458
 		if ($type == 'aircraft') {
1459
-			$hist = $Stats->getStatsSource('hist',$year,$month);
1459
+			$hist = $Stats->getStatsSource('hist', $year, $month);
1460 1460
 		} elseif ($type == 'marine') {
1461
-			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1461
+			$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1462 1462
 		} elseif ($type == 'tracker') {
1463
-			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1463
+			$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1464 1464
 		}
1465 1465
 	}
1466 1466
 	foreach ($hist as $hists) {
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 		$source = $hists['source_name'];
1471 1471
 		$hist_array = json_decode($hists['source_data']);
1472 1472
 		$unit = 'km';
1473
-		foreach($hist_array as $distance => $nb) {
1473
+		foreach ($hist_array as $distance => $nb) {
1474 1474
 			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1475 1475
 				$distance = round($distance*0.539957);
1476 1476
 				$unit = 'nm';
@@ -1490,18 +1490,18 @@  discard block
 block discarded – undo
1490 1490
 		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1491 1491
 ?>
1492 1492
             <div class="col-md-6">
1493
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1493
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1494 1494
 <?php
1495
-		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1495
+		print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1496 1496
 		print 'c3.generate({
1497
-		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1497
+		    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1498 1498
 		    data: { x: "x",
1499 1499
 		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1500 1500
 		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1501 1501
 		print '</script>';
1502 1502
 ?>
1503 1503
     	    </div>
1504
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1504
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1505 1505
 <?php
1506 1506
 	}
1507 1507
 ?>
Please login to merge, or discard this patch.
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Stats->countAllMarineTypes(true,$filter_name,$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -277,8 +302,9 @@  discard block
 block discarded – undo
277 302
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 303
 <?php
279 304
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
-	if (count($tracker_array) == 0) print _("No data available");
281
-	else {
305
+	if (count($tracker_array) == 0) {
306
+		print _("No data available");
307
+	} else {
282 308
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 309
 		$tracker_data = '';
284 310
 		foreach($tracker_array as $tracker_item) {
@@ -322,8 +348,9 @@  discard block
 block discarded – undo
322 348
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323 349
 <?php
324 350
 		$owner_array = $Satellite->countAllOwners(true);
325
-		if (count($owner_array) == 0) print _("No data available");
326
-		else {
351
+		if (count($owner_array) == 0) {
352
+			print _("No data available");
353
+		} else {
327 354
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 355
 			$owner_data = '';
329 356
 			foreach($owner_array as $owner_item) {
@@ -342,7 +369,10 @@  discard block
 block discarded – undo
342 369
 ?>
343 370
                <!--
344 371
                 <div class="more">
345
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
373
+	echo '/'.$airline_icao;
374
+}
375
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
346 376
                 </div>
347 377
                 -->
348 378
             </div>
@@ -351,8 +381,9 @@  discard block
 block discarded – undo
351 381
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 382
 <?php
353 383
 		$countries_array = $Satellite->countAllCountriesOwners(true);
354
-		if (count($countries_array) == 0) print _("No data available");
355
-		else {
384
+		if (count($countries_array) == 0) {
385
+			print _("No data available");
386
+		} else {
356 387
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 388
 			$owner_data = '';
358 389
 			foreach($countries_array as $owner_item) {
@@ -371,7 +402,10 @@  discard block
 block discarded – undo
371 402
 ?>
372 403
 	    <!--
373 404
                 <div class="more">
374
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
405
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
406
+	echo '/'.$airline_icao;
407
+}
408
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
375 409
                 </div>
376 410
                 -->
377 411
             </div>
@@ -383,8 +417,9 @@  discard block
 block discarded – undo
383 417
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384 418
 <?php
385 419
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
-		if (count($launch_site_array) == 0) print _("No data available");
387
-		else {
420
+		if (count($launch_site_array) == 0) {
421
+			print _("No data available");
422
+		} else {
388 423
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 424
 			$launch_site_data = '';
390 425
 			foreach($launch_site_array as $launch_site_item) {
@@ -403,7 +438,10 @@  discard block
 block discarded – undo
403 438
 ?>
404 439
                <!--
405 440
                 <div class="more">
406
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
441
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
442
+	echo '/'.$airline_icao;
443
+}
444
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
407 445
                 </div>
408 446
                 -->
409 447
             </div>
@@ -426,8 +464,9 @@  discard block
 block discarded – undo
426 464
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 465
 <?php
428 466
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
-		if (count($pilot_array) == 0) print _("No data available");
430
-		else {
467
+		if (count($pilot_array) == 0) {
468
+			print _("No data available");
469
+		} else {
431 470
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 471
 			$pilot_data = '';
433 472
 			foreach($pilot_array as $pilot_item) {
@@ -445,7 +484,9 @@  discard block
 block discarded – undo
445 484
 		}
446 485
 		print '<div class="more">';
447 486
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
487
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
488
+			echo '/'.$airline_icao;
489
+		}
449 490
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450 491
 		print '</div>';
451 492
 ?>
@@ -461,8 +502,9 @@  discard block
 block discarded – undo
461 502
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 503
 <?php
463 504
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
-		if (count($owner_array) == 0) print _("No data available");
465
-		else {
505
+		if (count($owner_array) == 0) {
506
+			print _("No data available");
507
+		} else {
466 508
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 509
 			$owner_data = '';
468 510
 			foreach($owner_array as $owner_item) {
@@ -480,7 +522,10 @@  discard block
 block discarded – undo
480 522
 		}
481 523
 ?>
482 524
                 <div class="more">
483
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
526
+	echo '/'.$airline_icao;
527
+}
528
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
484 529
                 </div>
485 530
             </div>
486 531
         
@@ -493,8 +538,9 @@  discard block
 block discarded – undo
493 538
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494 539
 <?php
495 540
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
-		if (count($flightover_array) == 0) print _("No data available");
497
-		else {
541
+		if (count($flightover_array) == 0) {
542
+			print _("No data available");
543
+		} else {
498 544
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 545
 			print 'var series = [';
500 546
 			$flightover_data = '';
@@ -536,7 +582,10 @@  discard block
 block discarded – undo
536 582
 		}
537 583
 ?>
538 584
                 <div class="more">
539
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
585
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
586
+	echo '/'.$airline_icao;
587
+}
588
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
540 589
                 </div>
541 590
             </div>
542 591
 <?php
@@ -554,8 +603,9 @@  discard block
 block discarded – undo
554 603
 	<div class="col-md-6">
555 604
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556 605
 <?php
557
-	if (count($flightover_array) == 0) print _("No data available");
558
-	else {
606
+	if (count($flightover_array) == 0) {
607
+		print _("No data available");
608
+	} else {
559 609
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 610
 		print 'var series = [';
561 611
 		$flightover_data = '';
@@ -612,8 +662,9 @@  discard block
 block discarded – undo
612 662
 	<div class="col-md-6">
613 663
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614 664
 <?php
615
-	if (count($flightover_array) == 0) print _("No data available");
616
-	else {
665
+	if (count($flightover_array) == 0) {
666
+		print _("No data available");
667
+	} else {
617 668
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 669
 		print 'var series = [';
619 670
 		$flightover_data = '';
@@ -719,7 +770,9 @@  discard block
 block discarded – undo
719 770
 		});";
720 771
 		print '</script>';
721 772
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
773
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+			echo '/'.$airline_icao;
775
+		}
723 776
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724 777
 	}
725 778
 ?>
@@ -783,7 +836,9 @@  discard block
 block discarded – undo
783 836
 		});";
784 837
 		print '</script>';
785 838
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
786
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
839
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
840
+			echo '/'.$airline_icao;
841
+		}
787 842
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
788 843
 	}
789 844
 ?>
@@ -802,8 +857,9 @@  discard block
 block discarded – undo
802 857
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
803 858
 <?php
804 859
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
805
-		if (count($year_array) == 0) print _("No data available");
806
-		else {
860
+		if (count($year_array) == 0) {
861
+			print _("No data available");
862
+		} else {
807 863
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
808 864
 			$year_data = '';
809 865
 			$year_cnt = '';
@@ -822,7 +878,10 @@  discard block
 block discarded – undo
822 878
 		}
823 879
 ?>
824 880
                 <div class="more">
825
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
881
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
882
+	echo '/'.$airline_icao;
883
+}
884
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
826 885
                 </div>
827 886
             </div>
828 887
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -830,8 +889,9 @@  discard block
 block discarded – undo
830 889
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
831 890
 <?php
832 891
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
833
-		if (count($month_array) == 0) print _("No data available");
834
-		else {
892
+		if (count($month_array) == 0) {
893
+			print _("No data available");
894
+		} else {
835 895
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
836 896
 			$month_data = '';
837 897
 			$month_cnt = '';
@@ -850,7 +910,10 @@  discard block
 block discarded – undo
850 910
 		}
851 911
 ?>
852 912
                 <div class="more">
853
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
913
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
914
+	echo '/'.$airline_icao;
915
+}
916
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
854 917
                 </div>
855 918
             </div>
856 919
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -859,8 +922,9 @@  discard block
 block discarded – undo
859 922
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
860 923
 <?php
861 924
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
862
-		if (empty($date_array)) print _("No data available");
863
-		else {
925
+		if (empty($date_array)) {
926
+			print _("No data available");
927
+		} else {
864 928
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
865 929
 			$date_data = '';
866 930
 			$date_cnt = '';
@@ -879,7 +943,10 @@  discard block
 block discarded – undo
879 943
 		}
880 944
 ?>
881 945
                 <div class="more">
882
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
946
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
947
+	echo '/'.$airline_icao;
948
+}
949
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
883 950
                 </div>
884 951
             </div>
885 952
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -887,8 +954,9 @@  discard block
 block discarded – undo
887 954
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
888 955
 <?php
889 956
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
890
-		if (empty($hour_array)) print _("No data available");
891
-		else {
957
+		if (empty($hour_array)) {
958
+			print _("No data available");
959
+		} else {
892 960
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
893 961
 			$hour_data = '';
894 962
 			$hour_cnt = '';
@@ -907,7 +975,10 @@  discard block
 block discarded – undo
907 975
 		}
908 976
 ?>
909 977
                 <div class="more">
910
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
978
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
979
+	echo '/'.$airline_icao;
980
+}
981
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911 982
                 </div>
912 983
             </div>
913 984
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -927,8 +998,9 @@  discard block
 block discarded – undo
927 998
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
928 999
 <?php
929 1000
 		$year_array = $Stats->countAllMarineMonthsLastYear(true,$filter_name);
930
-		if (count($year_array) == 0) print _("No data available");
931
-		else {
1001
+		if (count($year_array) == 0) {
1002
+			print _("No data available");
1003
+		} else {
932 1004
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
933 1005
 			$year_data = '';
934 1006
 			$year_cnt = '';
@@ -956,8 +1028,9 @@  discard block
 block discarded – undo
956 1028
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
957 1029
 <?php
958 1030
 		$month_array = $Stats->countAllMarineDatesLastMonth($filter_name);
959
-		if (count($month_array) == 0) print _("No data available");
960
-		else {
1031
+		if (count($month_array) == 0) {
1032
+			print _("No data available");
1033
+		} else {
961 1034
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
962 1035
 			$month_data = '';
963 1036
 			$month_cnt = '';
@@ -985,8 +1058,9 @@  discard block
 block discarded – undo
985 1058
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
986 1059
 <?php
987 1060
 		$date_array = $Stats->countAllMarineDatesLast7Days($filter_name);
988
-		if (empty($date_array)) print _("No data available");
989
-		else {
1061
+		if (empty($date_array)) {
1062
+			print _("No data available");
1063
+		} else {
990 1064
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
991 1065
 			$date_data = '';
992 1066
 			$date_cnt = '';
@@ -1013,8 +1087,9 @@  discard block
 block discarded – undo
1013 1087
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1014 1088
 <?php
1015 1089
 		$hour_array = $Stats->countAllMarineHours('hour',true,$filter_name);
1016
-		if (empty($hour_array)) print _("No data available");
1017
-		else {
1090
+		if (empty($hour_array)) {
1091
+			print _("No data available");
1092
+		} else {
1018 1093
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1019 1094
 			$hour_data = '';
1020 1095
 			$hour_cnt = '';
@@ -1053,8 +1128,9 @@  discard block
 block discarded – undo
1053 1128
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1054 1129
 <?php
1055 1130
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1056
-		if (count($year_array) == 0) print _("No data available");
1057
-		else {
1131
+		if (count($year_array) == 0) {
1132
+			print _("No data available");
1133
+		} else {
1058 1134
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1059 1135
 			$year_data = '';
1060 1136
 			$year_cnt = '';
@@ -1082,8 +1158,9 @@  discard block
 block discarded – undo
1082 1158
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1083 1159
 <?php
1084 1160
 		$month_array = $Tracker->countAllDatesLastMonth();
1085
-		if (count($month_array) == 0) print _("No data available");
1086
-		else {
1161
+		if (count($month_array) == 0) {
1162
+			print _("No data available");
1163
+		} else {
1087 1164
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1088 1165
 			$month_data = '';
1089 1166
 			$month_cnt = '';
@@ -1111,8 +1188,9 @@  discard block
 block discarded – undo
1111 1188
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1112 1189
 <?php
1113 1190
 		$date_array = $Tracker->countAllDatesLast7Days();
1114
-		if (empty($date_array)) print _("No data available");
1115
-		else {
1191
+		if (empty($date_array)) {
1192
+			print _("No data available");
1193
+		} else {
1116 1194
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1117 1195
 			$date_data = '';
1118 1196
 			$date_cnt = '';
@@ -1139,8 +1217,9 @@  discard block
 block discarded – undo
1139 1217
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1140 1218
 <?php
1141 1219
 		$hour_array = $Tracker->countAllHours('hour',true);
1142
-		if (empty($hour_array)) print _("No data available");
1143
-		else {
1220
+		if (empty($hour_array)) {
1221
+			print _("No data available");
1222
+		} else {
1144 1223
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1145 1224
 			$hour_data = '';
1146 1225
 			$hour_cnt = '';
@@ -1179,8 +1258,9 @@  discard block
 block discarded – undo
1179 1258
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1180 1259
 <?php
1181 1260
 		$year_array = $Satellite->countAllMonthsLastYear();
1182
-		if (count($year_array) == 0) print _("No data available");
1183
-		else {
1261
+		if (count($year_array) == 0) {
1262
+			print _("No data available");
1263
+		} else {
1184 1264
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1185 1265
 			$year_data = '';
1186 1266
 			$year_cnt = '';
@@ -1210,8 +1290,9 @@  discard block
 block discarded – undo
1210 1290
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1211 1291
 <?php
1212 1292
 		$year_array = $Satellite->countAllYears();
1213
-		if (count($year_array) == 0) print _("No data available");
1214
-		else {
1293
+		if (count($year_array) == 0) {
1294
+			print _("No data available");
1295
+		} else {
1215 1296
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1216 1297
 			$year_data = '';
1217 1298
 			$year_cnt = '';
@@ -1253,8 +1334,9 @@  discard block
 block discarded – undo
1253 1334
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1254 1335
 <?php
1255 1336
 		$year_array = $Stats->countFatalitiesByYear();
1256
-		if (count($year_array) == 0) print _("No data available");
1257
-		else {
1337
+		if (count($year_array) == 0) {
1338
+			print _("No data available");
1339
+		} else {
1258 1340
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1259 1341
 			$year_data = '';
1260 1342
 			$year_cnt = '';
@@ -1283,8 +1365,9 @@  discard block
 block discarded – undo
1283 1365
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1284 1366
 <?php
1285 1367
 		$year_array = $Stats->countFatalitiesLast12Months();
1286
-		if (count($year_array) == 0) print _("No data available");
1287
-		else {
1368
+		if (count($year_array) == 0) {
1369
+			print _("No data available");
1370
+		} else {
1288 1371
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1289 1372
 			$year_data = '';
1290 1373
 			$year_cnt = '';
@@ -1355,8 +1438,11 @@  discard block
 block discarded – undo
1355 1438
 					$distance = $distance;
1356 1439
 					$unit = 'km';
1357 1440
 				}
1358
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1359
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1441
+				if (!isset($polar_data)) {
1442
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1443
+				} else {
1444
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1445
+				}
1360 1446
 			}
1361 1447
 ?>
1362 1448
             <div class="col-md-6">
@@ -1420,9 +1506,12 @@  discard block
 block discarded – undo
1420 1506
 		foreach ($msg as $eachmsg) {
1421 1507
 			//$eachmsg = $msg[0];
1422 1508
 			$data = $eachmsg['source_data'];
1423
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1424
-			else $max = 500;
1425
-?>
1509
+			if ($data > 500) {
1510
+				$max = (round(($data+100)/100))*100;
1511
+			} else {
1512
+				$max = 500;
1513
+			}
1514
+			?>
1426 1515
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1427 1516
         	<script>
1428 1517
 		      var g = new JustGage({
Please login to merge, or discard this patch.