Completed
Push — master ( d86a10...79cbb4 )
by Yannick
75:24 queued 40:34
created
require/class.Stats.php 2 patches
Spacing   +601 added lines, -601 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 countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
221
+	public function countAllAirlineCountries($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,7 +227,7 @@  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);
@@ -235,32 +235,32 @@  discard block
 block discarded – undo
235 235
 		if (empty($all)) {
236 236
 			$Spotter = new Spotter($this->db);
237 237
 			$filters = array();
238
-			$filters = array('year' => $year,'month' => $month);
238
+			$filters = array('year' => $year, 'month' => $month);
239 239
 			if ($filter_name != '') {
240
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
240
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
241 241
 			}
242 242
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
243
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
243
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
244 244
 		}
245 245
 		return $all;
246 246
 	}
247
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
247
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
248 248
 		global $globalStatsFilters;
249 249
 		if ($filter_name == '') $filter_name = $this->filter_name;
250
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
250
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
251 251
 			$Spotter = new Spotter($this->db);
252
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
252
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
253 253
 			$alliance_airlines = array();
254 254
 			foreach ($airlines as $airline) {
255
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
255
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
256 256
 			}
257 257
 			if ($year == '' && $month == '') {
258
-				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";
259
-				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";
258
+				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";
259
+				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";
260 260
 				try {
261 261
 					$sth = $this->db->prepare($query);
262 262
 					$sth->execute(array(':filter_name' => $filter_name));
263
-				} catch(PDOException $e) {
263
+				} catch (PDOException $e) {
264 264
 					echo "error : ".$e->getMessage();
265 265
 				}
266 266
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -271,21 +271,21 @@  discard block
 block discarded – undo
271 271
 				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";
272 272
 				try {
273 273
 					$sth = $this->db->prepare($query);
274
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
275
-				} catch(PDOException $e) {
274
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
275
+				} catch (PDOException $e) {
276 276
 					echo "error : ".$e->getMessage();
277 277
 				}
278 278
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
279 279
 			} else $all = array();
280 280
 		}
281 281
 		if (empty($all)) {
282
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
283
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
282
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
283
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
284 284
 			} else {
285
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
285
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
286 286
 			}
287 287
 			if ($filter_name != '') {
288
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
288
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
289 289
 			}
290 290
 			$Spotter = new Spotter($this->db);
291 291
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
 		return $all;
295 295
 	}
296 296
 
297
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
297
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
298 298
 		global $globalStatsFilters;
299 299
 		if ($filter_name == '') $filter_name = $this->filter_name;
300
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
300
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
301 301
 			$Spotter = new Spotter($this->db);
302
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
302
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
303 303
 			$alliance_airlines = array();
304 304
 			foreach ($airlines as $airline) {
305
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
305
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
306 306
 			}
307 307
 			if ($year == '' && $month == '') {
308
-				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";
309
-				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";
308
+				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";
309
+				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";
310 310
 				try {
311 311
 					$sth = $this->db->prepare($query);
312 312
 					$sth->execute(array(':filter_name' => $filter_name));
313
-				} catch(PDOException $e) {
313
+				} catch (PDOException $e) {
314 314
 					echo "error : ".$e->getMessage();
315 315
 				}
316 316
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -321,61 +321,61 @@  discard block
 block discarded – undo
321 321
 				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";
322 322
 				try {
323 323
 					$sth = $this->db->prepare($query);
324
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
325
-				} catch(PDOException $e) {
324
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
325
+				} catch (PDOException $e) {
326 326
 					echo "error : ".$e->getMessage();
327 327
 				}
328 328
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
329 329
 			} else $all = array();
330 330
 		}
331 331
 		if (empty($all)) {
332
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
333
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
332
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
333
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
334 334
 			} else {
335
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
336 336
 			}
337 337
 			if ($filter_name != '') {
338
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
338
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
339 339
 			}
340 340
 			$Spotter = new Spotter($this->db);
341 341
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
342
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
342
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
343 343
 		}
344 344
 		return $all;
345 345
 	}
346 346
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
347 347
 		global $globalStatsFilters;
348 348
 		if ($filter_name == '') $filter_name = $this->filter_name;
349
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
349
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
350 350
 			$Spotter = new Spotter($this->db);
351
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
351
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
352 352
 			$alliance_airlines = array();
353 353
 			foreach ($airlines as $airline) {
354
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
354
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
355 355
 			}
356
-			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";
357
-			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";
356
+			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";
357
+			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";
358 358
 			$query_values = array(':filter_name' => $filter_name);
359 359
 		} else {
360 360
 			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";
361 361
 			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";
362
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
362
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
363 363
 		}
364 364
 		try {
365 365
 			$sth = $this->db->prepare($query);
366 366
 			$sth->execute($query_values);
367
-		} catch(PDOException $e) {
367
+		} catch (PDOException $e) {
368 368
 			echo "error : ".$e->getMessage();
369 369
 		}
370 370
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
371 371
 		if (empty($all)) {
372
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
373
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
372
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
373
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
374 374
 			} else {
375
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
375
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
376 376
 			}
377 377
 			if ($filter_name != '') {
378
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
378
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
379 379
 			}
380 380
 			$Spotter = new Spotter($this->db);
381 381
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		return $all;
385 385
 	}
386 386
 
387
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
387
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
388 388
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
389 389
 		if ($filter_name == '') $filter_name = $this->filter_name;
390 390
 		if ($year == '' && $month == '') {
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			if (isset($forsource)) {
394 394
 				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";
395 395
 				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";
396
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
396
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
397 397
 			} else {
398 398
 				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";
399 399
 				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";
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			try {
403 403
 				$sth = $this->db->prepare($query);
404 404
 				$sth->execute($query_values);
405
-			} catch(PDOException $e) {
405
+			} catch (PDOException $e) {
406 406
 				echo "error : ".$e->getMessage();
407 407
 			}
408 408
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -410,32 +410,32 @@  discard block
 block discarded – undo
410 410
                 if (empty($all)) {
411 411
 	                $Spotter = new Spotter($this->db);
412 412
             		$filters = array();
413
-			$filters = array('year' => $year,'month' => $month);
413
+			$filters = array('year' => $year, 'month' => $month);
414 414
             		if ($filter_name != '') {
415
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
415
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
416 416
 			}
417 417
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
418
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
418
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
419 419
                 }
420 420
                 return $all;
421 421
 	}
422
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
422
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
423 423
 		global $globalStatsFilters;
424 424
 		if ($filter_name == '') $filter_name = $this->filter_name;
425
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
425
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
426 426
 			$Spotter = new Spotter($this->db);
427
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
427
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
428 428
 			$alliance_airlines = array();
429 429
 			foreach ($airlines as $airline) {
430
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
430
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
431 431
 			}
432 432
 			if ($year == '' && $month == '') {
433
-				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";
434
-				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";
433
+				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";
434
+				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";
435 435
 				try {
436 436
 					$sth = $this->db->prepare($query);
437 437
 					$sth->execute(array(':filter_name' => $filter_name));
438
-				} catch(PDOException $e) {
438
+				} catch (PDOException $e) {
439 439
 					echo "error : ".$e->getMessage();
440 440
 				}
441 441
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -446,45 +446,45 @@  discard block
 block discarded – undo
446 446
 				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";
447 447
 				try {
448 448
 					$sth = $this->db->prepare($query);
449
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
450
-				} catch(PDOException $e) {
449
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
450
+				} catch (PDOException $e) {
451 451
 					echo "error : ".$e->getMessage();
452 452
 				}
453 453
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
454 454
 			} else $all = array();
455 455
 		}
456 456
 		if (empty($all)) {
457
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
458
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
457
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
458
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
459 459
 			} else {
460
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
460
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
461 461
 			}
462 462
 			if ($filter_name != '') {
463
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
463
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
464 464
 			}
465 465
 			$Spotter = new Spotter($this->db);
466 466
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
467
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
467
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
468 468
 		}
469 469
 		return $all;
470 470
 	}
471
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
471
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
472 472
 		global $globalStatsFilters;
473 473
 		if ($filter_name == '') $filter_name = $this->filter_name;
474
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
474
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
475 475
 			$Spotter = new Spotter($this->db);
476
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
476
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
477 477
 			$alliance_airlines = array();
478 478
 			foreach ($airlines as $airline) {
479
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
479
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
480 480
 			}
481 481
 			if ($year == '' && $month == '') {
482
-				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";
483
-				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";
482
+				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";
483
+				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";
484 484
 				 try {
485 485
 					$sth = $this->db->prepare($query);
486 486
 					$sth->execute(array(':filter_name' => $filter_name));
487
-				} catch(PDOException $e) {
487
+				} catch (PDOException $e) {
488 488
 					echo "error : ".$e->getMessage();
489 489
 				}
490 490
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -495,46 +495,46 @@  discard block
 block discarded – undo
495 495
 				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";
496 496
 				 try {
497 497
 					$sth = $this->db->prepare($query);
498
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
499
-				} catch(PDOException $e) {
498
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
499
+				} catch (PDOException $e) {
500 500
 					echo "error : ".$e->getMessage();
501 501
 				}
502 502
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503 503
 			} else $all = array();
504 504
 		}
505 505
 		if (empty($all)) {
506
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
507
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
506
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
507
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
508 508
 			} else {
509
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
509
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
510 510
 			}
511 511
 			if ($filter_name != '') {
512
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
512
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
513 513
 			}
514 514
 			$Spotter = new Spotter($this->db);
515 515
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
516
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
516
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
517 517
 		}
518 518
 		return $all;
519 519
 	}
520
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
520
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
521 521
 		$Connection = new Connection($this->db);
522 522
 		if ($filter_name == '') $filter_name = $this->filter_name;
523 523
 		if ($Connection->tableExists('countries')) {
524
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
524
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
525 525
 				$Spotter = new Spotter($this->db);
526
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
526
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
527 527
 				if ($year == '' && $month == '') {
528 528
 					$alliance_airlines = array();
529 529
 					foreach ($airlines as $airline) {
530
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
530
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
531 531
 					}
532
-					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";
533
-					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";
532
+					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";
533
+					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";
534 534
 					 try {
535 535
 						$sth = $this->db->prepare($query);
536 536
 						$sth->execute(array(':filter_name' => $filter_name));
537
-					} catch(PDOException $e) {
537
+					} catch (PDOException $e) {
538 538
 						echo "error : ".$e->getMessage();
539 539
 					}
540 540
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 					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";
547 547
 					 try {
548 548
 						$sth = $this->db->prepare($query);
549
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
550
-					} catch(PDOException $e) {
549
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
550
+					} catch (PDOException $e) {
551 551
 						echo "error : ".$e->getMessage();
552 552
 					}
553 553
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 			return $Spotter->countAllFlightOverCountries($limit);
559 559
 		} else return array();
560 560
 	}
561
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
561
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
562 562
 		$Connection = new Connection($this->db);
563 563
 		if ($filter_name == '') $filter_name = $this->filter_name;
564 564
 		if ($Connection->tableExists('countries')) {
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 				 try {
569 569
 					$sth = $this->db->prepare($query);
570 570
 					$sth->execute(array(':filter_name' => $filter_name));
571
-				} catch(PDOException $e) {
571
+				} catch (PDOException $e) {
572 572
 					echo "error : ".$e->getMessage();
573 573
 				}
574 574
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -576,13 +576,13 @@  discard block
 block discarded – undo
576 576
 			}
577 577
 			$filters = array();
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
 			$Marine = new Marine($this->db);
582
-			return $Marine->countAllMarineOverCountries($limit,$filters,$year,$month);
582
+			return $Marine->countAllMarineOverCountries($limit, $filters, $year, $month);
583 583
 		} else return array();
584 584
 	}
585
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
585
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
586 586
 		$Connection = new Connection($this->db);
587 587
 		if ($filter_name == '') $filter_name = $this->filter_name;
588 588
 		if ($Connection->tableExists('countries')) {
@@ -592,17 +592,17 @@  discard block
 block discarded – undo
592 592
 				 try {
593 593
 					$sth = $this->db->prepare($query);
594 594
 					$sth->execute(array(':filter_name' => $filter_name));
595
-				} catch(PDOException $e) {
595
+				} catch (PDOException $e) {
596 596
 					echo "error : ".$e->getMessage();
597 597
 				}
598 598
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
599 599
 				return $all;
600 600
 			}
601 601
 			$Tracker = new Tracker($this->db);
602
-			return $Tracker->countAllTrackerOverCountries($limit,$filters,$year,$month);
602
+			return $Tracker->countAllTrackerOverCountries($limit, $filters, $year, $month);
603 603
 		} else return array();
604 604
 	}
605
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
605
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
606 606
 		global $globalStatsFilters;
607 607
 		if ($filter_name == '') $filter_name = $this->filter_name;
608 608
 		if ($year == '' && $month == '') {
@@ -610,41 +610,41 @@  discard block
 block discarded – undo
610 610
 			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";
611 611
 			try {
612 612
 				$sth = $this->db->prepare($query);
613
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
614
-			} catch(PDOException $e) {
613
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
614
+			} catch (PDOException $e) {
615 615
 				echo "error : ".$e->getMessage();
616 616
 			}
617 617
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
618 618
 		} else $all = array();
619 619
 		if (empty($all)) {
620
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
620
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
621 621
 			if ($filter_name != '') {
622
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
622
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
623 623
 			}
624 624
 			$Spotter = new Spotter($this->db);
625 625
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
626
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
626
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
627 627
 		}
628 628
 		return $all;
629 629
 	}
630 630
 
631
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
631
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
632 632
 		global $globalStatsFilters;
633 633
 		if ($filter_name == '') $filter_name = $this->filter_name;
634
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
634
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
635 635
 			$Spotter = new Spotter($this->db);
636
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
636
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
637 637
 			if ($year == '' && $month == '') {
638 638
 				$alliance_airlines = array();
639 639
 				foreach ($airlines as $airline) {
640
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
640
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
641 641
 				}
642
-				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";
643
-				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";
642
+				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";
643
+				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";
644 644
 				try {
645 645
 					$sth = $this->db->prepare($query);
646 646
 					$sth->execute(array(':filter_name' => $filter_name));
647
-				} catch(PDOException $e) {
647
+				} catch (PDOException $e) {
648 648
 					echo "error : ".$e->getMessage();
649 649
 				}
650 650
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -655,45 +655,45 @@  discard block
 block discarded – undo
655 655
 				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";
656 656
 				try {
657 657
 					$sth = $this->db->prepare($query);
658
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
659
-				} catch(PDOException $e) {
658
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
659
+				} catch (PDOException $e) {
660 660
 					echo "error : ".$e->getMessage();
661 661
 				}
662 662
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
663 663
 			} else $all = array();
664 664
 		}
665 665
 		if (empty($all)) {
666
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
667
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
666
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
667
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
668 668
 			} else {
669
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
669
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
670 670
 			}
671 671
 			if ($filter_name != '') {
672
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
672
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
673 673
 			}
674 674
 			$Spotter = new Spotter($this->db);
675 675
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
676
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
676
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
677 677
 		}
678 678
 		return $all;
679 679
 	}
680
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
680
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
681 681
 		global $globalStatsFilters;
682 682
 		if ($filter_name == '') $filter_name = $this->filter_name;
683
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
683
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
684 684
 			$Spotter = new Spotter($this->db);
685
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
685
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
686 686
 			if ($year == '' && $month == '') {
687 687
 				$alliance_airlines = array();
688 688
 				foreach ($airlines as $airline) {
689
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
689
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
690 690
 				}
691
-				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";
692
-				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";
691
+				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";
692
+				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";
693 693
 				try {
694 694
 					$sth = $this->db->prepare($query);
695 695
 					$sth->execute(array(':filter_name' => $filter_name));
696
-				} catch(PDOException $e) {
696
+				} catch (PDOException $e) {
697 697
 					echo "error : ".$e->getMessage();
698 698
 				}
699 699
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -704,27 +704,27 @@  discard block
 block discarded – undo
704 704
 				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";
705 705
 				try {
706 706
 					$sth = $this->db->prepare($query);
707
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
708
-				} catch(PDOException $e) {
707
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
708
+				} catch (PDOException $e) {
709 709
 					echo "error : ".$e->getMessage();
710 710
 				}
711 711
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
712 712
 			} else $all = array();
713 713
 		}
714 714
 		if (empty($all)) {
715
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
716
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
715
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
716
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
717 717
 			} else {
718
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
718
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
719 719
 			}
720 720
 			if ($filter_name != '') {
721
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
721
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
722 722
 			}
723 723
 			$Spotter = new Spotter($this->db);
724 724
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
725 725
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
726
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
727
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
726
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
727
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
728 728
 			$all = array();
729 729
 			foreach ($pall as $value) {
730 730
 				$icao = $value['airport_departure_icao'];
@@ -740,27 +740,27 @@  discard block
 block discarded – undo
740 740
 			foreach ($all as $key => $row) {
741 741
 				$count[$key] = $row['airport_departure_icao_count'];
742 742
 			}
743
-			array_multisort($count,SORT_DESC,$all);
743
+			array_multisort($count, SORT_DESC, $all);
744 744
 		}
745 745
 		return $all;
746 746
 	}
747
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
747
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
748 748
 		global $globalStatsFilters;
749 749
 		if ($filter_name == '') $filter_name = $this->filter_name;
750
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
750
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
751 751
 			$Spotter = new Spotter($this->db);
752
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
752
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
753 753
 			if ($year == '' && $month == '') {
754 754
 				$alliance_airlines = array();
755 755
 				foreach ($airlines as $airline) {
756
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
756
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
757 757
 				}
758
-				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";
759
-				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";
758
+				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";
759
+				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";
760 760
 				try {
761 761
 					$sth = $this->db->prepare($query);
762 762
 					$sth->execute(array(':filter_name' => $filter_name));
763
-				} catch(PDOException $e) {
763
+				} catch (PDOException $e) {
764 764
 					echo "error : ".$e->getMessage();
765 765
 				}
766 766
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -771,27 +771,27 @@  discard block
 block discarded – undo
771 771
 				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";
772 772
 				try {
773 773
 					$sth = $this->db->prepare($query);
774
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
775
-				} catch(PDOException $e) {
774
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
775
+				} catch (PDOException $e) {
776 776
 					echo "error : ".$e->getMessage();
777 777
 				}
778 778
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
779 779
 			} else $all = array();
780 780
 		}
781 781
 		if (empty($all)) {
782
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
783
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
782
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
783
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
784 784
 			} else {
785
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
785
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
786 786
 			}
787 787
 			if ($filter_name != '') {
788
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
788
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
789 789
 			}
790 790
 			$Spotter = new Spotter($this->db);
791 791
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
792 792
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
793
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
794
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
793
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
794
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
795 795
 			$all = array();
796 796
 			foreach ($pall as $value) {
797 797
 				$icao = $value['airport_arrival_icao'];
@@ -807,26 +807,26 @@  discard block
 block discarded – undo
807 807
 			foreach ($all as $key => $row) {
808 808
 				$count[$key] = $row['airport_arrival_icao_count'];
809 809
 			}
810
-			array_multisort($count,SORT_DESC,$all);
810
+			array_multisort($count, SORT_DESC, $all);
811 811
 		}
812 812
 		return $all;
813 813
 	}
814
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
814
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
815 815
 		global $globalDBdriver, $globalStatsFilters;
816 816
 		if ($filter_name == '') $filter_name = $this->filter_name;
817
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
817
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
818 818
 			$Spotter = new Spotter($this->db);
819
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
819
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
820 820
 			$alliance_airlines = array();
821 821
 			foreach ($airlines as $airline) {
822
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
822
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
823 823
 			}
824 824
 			if ($globalDBdriver == 'mysql') {
825
-				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";
826
-				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";
825
+				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";
826
+				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";
827 827
 			} else {
828
-				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";
829
-				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";
828
+				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";
829
+				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";
830 830
 			}
831 831
 			$query_data = array(':filter_name' => $filter_name);
832 832
 		} else {
@@ -837,23 +837,23 @@  discard block
 block discarded – undo
837 837
 				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";
838 838
 				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";
839 839
 			}
840
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
840
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
841 841
 		}
842 842
 		try {
843 843
 			$sth = $this->db->prepare($query);
844 844
 			$sth->execute($query_data);
845
-		} catch(PDOException $e) {
845
+		} catch (PDOException $e) {
846 846
 			echo "error : ".$e->getMessage();
847 847
 		}
848 848
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
849 849
 		if (empty($all)) {
850
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
851
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
850
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
851
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
852 852
 			} else {
853 853
 				$filters = array('airlines' => array($stats_airline));
854 854
 			}
855 855
 			if ($filter_name != '') {
856
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
856
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
857 857
 			}
858 858
 			$Spotter = new Spotter($this->db);
859 859
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -861,57 +861,57 @@  discard block
 block discarded – undo
861 861
 		return $all;
862 862
 	}
863 863
 	
864
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
864
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
865 865
 		global $globalStatsFilters;
866 866
 		if ($filter_name == '') $filter_name = $this->filter_name;
867
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
867
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
868 868
 			$Spotter = new Spotter($this->db);
869
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
869
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
870 870
 			$alliance_airlines = array();
871 871
 			foreach ($airlines as $airline) {
872
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
872
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
873 873
 			}
874
-			$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";
874
+			$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";
875 875
 			$query_data = array(':filter_name' => $filter_name);
876 876
 		} else {
877 877
 			$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";
878
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
878
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
879 879
 		}
880 880
 		try {
881 881
 			$sth = $this->db->prepare($query);
882 882
 			$sth->execute($query_data);
883
-		} catch(PDOException $e) {
883
+		} catch (PDOException $e) {
884 884
 			echo "error : ".$e->getMessage();
885 885
 		}
886 886
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
887 887
 		if (empty($all)) {
888
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
889
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
888
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
889
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
890 890
 			} else {
891 891
 				$filters = array('airlines' => array($stats_airline));
892 892
 			}
893 893
 			if ($filter_name != '') {
894
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
894
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
895 895
 			}
896 896
 			$Spotter = new Spotter($this->db);
897 897
 			$all = $Spotter->countAllDatesLastMonth($filters);
898 898
 		}
899 899
 		return $all;
900 900
 	}
901
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
901
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
902 902
 		global $globalDBdriver, $globalStatsFilters;
903 903
 		if ($filter_name == '') $filter_name = $this->filter_name;
904
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
904
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
905 905
 			$Spotter = new Spotter($this->db);
906
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
906
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
907 907
 			$alliance_airlines = array();
908 908
 			foreach ($airlines as $airline) {
909
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
909
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
910 910
 			}
911 911
 			if ($globalDBdriver == 'mysql') {
912
-				$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";
912
+				$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";
913 913
 			} else {
914
-				$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";
914
+				$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";
915 915
 			}
916 916
 			$query_data = array(':filter_name' => $filter_name);
917 917
 		} else {
@@ -920,60 +920,60 @@  discard block
 block discarded – undo
920 920
 			} else {
921 921
 				$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";
922 922
 			}
923
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
923
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
924 924
 		}
925 925
 		try {
926 926
 			$sth = $this->db->prepare($query);
927 927
 			$sth->execute($query_data);
928
-		} catch(PDOException $e) {
928
+		} catch (PDOException $e) {
929 929
 			echo "error : ".$e->getMessage();
930 930
 		}
931 931
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
932 932
 		if (empty($all)) {
933
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
934
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
933
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
934
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
935 935
 			} else {
936 936
 				$filters = array('airlines' => array($stats_airline));
937 937
 			}
938 938
 			if ($filter_name != '') {
939
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
939
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
940 940
 			}
941 941
 			$Spotter = new Spotter($this->db);
942 942
 			$all = $Spotter->countAllDatesLast7Days($filters);
943 943
 		}
944 944
 		return $all;
945 945
 	}
946
-	public function countAllDates($stats_airline = '',$filter_name = '') {
946
+	public function countAllDates($stats_airline = '', $filter_name = '') {
947 947
 		global $globalStatsFilters;
948 948
 		if ($filter_name == '') $filter_name = $this->filter_name;
949
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
949
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
950 950
 			$Spotter = new Spotter($this->db);
951
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
951
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
952 952
 			$alliance_airlines = array();
953 953
 			foreach ($airlines as $airline) {
954
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
954
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
955 955
 			}
956
-			$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";
956
+			$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";
957 957
 			$query_data = array(':filter_name' => $filter_name);
958 958
 		} else {
959 959
 			$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";
960
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
960
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
961 961
 		}
962 962
 		try {
963 963
 			$sth = $this->db->prepare($query);
964 964
 			$sth->execute($query_data);
965
-		} catch(PDOException $e) {
965
+		} catch (PDOException $e) {
966 966
 			echo "error : ".$e->getMessage();
967 967
 		}
968 968
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
969 969
 		if (empty($all)) {
970
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
971
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
970
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
971
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
972 972
 			} else {
973 973
 				$filters = array('airlines' => array($stats_airline));
974 974
 			}
975 975
 			if ($filter_name != '') {
976
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
976
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
977 977
 			}
978 978
 			$Spotter = new Spotter($this->db);
979 979
 			$all = $Spotter->countAllDates($filters);
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_data);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 		}
994 994
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 		try {
1011 1011
 			$sth = $this->db->prepare($query);
1012 1012
 			$sth->execute($query_data);
1013
-		} catch(PDOException $e) {
1013
+		} catch (PDOException $e) {
1014 1014
 			echo "error : ".$e->getMessage();
1015 1015
 		}
1016 1016
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1032,34 +1032,34 @@  discard block
 block discarded – undo
1032 1032
 		try {
1033 1033
 			$sth = $this->db->prepare($query);
1034 1034
 			$sth->execute($query_data);
1035
-		} catch(PDOException $e) {
1035
+		} catch (PDOException $e) {
1036 1036
 			echo "error : ".$e->getMessage();
1037 1037
 		}
1038 1038
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1039 1039
 		if (empty($all)) {
1040 1040
 			$filters = array();
1041 1041
 			if ($filter_name != '') {
1042
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1042
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1043 1043
 			}
1044 1044
 			$Spotter = new Spotter($this->db);
1045 1045
 			$all = $Spotter->countAllDatesByAirlines($filters);
1046 1046
 		}
1047 1047
 		return $all;
1048 1048
 	}
1049
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1049
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1050 1050
 		global $globalStatsFilters, $globalDBdriver;
1051 1051
 		if ($filter_name == '') $filter_name = $this->filter_name;
1052
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1052
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1053 1053
 			$Spotter = new Spotter($this->db);
1054
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1054
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1055 1055
 			$alliance_airlines = array();
1056 1056
 			foreach ($airlines as $airline) {
1057
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1057
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1058 1058
 			}
1059 1059
 			if ($globalDBdriver == 'mysql') {
1060
-				$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";
1060
+				$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";
1061 1061
 			} else {
1062
-				$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";
1062
+				$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";
1063 1063
 			}
1064 1064
 			$query_data = array(':filter_name' => $filter_name);
1065 1065
 		} else {
@@ -1073,18 +1073,18 @@  discard block
 block discarded – undo
1073 1073
 		try {
1074 1074
 			$sth = $this->db->prepare($query);
1075 1075
 			$sth->execute($query_data);
1076
-		} catch(PDOException $e) {
1076
+		} catch (PDOException $e) {
1077 1077
 			echo "error : ".$e->getMessage();
1078 1078
 		}
1079 1079
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1080 1080
 		if (empty($all)) {
1081
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1082
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1081
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1082
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1083 1083
 			} else {
1084 1084
 				$filters = array('airlines' => array($stats_airline));
1085 1085
 			}
1086 1086
 			if ($filter_name != '') {
1087
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1087
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1088 1088
 			}
1089 1089
 			$Spotter = new Spotter($this->db);
1090 1090
 			$all = $Spotter->countAllMonths($filters);
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 		try {
1102 1102
 			$sth = $this->db->prepare($query);
1103 1103
 			$sth->execute();
1104
-		} catch(PDOException $e) {
1104
+		} catch (PDOException $e) {
1105 1105
 			echo "error : ".$e->getMessage();
1106 1106
 		}
1107 1107
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $this->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			echo "error : ".$e->getMessage();
1126 1126
 		}
1127 1127
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1138,32 +1138,32 @@  discard block
 block discarded – undo
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
1140 1140
 			$sth->execute(array(':filter_name' => $filter_name));
1141
-		} catch(PDOException $e) {
1141
+		} catch (PDOException $e) {
1142 1142
 			echo "error : ".$e->getMessage();
1143 1143
 		}
1144 1144
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1145 1145
 		if (empty($all)) {
1146 1146
 			$filters = array();
1147 1147
 			if ($filter_name != '') {
1148
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1148
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1149 1149
 			}
1150 1150
 			$Spotter = new Spotter($this->db);
1151 1151
 			$all = $Spotter->countAllMilitaryMonths($filters);
1152 1152
 		}
1153 1153
 		return $all;
1154 1154
 	}
1155
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1155
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1156 1156
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1157 1157
 		if ($filter_name == '') $filter_name = $this->filter_name;
1158
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1158
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1159 1159
 			$Spotter = new Spotter($this->db);
1160
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1160
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1161 1161
 			$alliance_airlines = array();
1162 1162
 			foreach ($airlines as $airline) {
1163
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1163
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1164 1164
 			}
1165
-			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";
1166
-			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";
1165
+			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";
1166
+			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";
1167 1167
 			$query_data = array(':filter_name' => $filter_name);
1168 1168
 		} else {
1169 1169
 			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";
@@ -1181,37 +1181,37 @@  discard block
 block discarded – undo
1181 1181
 		try {
1182 1182
 			$sth = $this->db->prepare($query);
1183 1183
 			$sth->execute($query_data);
1184
-		} catch(PDOException $e) {
1184
+		} catch (PDOException $e) {
1185 1185
 			echo "error : ".$e->getMessage();
1186 1186
 		}
1187 1187
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1188 1188
 		if (empty($all)) {
1189
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1190
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1189
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1190
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1191 1191
 			} else {
1192 1192
 				$filters = array('airlines' => array($stats_airline));
1193 1193
 			}
1194 1194
 			if ($filter_name != '') {
1195
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1195
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1196 1196
 			}
1197 1197
 			$Spotter = new Spotter($this->db);
1198
-			$all = $Spotter->countAllHours($orderby,$filters);
1198
+			$all = $Spotter->countAllHours($orderby, $filters);
1199 1199
 		}
1200 1200
 		return $all;
1201 1201
 	}
1202
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1202
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1203 1203
 		global $globalStatsFilters;
1204 1204
 		if ($filter_name == '') $filter_name = $this->filter_name;
1205 1205
 		if ($year == '') $year = date('Y');
1206
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1206
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1207 1207
 		if (empty($all)) {
1208
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1209
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1208
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1209
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1210 1210
 			} else {
1211
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1211
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1212 1212
 			}
1213 1213
 			if ($filter_name != '') {
1214
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1214
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1215 1215
 			}
1216 1216
 			$Spotter = new Spotter($this->db);
1217 1217
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1219,15 +1219,15 @@  discard block
 block discarded – undo
1219 1219
 		}
1220 1220
 		return $all;
1221 1221
 	}
1222
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1222
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1223 1223
 		global $globalStatsFilters;
1224 1224
 		if ($filter_name == '') $filter_name = $this->filter_name;
1225 1225
 		if ($year == '') $year = date('Y');
1226
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1226
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1227 1227
 		if (empty($all)) {
1228
-			$filters = array('year' => $year,'month' => $month);
1228
+			$filters = array('year' => $year, 'month' => $month);
1229 1229
 			if ($filter_name != '') {
1230
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1230
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1231 1231
 			}
1232 1232
 			$Marine = new Marine($this->db);
1233 1233
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
 		}
1236 1236
 		return $all;
1237 1237
 	}
1238
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1238
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1239 1239
 		global $globalStatsFilters;
1240 1240
 		if ($filter_name == '') $filter_name = $this->filter_name;
1241 1241
 		if ($year == '') $year = date('Y');
1242
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1242
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1243 1243
 		if (empty($all)) {
1244
-			$filters = array('year' => $year,'month' => $month);
1244
+			$filters = array('year' => $year, 'month' => $month);
1245 1245
 			if ($filter_name != '') {
1246
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1246
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1247 1247
 			}
1248 1248
 			$Tracker = new Tracker($this->db);
1249 1249
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1251,16 +1251,16 @@  discard block
 block discarded – undo
1251 1251
 		}
1252 1252
 		return $all;
1253 1253
 	}
1254
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1254
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1255 1255
 		global $globalStatsFilters;
1256 1256
 		if ($filter_name == '') $filter_name = $this->filter_name;
1257 1257
 		if ($year == '') $year = date('Y');
1258
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1258
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1259 1259
 		if (empty($all)) {
1260 1260
 			$filters = array();
1261
-			$filters = array('year' => $year,'month' => $month);
1261
+			$filters = array('year' => $year, 'month' => $month);
1262 1262
 			if ($filter_name != '') {
1263
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1263
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1264 1264
 			}
1265 1265
 			$Spotter = new Spotter($this->db);
1266 1266
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1268,19 +1268,19 @@  discard block
 block discarded – undo
1268 1268
 		}
1269 1269
 		return $all;
1270 1270
 	}
1271
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1271
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1272 1272
 		global $globalStatsFilters;
1273 1273
 		if ($filter_name == '') $filter_name = $this->filter_name;
1274 1274
 		if ($year == '') $year = date('Y');
1275
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1275
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1276 1276
 		if (empty($all)) {
1277
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1278
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1277
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1278
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1279 1279
 			} else {
1280
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1280
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1281 1281
 			}
1282 1282
 			if ($filter_name != '') {
1283
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1283
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1284 1284
 			}
1285 1285
 			$Spotter = new Spotter($this->db);
1286 1286
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1288,48 +1288,48 @@  discard block
 block discarded – undo
1288 1288
 		}
1289 1289
 		return $all;
1290 1290
 	}
1291
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1291
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1292 1292
 		global $globalStatsFilters;
1293 1293
 		if ($filter_name == '') $filter_name = $this->filter_name;
1294
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1294
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1295 1295
 			$Spotter = new Spotter($this->db);
1296
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1296
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1297 1297
 			if ($year == '' && $month == '') {
1298 1298
 				$alliance_airlines = array();
1299 1299
 				foreach ($airlines as $airline) {
1300
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1300
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1301 1301
 				}
1302
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1302
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1303 1303
 				try {
1304 1304
 					$sth = $this->db->prepare($query);
1305 1305
 					$sth->execute(array(':filter_name' => $filter_name));
1306
-				} catch(PDOException $e) {
1306
+				} catch (PDOException $e) {
1307 1307
 					echo "error : ".$e->getMessage();
1308 1308
 				}
1309 1309
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1310 1310
 				$all = $result[0]['nb'];
1311
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1311
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1312 1312
 		} else {
1313 1313
 			if ($year == '' && $month == '') {
1314 1314
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1315 1315
 				try {
1316 1316
 					$sth = $this->db->prepare($query);
1317
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1318
-				} catch(PDOException $e) {
1317
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1318
+				} catch (PDOException $e) {
1319 1319
 					echo "error : ".$e->getMessage();
1320 1320
 				}
1321 1321
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1322 1322
 				$all = $result[0]['nb'];
1323
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1323
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1324 1324
 		}
1325 1325
 		if (empty($all)) {
1326
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1327
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1326
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1327
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1328 1328
 			} else {
1329
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1329
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1330 1330
 			}
1331 1331
 			if ($filter_name != '') {
1332
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1332
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1333 1333
 			}
1334 1334
 			$Spotter = new Spotter($this->db);
1335 1335
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
 		}
1338 1338
 		return $all;
1339 1339
 	}
1340
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1340
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1341 1341
 		global $globalStatsFilters;
1342 1342
 		if ($filter_name == '') $filter_name = $this->filter_name;
1343 1343
 		if ($year == '' && $month == '') {
@@ -1345,17 +1345,17 @@  discard block
 block discarded – undo
1345 1345
 			try {
1346 1346
 				$sth = $this->db->prepare($query);
1347 1347
 				$sth->execute(array(':filter_name' => $filter_name));
1348
-			} catch(PDOException $e) {
1348
+			} catch (PDOException $e) {
1349 1349
 				echo "error : ".$e->getMessage();
1350 1350
 			}
1351 1351
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1352 1352
 			$all = $result[0]['nb_airline'];
1353
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1353
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1354 1354
 		if (empty($all)) {
1355 1355
 			$filters = array();
1356
-			$filters = array('year' => $year,'month' => $month);
1356
+			$filters = array('year' => $year, 'month' => $month);
1357 1357
 			if ($filter_name != '') {
1358
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1358
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1359 1359
 			}
1360 1360
 			$Spotter = new Spotter($this->db);
1361 1361
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1363,29 +1363,29 @@  discard block
 block discarded – undo
1363 1363
 		}
1364 1364
 		return $all;
1365 1365
 	}
1366
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1366
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1367 1367
 		global $globalStatsFilters;
1368 1368
 		if ($filter_name == '') $filter_name = $this->filter_name;
1369
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1369
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1370 1370
 			$Spotter = new Spotter($this->db);
1371
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1371
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1372 1372
 			if ($year == '' && $month == '') {
1373 1373
 				$alliance_airlines = array();
1374 1374
 				foreach ($airlines as $airline) {
1375
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1375
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1376 1376
 				}
1377
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1377
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1378 1378
 				$query_values = array(':filter_name' => $filter_name);
1379 1379
 				try {
1380 1380
 					$sth = $this->db->prepare($query);
1381 1381
 					$sth->execute($query_values);
1382
-				} catch(PDOException $e) {
1382
+				} catch (PDOException $e) {
1383 1383
 					echo "error : ".$e->getMessage();
1384 1384
 				}
1385 1385
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1386 1386
 				$all = $result[0]['nb'];
1387 1387
 			} else {
1388
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1388
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1389 1389
 			}
1390 1390
 		} else {
1391 1391
 			if ($year == '' && $month == '') {
@@ -1394,23 +1394,23 @@  discard block
 block discarded – undo
1394 1394
 				try {
1395 1395
 					$sth = $this->db->prepare($query);
1396 1396
 					$sth->execute($query_values);
1397
-				} catch(PDOException $e) {
1397
+				} catch (PDOException $e) {
1398 1398
 					echo "error : ".$e->getMessage();
1399 1399
 				}
1400 1400
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1401 1401
 				$all = $result[0]['nb'];
1402 1402
 			} else {
1403
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1403
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1404 1404
 			}
1405 1405
 		}
1406 1406
 		if (empty($all)) {
1407
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1408
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1407
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1408
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1409 1409
 			} else {
1410
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1410
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1411 1411
 			}
1412 1412
 			if ($filter_name != '') {
1413
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1413
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1414 1414
 			}
1415 1415
 			$Spotter = new Spotter($this->db);
1416 1416
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 		}
1419 1419
 		return $all;
1420 1420
 	}
1421
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1421
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1422 1422
 		global $globalStatsFilters;
1423 1423
 		if ($filter_name == '') $filter_name = $this->filter_name;
1424 1424
 		//if ($year == '') $year = date('Y');
@@ -1428,18 +1428,18 @@  discard block
 block discarded – undo
1428 1428
 			try {
1429 1429
 				$sth = $this->db->prepare($query);
1430 1430
 				$sth->execute($query_values);
1431
-			} catch(PDOException $e) {
1431
+			} catch (PDOException $e) {
1432 1432
 				echo "error : ".$e->getMessage();
1433 1433
 			}
1434 1434
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1435 1435
 			$all = $result[0]['nb'];
1436 1436
 		} else {
1437
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1437
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1438 1438
 		}
1439 1439
 		if (empty($all)) {
1440
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1440
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1441 1441
 			if ($filter_name != '') {
1442
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1442
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1443 1443
 			}
1444 1444
 			$Spotter = new Spotter($this->db);
1445 1445
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1448,104 +1448,104 @@  discard block
 block discarded – undo
1448 1448
 		return $all;
1449 1449
 	}
1450 1450
 
1451
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1451
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1452 1452
 		if ($filter_name == '') $filter_name = $this->filter_name;
1453
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1453
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1454 1454
 			$Spotter = new Spotter($this->db);
1455
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1455
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1456 1456
 			$alliance_airlines = array();
1457 1457
 			foreach ($airlines as $airline) {
1458
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1458
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1459 1459
 			}
1460
-			$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";
1461
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1460
+			$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";
1461
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1462 1462
 		} else {
1463 1463
 			$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";
1464
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1464
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1465 1465
 		}
1466 1466
 		try {
1467 1467
 			$sth = $this->db->prepare($query);
1468 1468
 			$sth->execute($query_values);
1469
-		} catch(PDOException $e) {
1469
+		} catch (PDOException $e) {
1470 1470
 			echo "error : ".$e->getMessage();
1471 1471
 		}
1472 1472
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1473 1473
 		return $all;
1474 1474
 	}
1475
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1475
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1476 1476
 		if ($filter_name == '') $filter_name = $this->filter_name;
1477 1477
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1478
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1478
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1479 1479
 		try {
1480 1480
 			$sth = $this->db->prepare($query);
1481 1481
 			$sth->execute($query_values);
1482
-		} catch(PDOException $e) {
1482
+		} catch (PDOException $e) {
1483 1483
 			echo "error : ".$e->getMessage();
1484 1484
 		}
1485 1485
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1486 1486
 		return $all;
1487 1487
 	}
1488
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1488
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1489 1489
 		if ($filter_name == '') $filter_name = $this->filter_name;
1490 1490
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1491
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1491
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1492 1492
 		try {
1493 1493
 			$sth = $this->db->prepare($query);
1494 1494
 			$sth->execute($query_values);
1495
-		} catch(PDOException $e) {
1495
+		} catch (PDOException $e) {
1496 1496
 			echo "error : ".$e->getMessage();
1497 1497
 		}
1498 1498
 	}
1499
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1499
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1500 1500
 		if ($filter_name == '') $filter_name = $this->filter_name;
1501 1501
 		global $globalArchiveMonths, $globalDBdriver;
1502
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1502
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1503 1503
 			$Spotter = new Spotter($this->db);
1504
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1504
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1505 1505
 			$alliance_airlines = array();
1506 1506
 			foreach ($airlines as $airline) {
1507
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1507
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1508 1508
 			}
1509 1509
 			if ($globalDBdriver == 'mysql') {
1510 1510
 				if ($month == '') {
1511
-					$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";
1511
+					$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";
1512 1512
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1513 1513
 				} else {
1514
-					$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";
1515
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1514
+					$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";
1515
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1516 1516
 				}
1517 1517
 			} else {
1518 1518
 				if ($month == '') {
1519
-					$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";
1519
+					$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";
1520 1520
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1521 1521
 				} else {
1522
-					$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";
1523
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1522
+					$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";
1523
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1524 1524
 				}
1525 1525
 			}
1526 1526
 		} else {
1527 1527
 			if ($globalDBdriver == 'mysql') {
1528 1528
 				if ($month == '') {
1529 1529
 					$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";
1530
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1530
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1531 1531
 				} else {
1532 1532
 					$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";
1533
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1533
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1534 1534
 				}
1535 1535
 			} else {
1536 1536
 				if ($month == '') {
1537 1537
 					$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";
1538
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1538
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1539 1539
 				} else {
1540 1540
 					$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";
1541
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1541
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1542 1542
 				}
1543 1543
 			}
1544 1544
 		}
1545 1545
 		try {
1546 1546
 			$sth = $this->db->prepare($query);
1547 1547
 			$sth->execute($query_values);
1548
-		} catch(PDOException $e) {
1548
+		} catch (PDOException $e) {
1549 1549
 			echo "error : ".$e->getMessage();
1550 1550
 		}
1551 1551
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1554,17 +1554,17 @@  discard block
 block discarded – undo
1554 1554
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1555 1555
 		global $globalArchiveMonths, $globalDBdriver;
1556 1556
 		if ($filter_name == '') $filter_name = $this->filter_name;
1557
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1557
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1558 1558
 			$Spotter = new Spotter($this->db);
1559
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1559
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1560 1560
 			$alliance_airlines = array();
1561 1561
 			foreach ($airlines as $airline) {
1562
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1562
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1563 1563
 			}
1564 1564
 			if ($globalDBdriver == 'mysql') {
1565
-				$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";
1565
+				$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";
1566 1566
 			} else {
1567
-				$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";
1567
+				$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";
1568 1568
 			}
1569 1569
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1570 1570
 		} else {
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		try {
1579 1579
 			$sth = $this->db->prepare($query);
1580 1580
 			$sth->execute($query_values);
1581
-		} catch(PDOException $e) {
1581
+		} catch (PDOException $e) {
1582 1582
 			echo "error : ".$e->getMessage();
1583 1583
 		}
1584 1584
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1587,17 +1587,17 @@  discard block
 block discarded – undo
1587 1587
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1588 1588
 		global $globalArchiveMonths, $globalDBdriver;
1589 1589
 		if ($filter_name == '') $filter_name = $this->filter_name;
1590
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1590
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1591 1591
 			$Spotter = new Spotter($this->db);
1592
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1592
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1593 1593
 			$alliance_airlines = array();
1594 1594
 			foreach ($airlines as $airline) {
1595
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1595
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1596 1596
 			}
1597 1597
 			if ($globalDBdriver == 'mysql') {
1598
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1598
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1599 1599
 			} else {
1600
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1600
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1601 1601
 			}
1602 1602
 		} else {
1603 1603
 			if ($globalDBdriver == 'mysql') {
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
 		try {
1610 1610
 			$sth = $this->db->prepare($query);
1611 1611
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1612
-		} catch(PDOException $e) {
1612
+		} catch (PDOException $e) {
1613 1613
 			echo "error : ".$e->getMessage();
1614 1614
 		}
1615 1615
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 		try {
1627 1627
 			$sth = $this->db->prepare($query);
1628 1628
 			$sth->execute(array(':filter_name' => $filter_name));
1629
-		} catch(PDOException $e) {
1629
+		} catch (PDOException $e) {
1630 1630
 			echo "error : ".$e->getMessage();
1631 1631
 		}
1632 1632
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1643,20 +1643,20 @@  discard block
 block discarded – undo
1643 1643
 		try {
1644 1644
 			$sth = $this->db->prepare($query);
1645 1645
 			$sth->execute(array(':filter_name' => $filter_name));
1646
-		} catch(PDOException $e) {
1646
+		} catch (PDOException $e) {
1647 1647
 			echo "error : ".$e->getMessage();
1648 1648
 		}
1649 1649
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1650 1650
 		return $all[0]['total'];
1651 1651
 	}
1652
-	public function getStatsOwner($owner_name,$filter_name = '') {
1652
+	public function getStatsOwner($owner_name, $filter_name = '') {
1653 1653
 		global $globalArchiveMonths, $globalDBdriver;
1654 1654
 		if ($filter_name == '') $filter_name = $this->filter_name;
1655 1655
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1656 1656
 		try {
1657 1657
 			$sth = $this->db->prepare($query);
1658
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1659
-		} catch(PDOException $e) {
1658
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1659
+		} catch (PDOException $e) {
1660 1660
 			echo "error : ".$e->getMessage();
1661 1661
 		}
1662 1662
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1674,20 +1674,20 @@  discard block
 block discarded – undo
1674 1674
 		try {
1675 1675
 			$sth = $this->db->prepare($query);
1676 1676
 			$sth->execute(array(':filter_name' => $filter_name));
1677
-		} catch(PDOException $e) {
1677
+		} catch (PDOException $e) {
1678 1678
 			echo "error : ".$e->getMessage();
1679 1679
 		}
1680 1680
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1681 1681
 		return $all[0]['total'];
1682 1682
 	}
1683
-	public function getStatsPilot($pilot,$filter_name = '') {
1683
+	public function getStatsPilot($pilot, $filter_name = '') {
1684 1684
 		global $globalArchiveMonths, $globalDBdriver;
1685 1685
 		if ($filter_name == '') $filter_name = $this->filter_name;
1686 1686
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1687 1687
 		try {
1688 1688
 			$sth = $this->db->prepare($query);
1689
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1690
-		} catch(PDOException $e) {
1689
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1690
+		} catch (PDOException $e) {
1691 1691
 			echo "error : ".$e->getMessage();
1692 1692
 		}
1693 1693
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 		else return 0;
1696 1696
 	}
1697 1697
 
1698
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1698
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1699 1699
 		global $globalDBdriver;
1700 1700
 		if ($filter_name == '') $filter_name = $this->filter_name;
1701 1701
 		if ($globalDBdriver == 'mysql') {
@@ -1703,15 +1703,15 @@  discard block
 block discarded – undo
1703 1703
 		} else {
1704 1704
 			$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);"; 
1705 1705
 		}
1706
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1706
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1707 1707
 		try {
1708 1708
 			$sth = $this->db->prepare($query);
1709 1709
 			$sth->execute($query_values);
1710
-		} catch(PDOException $e) {
1710
+		} catch (PDOException $e) {
1711 1711
 			return "error : ".$e->getMessage();
1712 1712
 		}
1713 1713
 	}
1714
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1714
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1715 1715
 		global $globalDBdriver;
1716 1716
 		if ($filter_name == '') $filter_name = $this->filter_name;
1717 1717
 		if ($globalDBdriver == 'mysql') {
@@ -1720,11 +1720,11 @@  discard block
 block discarded – undo
1720 1720
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1721 1721
 			$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);"; 
1722 1722
 		}
1723
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1723
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1724 1724
 		try {
1725 1725
 			$sth = $this->db->prepare($query);
1726 1726
 			$sth->execute($query_values);
1727
-		} catch(PDOException $e) {
1727
+		} catch (PDOException $e) {
1728 1728
 			return "error : ".$e->getMessage();
1729 1729
 		}
1730 1730
 	}
@@ -1748,95 +1748,95 @@  discard block
 block discarded – undo
1748 1748
         }
1749 1749
         */
1750 1750
 
1751
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1751
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1752 1752
 		global $globalDBdriver;
1753 1753
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1754 1754
 		$query_values = array();
1755 1755
 		if ($globalDBdriver == 'mysql') {
1756 1756
 			if ($year != '') {
1757 1757
 				$query .= ' AND YEAR(stats_date) = :year';
1758
-				$query_values = array_merge($query_values,array(':year' => $year));
1758
+				$query_values = array_merge($query_values, array(':year' => $year));
1759 1759
 			}
1760 1760
 			if ($month != '') {
1761 1761
 				$query .= ' AND MONTH(stats_date) = :month';
1762
-				$query_values = array_merge($query_values,array(':month' => $month));
1762
+				$query_values = array_merge($query_values, array(':month' => $month));
1763 1763
 			}
1764 1764
 			if ($day != '') {
1765 1765
 				$query .= ' AND DAY(stats_date) = :day';
1766
-				$query_values = array_merge($query_values,array(':day' => $day));
1766
+				$query_values = array_merge($query_values, array(':day' => $day));
1767 1767
 			}
1768 1768
 		} else {
1769 1769
 			if ($year != '') {
1770 1770
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1771
-				$query_values = array_merge($query_values,array(':year' => $year));
1771
+				$query_values = array_merge($query_values, array(':year' => $year));
1772 1772
 			}
1773 1773
 			if ($month != '') {
1774 1774
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1775
-				$query_values = array_merge($query_values,array(':month' => $month));
1775
+				$query_values = array_merge($query_values, array(':month' => $month));
1776 1776
 			}
1777 1777
 			if ($day != '') {
1778 1778
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1779
-				$query_values = array_merge($query_values,array(':day' => $day));
1779
+				$query_values = array_merge($query_values, array(':day' => $day));
1780 1780
 			}
1781 1781
 		}
1782 1782
 		$query .= " ORDER BY source_name";
1783
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1783
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1784 1784
 		try {
1785 1785
 			$sth = $this->db->prepare($query);
1786 1786
 			$sth->execute($query_values);
1787
-		} catch(PDOException $e) {
1787
+		} catch (PDOException $e) {
1788 1788
 			echo "error : ".$e->getMessage();
1789 1789
 		}
1790 1790
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1791 1791
 		return $all;
1792 1792
 	}
1793 1793
 
1794
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1794
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1795 1795
 		global $globalDBdriver;
1796 1796
 		if ($globalDBdriver == 'mysql') {
1797 1797
 			$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";
1798 1798
 		} else {
1799 1799
 			$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);"; 
1800 1800
 		}
1801
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1801
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1802 1802
 		try {
1803 1803
 			$sth = $this->db->prepare($query);
1804 1804
 			$sth->execute($query_values);
1805
-		} catch(PDOException $e) {
1805
+		} catch (PDOException $e) {
1806 1806
 			return "error : ".$e->getMessage();
1807 1807
 		}
1808 1808
 	}
1809
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1809
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1810 1810
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1811
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1811
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1812 1812
 		try {
1813 1813
 			$sth = $this->db->prepare($query);
1814 1814
 			$sth->execute($query_values);
1815
-		} catch(PDOException $e) {
1815
+		} catch (PDOException $e) {
1816 1816
 			return "error : ".$e->getMessage();
1817 1817
 		}
1818 1818
 	}
1819
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1819
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
1820 1820
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1821
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1821
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1822 1822
 		try {
1823 1823
 			$sth = $this->db->prepare($query);
1824 1824
 			$sth->execute($query_values);
1825
-		} catch(PDOException $e) {
1825
+		} catch (PDOException $e) {
1826 1826
 			return "error : ".$e->getMessage();
1827 1827
 		}
1828 1828
 	}
1829
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
1829
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
1830 1830
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1831
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1831
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1832 1832
 		try {
1833 1833
 			$sth = $this->db->prepare($query);
1834 1834
 			$sth->execute($query_values);
1835
-		} catch(PDOException $e) {
1835
+		} catch (PDOException $e) {
1836 1836
 			return "error : ".$e->getMessage();
1837 1837
 		}
1838 1838
 	}
1839
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1839
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1840 1840
 		global $globalDBdriver;
1841 1841
 		if ($globalDBdriver == 'mysql') {
1842 1842
 			if ($reset) {
@@ -1851,15 +1851,15 @@  discard block
 block discarded – undo
1851 1851
 				$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);"; 
1852 1852
 			}
1853 1853
 		}
1854
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1854
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1855 1855
 		try {
1856 1856
 			$sth = $this->db->prepare($query);
1857 1857
 			$sth->execute($query_values);
1858
-		} catch(PDOException $e) {
1858
+		} catch (PDOException $e) {
1859 1859
 			return "error : ".$e->getMessage();
1860 1860
 		}
1861 1861
 	}
1862
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1862
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1863 1863
 		global $globalDBdriver;
1864 1864
 		if ($globalDBdriver == 'mysql') {
1865 1865
 			if ($reset) {
@@ -1874,15 +1874,15 @@  discard block
 block discarded – undo
1874 1874
 				$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);"; 
1875 1875
 			}
1876 1876
 		}
1877
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1877
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1878 1878
 		try {
1879 1879
 			$sth = $this->db->prepare($query);
1880 1880
 			$sth->execute($query_values);
1881
-		} catch(PDOException $e) {
1881
+		} catch (PDOException $e) {
1882 1882
 			return "error : ".$e->getMessage();
1883 1883
 		}
1884 1884
 	}
1885
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1885
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1886 1886
 		global $globalDBdriver;
1887 1887
 		if ($globalDBdriver == 'mysql') {
1888 1888
 			if ($reset) {
@@ -1897,15 +1897,15 @@  discard block
 block discarded – undo
1897 1897
 				$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);"; 
1898 1898
 			}
1899 1899
 		}
1900
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1900
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1901 1901
 		try {
1902 1902
 			$sth = $this->db->prepare($query);
1903 1903
 			$sth->execute($query_values);
1904
-		} catch(PDOException $e) {
1904
+		} catch (PDOException $e) {
1905 1905
 			return "error : ".$e->getMessage();
1906 1906
 		}
1907 1907
 	}
1908
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1908
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1909 1909
 		global $globalDBdriver;
1910 1910
 		if ($globalDBdriver == 'mysql') {
1911 1911
 			if ($reset) {
@@ -1920,15 +1920,15 @@  discard block
 block discarded – undo
1920 1920
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1921 1921
 			}
1922 1922
 		}
1923
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1923
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1924 1924
 		try {
1925 1925
 			$sth = $this->db->prepare($query);
1926 1926
 			$sth->execute($query_values);
1927
-		} catch(PDOException $e) {
1927
+		} catch (PDOException $e) {
1928 1928
 			return "error : ".$e->getMessage();
1929 1929
 		}
1930 1930
 	}
1931
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1931
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1932 1932
 		global $globalDBdriver;
1933 1933
 		if ($globalDBdriver == 'mysql') {
1934 1934
 			if ($reset) {
@@ -1943,15 +1943,15 @@  discard block
 block discarded – undo
1943 1943
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1944 1944
 			}
1945 1945
 		}
1946
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1946
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1947 1947
 		try {
1948 1948
 			$sth = $this->db->prepare($query);
1949 1949
 			$sth->execute($query_values);
1950
-		} catch(PDOException $e) {
1950
+		} catch (PDOException $e) {
1951 1951
 			return "error : ".$e->getMessage();
1952 1952
 		}
1953 1953
 	}
1954
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1954
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1955 1955
 		global $globalDBdriver;
1956 1956
 		if ($globalDBdriver == 'mysql') {
1957 1957
 			if ($reset) {
@@ -1966,15 +1966,15 @@  discard block
 block discarded – undo
1966 1966
 				$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);"; 
1967 1967
 			}
1968 1968
 		}
1969
-		$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);
1969
+		$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);
1970 1970
 		try {
1971 1971
 			$sth = $this->db->prepare($query);
1972 1972
 			$sth->execute($query_values);
1973
-		} catch(PDOException $e) {
1973
+		} catch (PDOException $e) {
1974 1974
 			return "error : ".$e->getMessage();
1975 1975
 		}
1976 1976
 	}
1977
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1977
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1978 1978
 		global $globalDBdriver;
1979 1979
 		if ($globalDBdriver == 'mysql') {
1980 1980
 			if ($reset) {
@@ -1989,15 +1989,15 @@  discard block
 block discarded – undo
1989 1989
 				$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);"; 
1990 1990
 			}
1991 1991
 		}
1992
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1992
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1993 1993
 		try {
1994 1994
 			$sth = $this->db->prepare($query);
1995 1995
 			$sth->execute($query_values);
1996
-		} catch(PDOException $e) {
1996
+		} catch (PDOException $e) {
1997 1997
 			return "error : ".$e->getMessage();
1998 1998
 		}
1999 1999
 	}
2000
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2000
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2001 2001
 		global $globalDBdriver;
2002 2002
 		if ($globalDBdriver == 'mysql') {
2003 2003
 			if ($reset) {
@@ -2012,15 +2012,15 @@  discard block
 block discarded – undo
2012 2012
 				$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);"; 
2013 2013
 			}
2014 2014
 		}
2015
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2015
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2016 2016
 		try {
2017 2017
 			$sth = $this->db->prepare($query);
2018 2018
 			$sth->execute($query_values);
2019
-		} catch(PDOException $e) {
2019
+		} catch (PDOException $e) {
2020 2020
 			return "error : ".$e->getMessage();
2021 2021
 		}
2022 2022
 	}
2023
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2023
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2024 2024
 		global $globalDBdriver;
2025 2025
 		if ($globalDBdriver == 'mysql') {
2026 2026
 			if ($reset) {
@@ -2035,15 +2035,15 @@  discard block
 block discarded – undo
2035 2035
 				$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);"; 
2036 2036
 			}
2037 2037
 		}
2038
-		$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);
2038
+		$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);
2039 2039
 		try {
2040 2040
 			$sth = $this->db->prepare($query);
2041 2041
 			$sth->execute($query_values);
2042
-		} catch(PDOException $e) {
2042
+		} catch (PDOException $e) {
2043 2043
 			return "error : ".$e->getMessage();
2044 2044
 		}
2045 2045
 	}
2046
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2046
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2047 2047
 		global $globalDBdriver;
2048 2048
 		if ($airport_icao != '') {
2049 2049
 			if ($globalDBdriver == 'mysql') {
@@ -2059,16 +2059,16 @@  discard block
 block discarded – undo
2059 2059
 					$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);"; 
2060 2060
 				}
2061 2061
 			}
2062
-			$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);
2062
+			$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);
2063 2063
 			try {
2064 2064
 				$sth = $this->db->prepare($query);
2065 2065
 				$sth->execute($query_values);
2066
-			} catch(PDOException $e) {
2066
+			} catch (PDOException $e) {
2067 2067
 				return "error : ".$e->getMessage();
2068 2068
 			}
2069 2069
 		}
2070 2070
 	}
2071
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2071
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2072 2072
 		global $globalDBdriver;
2073 2073
 		if ($airport_icao != '') {
2074 2074
 			if ($globalDBdriver == 'mysql') {
@@ -2076,16 +2076,16 @@  discard block
 block discarded – undo
2076 2076
 			} else {
2077 2077
 				$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);"; 
2078 2078
 			}
2079
-			$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);
2079
+			$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);
2080 2080
 			 try {
2081 2081
 				$sth = $this->db->prepare($query);
2082 2082
 				$sth->execute($query_values);
2083
-			} catch(PDOException $e) {
2083
+			} catch (PDOException $e) {
2084 2084
 				return "error : ".$e->getMessage();
2085 2085
 			}
2086 2086
 		}
2087 2087
 	}
2088
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2088
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2089 2089
 		global $globalDBdriver;
2090 2090
 		if ($airport_icao != '') {
2091 2091
 			if ($globalDBdriver == 'mysql') {
@@ -2101,16 +2101,16 @@  discard block
 block discarded – undo
2101 2101
 					$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);"; 
2102 2102
 				}
2103 2103
 			}
2104
-			$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);
2104
+			$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);
2105 2105
 			try {
2106 2106
 				$sth = $this->db->prepare($query);
2107 2107
 				$sth->execute($query_values);
2108
-			} catch(PDOException $e) {
2108
+			} catch (PDOException $e) {
2109 2109
 				return "error : ".$e->getMessage();
2110 2110
 			}
2111 2111
 		}
2112 2112
 	}
2113
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2113
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2114 2114
 		global $globalDBdriver;
2115 2115
 		if ($airport_icao != '') {
2116 2116
 			if ($globalDBdriver == 'mysql') {
@@ -2118,11 +2118,11 @@  discard block
 block discarded – undo
2118 2118
 			} else {
2119 2119
 				$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);"; 
2120 2120
 			}
2121
-			$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);
2121
+			$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);
2122 2122
 			try {
2123 2123
 				$sth = $this->db->prepare($query);
2124 2124
 				$sth->execute($query_values);
2125
-			} catch(PDOException $e) {
2125
+			} catch (PDOException $e) {
2126 2126
 				return "error : ".$e->getMessage();
2127 2127
 			}
2128 2128
 		}
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
 		try {
2135 2135
 			$sth = $this->db->prepare($query);
2136 2136
 			$sth->execute($query_values);
2137
-		} catch(PDOException $e) {
2137
+		} catch (PDOException $e) {
2138 2138
 			return "error : ".$e->getMessage();
2139 2139
 		}
2140 2140
 	}
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		try {
2145 2145
 			$sth = $this->db->prepare($query);
2146 2146
 			$sth->execute($query_values);
2147
-		} catch(PDOException $e) {
2147
+		} catch (PDOException $e) {
2148 2148
 			return "error : ".$e->getMessage();
2149 2149
 		}
2150 2150
 	}
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
 		try {
2155 2155
 			$sth = $this->db->prepare($query);
2156 2156
 			$sth->execute($query_values);
2157
-		} catch(PDOException $e) {
2157
+		} catch (PDOException $e) {
2158 2158
 			return "error : ".$e->getMessage();
2159 2159
 		}
2160 2160
 	}
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
 		try {
2165 2165
 			$sth = $this->db->prepare($query);
2166 2166
 			$sth->execute($query_values);
2167
-		} catch(PDOException $e) {
2167
+		} catch (PDOException $e) {
2168 2168
 			return "error : ".$e->getMessage();
2169 2169
 		}
2170 2170
 	}
@@ -2174,13 +2174,13 @@  discard block
 block discarded – undo
2174 2174
 		try {
2175 2175
 			$sth = $this->db->prepare($query);
2176 2176
 			$sth->execute($query_values);
2177
-		} catch(PDOException $e) {
2177
+		} catch (PDOException $e) {
2178 2178
 			return "error : ".$e->getMessage();
2179 2179
 		}
2180 2180
 	}
2181 2181
 
2182 2182
 	public function addOldStats() {
2183
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2183
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2184 2184
 		$Common = new Common();
2185 2185
 		$Connection = new Connection($this->db);
2186 2186
 		date_default_timezone_set('UTC');
@@ -2195,9 +2195,9 @@  discard block
 block discarded – undo
2195 2195
 			$filtername = 'marine';
2196 2196
 			if ($Connection->tableExists('countries')) {
2197 2197
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2198
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2198
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2199 2199
 				foreach ($alldata as $number) {
2200
-					$this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2200
+					$this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2201 2201
 				}
2202 2202
 			}
2203 2203
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2207,38 +2207,38 @@  discard block
 block discarded – undo
2207 2207
 			$lastyear = false;
2208 2208
 			foreach ($alldata as $number) {
2209 2209
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2210
-				$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'])));
2210
+				$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'])));
2211 2211
 			}
2212 2212
 			echo 'Marine data...'."\n";
2213 2213
 			$this->deleteStatMarine('month');
2214 2214
 			echo '-> countAllDatesLastMonth...'."\n";
2215 2215
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2216 2216
 			foreach ($alldata as $number) {
2217
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2217
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2218 2218
 			}
2219 2219
 			echo '-> countAllDates...'."\n";
2220 2220
 			$previousdata = $this->countAllDatesMarine();
2221 2221
 			$this->deleteStatMarine('date');
2222
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2222
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2223 2223
 			$values = array();
2224 2224
 			foreach ($alldata as $cnt) {
2225 2225
 				$values[] = $cnt['date_count'];
2226 2226
 			}
2227
-			array_multisort($values,SORT_DESC,$alldata);
2228
-			array_splice($alldata,11);
2227
+			array_multisort($values, SORT_DESC, $alldata);
2228
+			array_splice($alldata, 11);
2229 2229
 			foreach ($alldata as $number) {
2230
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2230
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2231 2231
 			}
2232 2232
 			
2233 2233
 			$this->deleteStatMarine('hour');
2234 2234
 			echo '-> countAllHours...'."\n";
2235
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2235
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2236 2236
 			foreach ($alldata as $number) {
2237
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2237
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2238 2238
 			}
2239 2239
 			echo 'Insert last stats update date...'."\n";
2240 2240
 			date_default_timezone_set('UTC');
2241
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2241
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2242 2242
 		}
2243 2243
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2244 2244
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2250,9 +2250,9 @@  discard block
 block discarded – undo
2250 2250
 			$Tracker = new Tracker($this->db);
2251 2251
 			if ($Connection->tableExists('countries')) {
2252 2252
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2253
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2253
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2254 2254
 				foreach ($alldata as $number) {
2255
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2255
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2256 2256
 				}
2257 2257
 			}
2258 2258
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2262,38 +2262,38 @@  discard block
 block discarded – undo
2262 2262
 			$lastyear = false;
2263 2263
 			foreach ($alldata as $number) {
2264 2264
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2265
-				$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'])));
2265
+				$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'])));
2266 2266
 			}
2267 2267
 			echo 'Tracker data...'."\n";
2268 2268
 			$this->deleteStatTracker('month');
2269 2269
 			echo '-> countAllDatesLastMonth...'."\n";
2270 2270
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2271 2271
 			foreach ($alldata as $number) {
2272
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2272
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2273 2273
 			}
2274 2274
 			echo '-> countAllDates...'."\n";
2275 2275
 			$previousdata = $this->countAllDatesTracker();
2276 2276
 			$this->deleteStatTracker('date');
2277
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2277
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2278 2278
 			$values = array();
2279 2279
 			foreach ($alldata as $cnt) {
2280 2280
 				$values[] = $cnt['date_count'];
2281 2281
 			}
2282
-			array_multisort($values,SORT_DESC,$alldata);
2283
-			array_splice($alldata,11);
2282
+			array_multisort($values, SORT_DESC, $alldata);
2283
+			array_splice($alldata, 11);
2284 2284
 			foreach ($alldata as $number) {
2285
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2285
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2286 2286
 			}
2287 2287
 			
2288 2288
 			$this->deleteStatTracker('hour');
2289 2289
 			echo '-> countAllHours...'."\n";
2290
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2290
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2291 2291
 			foreach ($alldata as $number) {
2292
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2292
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2293 2293
 			}
2294 2294
 			echo 'Insert last stats update date...'."\n";
2295 2295
 			date_default_timezone_set('UTC');
2296
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2296
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2297 2297
 		}
2298 2298
 
2299 2299
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2311,41 +2311,41 @@  discard block
 block discarded – undo
2311 2311
 			$Spotter = new Spotter($this->db);
2312 2312
 
2313 2313
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2314
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2314
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2315 2315
 			foreach ($alldata as $number) {
2316
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2316
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2317 2317
 			}
2318 2318
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2319
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2319
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2320 2320
 			foreach ($alldata as $number) {
2321
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2321
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2322 2322
 			}
2323 2323
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2324
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2324
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2325 2325
 			foreach ($alldata as $number) {
2326
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2326
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2327 2327
 			}
2328 2328
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2329
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2329
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2330 2330
 			foreach ($alldata as $number) {
2331
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2331
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2332 2332
 			}
2333 2333
 			if ($globalDebug) echo 'Count all owners...'."\n";
2334
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2334
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2335 2335
 			foreach ($alldata as $number) {
2336
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2336
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2337 2337
 			}
2338 2338
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2339
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2339
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2340 2340
 			foreach ($alldata as $number) {
2341 2341
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2342
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2342
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2343 2343
 			}
2344 2344
 			
2345 2345
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2346
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2346
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2347 2347
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2348
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2348
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2349 2349
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2350 2350
 			$alldata = array();
2351 2351
 			foreach ($pall as $value) {
@@ -2362,14 +2362,14 @@  discard block
 block discarded – undo
2362 2362
 			foreach ($alldata as $key => $row) {
2363 2363
 				$count[$key] = $row['airport_departure_icao_count'];
2364 2364
 			}
2365
-			array_multisort($count,SORT_DESC,$alldata);
2365
+			array_multisort($count, SORT_DESC, $alldata);
2366 2366
 			foreach ($alldata as $number) {
2367
-				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);
2367
+				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);
2368 2368
 			}
2369 2369
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2370
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2370
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2371 2371
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2372
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2372
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2373 2373
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2374 2374
 			$alldata = array();
2375 2375
 			foreach ($pall as $value) {
@@ -2386,18 +2386,18 @@  discard block
 block discarded – undo
2386 2386
 			foreach ($alldata as $key => $row) {
2387 2387
 				$count[$key] = $row['airport_arrival_icao_count'];
2388 2388
 			}
2389
-			array_multisort($count,SORT_DESC,$alldata);
2389
+			array_multisort($count, SORT_DESC, $alldata);
2390 2390
 			foreach ($alldata as $number) {
2391
-				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);
2391
+				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);
2392 2392
 			}
2393 2393
 			if ($Connection->tableExists('countries')) {
2394 2394
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2395 2395
 				//$SpotterArchive = new SpotterArchive();
2396 2396
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2397 2397
 				$Spotter = new Spotter($this->db);
2398
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2398
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2399 2399
 				foreach ($alldata as $number) {
2400
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2400
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2401 2401
 				}
2402 2402
 			}
2403 2403
 			
@@ -2407,12 +2407,12 @@  discard block
 block discarded – undo
2407 2407
 				$this->deleteStatsByType('fatalities_byyear');
2408 2408
 				$alldata = $Accident->countFatalitiesByYear();
2409 2409
 				foreach ($alldata as $number) {
2410
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2410
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2411 2411
 				}
2412 2412
 				$this->deleteStatsByType('fatalities_bymonth');
2413 2413
 				$alldata = $Accident->countFatalitiesLast12Months();
2414 2414
 				foreach ($alldata as $number) {
2415
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2415
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2416 2416
 				}
2417 2417
 			}
2418 2418
 
@@ -2426,37 +2426,37 @@  discard block
 block discarded – undo
2426 2426
 			$lastyear = false;
2427 2427
 			foreach ($alldata as $number) {
2428 2428
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2429
-				$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'])));
2429
+				$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'])));
2430 2430
 			}
2431 2431
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2432 2432
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2433 2433
 			foreach ($alldata as $number) {
2434
-				$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'])));
2434
+				$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'])));
2435 2435
 			}
2436 2436
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2437 2437
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2438 2438
 			foreach ($alldata as $number) {
2439
-				$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'])));
2439
+				$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'])));
2440 2440
 			}
2441 2441
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2442 2442
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2443 2443
 			foreach ($alldata as $number) {
2444
-				$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'])));
2444
+				$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'])));
2445 2445
 			}
2446 2446
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2447 2447
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2448 2448
 			foreach ($alldata as $number) {
2449
-				$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'])));
2449
+				$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'])));
2450 2450
 			}
2451 2451
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2452 2452
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2453 2453
 			foreach ($alldata as $number) {
2454
-				$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'])));
2454
+				$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'])));
2455 2455
 			}
2456 2456
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2457 2457
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2458 2458
 			foreach ($alldata as $number) {
2459
-				$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'])));
2459
+				$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'])));
2460 2460
 			}
2461 2461
 			if ($globalDebug) echo 'Airports data...'."\n";
2462 2462
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
 			}
2502 2502
 			$alldata = $pall;
2503 2503
 			foreach ($alldata as $number) {
2504
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2504
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2505 2505
 			}
2506 2506
 			echo '...Arrival'."\n";
2507 2507
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2542,7 +2542,7 @@  discard block
 block discarded – undo
2542 2542
 			}
2543 2543
 			$alldata = $pall;
2544 2544
 			foreach ($alldata as $number) {
2545
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2545
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2546 2546
 			}
2547 2547
 
2548 2548
 			echo 'Flights data...'."\n";
@@ -2550,28 +2550,28 @@  discard block
 block discarded – undo
2550 2550
 			echo '-> countAllDatesLastMonth...'."\n";
2551 2551
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2552 2552
 			foreach ($alldata as $number) {
2553
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2553
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2554 2554
 			}
2555 2555
 			echo '-> countAllDates...'."\n";
2556 2556
 			$previousdata = $this->countAllDates();
2557 2557
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2558 2558
 			$this->deleteStatFlight('date');
2559
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2559
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2560 2560
 			$values = array();
2561 2561
 			foreach ($alldata as $cnt) {
2562 2562
 				$values[] = $cnt['date_count'];
2563 2563
 			}
2564
-			array_multisort($values,SORT_DESC,$alldata);
2565
-			array_splice($alldata,11);
2564
+			array_multisort($values, SORT_DESC, $alldata);
2565
+			array_splice($alldata, 11);
2566 2566
 			foreach ($alldata as $number) {
2567
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2567
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2568 2568
 			}
2569 2569
 			
2570 2570
 			$this->deleteStatFlight('hour');
2571 2571
 			echo '-> countAllHours...'."\n";
2572
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2572
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2573 2573
 			foreach ($alldata as $number) {
2574
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2574
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2575 2575
 			}
2576 2576
 
2577 2577
 			// Count by airlines
@@ -2580,42 +2580,42 @@  discard block
 block discarded – undo
2580 2580
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2581 2581
 				$SpotterArchive = new SpotterArchive($this->db);
2582 2582
 				//$Spotter = new Spotter($this->db);
2583
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2583
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2584 2584
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2585 2585
 				foreach ($alldata as $number) {
2586
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2586
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2587 2587
 				}
2588 2588
 			}
2589 2589
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2590 2590
 			$Spotter = new Spotter($this->db);
2591
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2591
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2592 2592
 			foreach ($alldata as $number) {
2593
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2593
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2594 2594
 			}
2595 2595
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2596
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2596
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2597 2597
 			foreach ($alldata as $number) {
2598
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2598
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2599 2599
 			}
2600 2600
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2601
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2601
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2602 2602
 			foreach ($alldata as $number) {
2603
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2603
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2604 2604
 			}
2605 2605
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2606
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2606
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2607 2607
 			foreach ($alldata as $number) {
2608
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2608
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2609 2609
 			}
2610 2610
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2611
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2611
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2612 2612
 			foreach ($alldata as $number) {
2613
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2613
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2614 2614
 			}
2615 2615
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2616
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2616
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2617 2617
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2618
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2618
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2619 2619
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2620 2620
 			//$alldata = array();
2621 2621
 			foreach ($dall as $value) {
@@ -2635,12 +2635,12 @@  discard block
 block discarded – undo
2635 2635
 			}
2636 2636
 			$alldata = $pall;
2637 2637
 			foreach ($alldata as $number) {
2638
-				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);
2638
+				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);
2639 2639
 			}
2640 2640
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2641
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2641
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2642 2642
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2643
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2643
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2644 2644
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2645 2645
 			//$alldata = array();
2646 2646
 			foreach ($dall as $value) {
@@ -2660,7 +2660,7 @@  discard block
 block discarded – undo
2660 2660
 			}
2661 2661
 			$alldata = $pall;
2662 2662
 			foreach ($alldata as $number) {
2663
-				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);
2663
+				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);
2664 2664
 			}
2665 2665
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2666 2666
 			$Spotter = new Spotter($this->db);
@@ -2668,27 +2668,27 @@  discard block
 block discarded – undo
2668 2668
 			$lastyear = false;
2669 2669
 			foreach ($alldata as $number) {
2670 2670
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2671
-				$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']);
2671
+				$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']);
2672 2672
 			}
2673 2673
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2674 2674
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2675 2675
 			foreach ($alldata as $number) {
2676
-				$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']);
2676
+				$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']);
2677 2677
 			}
2678 2678
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2679 2679
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2680 2680
 			foreach ($alldata as $number) {
2681
-				$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']);
2681
+				$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']);
2682 2682
 			}
2683 2683
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2684 2684
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2685 2685
 			foreach ($alldata as $number) {
2686
-				$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']);
2686
+				$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']);
2687 2687
 			}
2688 2688
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2689 2689
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2690 2690
 			foreach ($alldata as $number) {
2691
-				$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']);
2691
+				$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']);
2692 2692
 			}
2693 2693
 			if ($globalDebug) echo '...Departure'."\n";
2694 2694
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
 			}
2712 2712
 			$alldata = $pall;
2713 2713
 			foreach ($alldata as $number) {
2714
-				$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']);
2714
+				$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']);
2715 2715
 			}
2716 2716
 			if ($globalDebug) echo '...Arrival'."\n";
2717 2717
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -2734,32 +2734,32 @@  discard block
 block discarded – undo
2734 2734
 			}
2735 2735
 			$alldata = $pall;
2736 2736
 			foreach ($alldata as $number) {
2737
-				$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']);
2737
+				$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']);
2738 2738
 			}
2739 2739
 
2740 2740
 			if ($globalDebug) echo 'Flights data...'."\n";
2741 2741
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2742 2742
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2743 2743
 			foreach ($alldata as $number) {
2744
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2744
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
2745 2745
 			}
2746 2746
 			if ($globalDebug) echo '-> countAllDates...'."\n";
2747 2747
 			//$previousdata = $this->countAllDatesByAirlines();
2748
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2748
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
2749 2749
 			$values = array();
2750 2750
 			foreach ($alldata as $cnt) {
2751 2751
 				$values[] = $cnt['date_count'];
2752 2752
 			}
2753
-			array_multisort($values,SORT_DESC,$alldata);
2754
-			array_splice($alldata,11);
2753
+			array_multisort($values, SORT_DESC, $alldata);
2754
+			array_splice($alldata, 11);
2755 2755
 			foreach ($alldata as $number) {
2756
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2756
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
2757 2757
 			}
2758 2758
 			
2759 2759
 			if ($globalDebug) echo '-> countAllHours...'."\n";
2760
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2760
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
2761 2761
 			foreach ($alldata as $number) {
2762
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2762
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
2763 2763
 			}
2764 2764
 
2765 2765
 			// Stats by filters
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 							$last_update_day = date('Y').'-01-01 00:00:00';
2784 2784
 						}
2785 2785
 					}
2786
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2786
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2787 2787
 						$last_update_day = date('Y').'-01-01 00:00:00';
2788 2788
 						$reset = true;
2789 2789
 					}
@@ -2791,38 +2791,38 @@  discard block
 block discarded – undo
2791 2791
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2792 2792
 					$Spotter = new Spotter($this->db);
2793 2793
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
2794
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2794
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2795 2795
 					foreach ($alldata as $number) {
2796
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2796
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2797 2797
 					}
2798 2798
 					if ($globalDebug) echo 'Count all airlines...'."\n";
2799
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2799
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2800 2800
 					foreach ($alldata as $number) {
2801
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2801
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2802 2802
 					}
2803 2803
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
2804
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2804
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2805 2805
 					foreach ($alldata as $number) {
2806
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2806
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2807 2807
 					}
2808 2808
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
2809
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2809
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2810 2810
 					foreach ($alldata as $number) {
2811
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2811
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2812 2812
 					}
2813 2813
 					if ($globalDebug) echo 'Count all owners...'."\n";
2814
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2814
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2815 2815
 					foreach ($alldata as $number) {
2816
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2816
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2817 2817
 					}
2818 2818
 					if ($globalDebug) echo 'Count all pilots...'."\n";
2819
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2819
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2820 2820
 					foreach ($alldata as $number) {
2821
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2821
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2822 2822
 					}
2823 2823
 					if ($globalDebug) echo 'Count departure airports...'."\n";
2824
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2825
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2824
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2825
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2826 2826
 					$alldata = array();
2827 2827
 					foreach ($pall as $value) {
2828 2828
 						$icao = $value['airport_departure_icao'];
@@ -2838,13 +2838,13 @@  discard block
 block discarded – undo
2838 2838
 					foreach ($alldata as $key => $row) {
2839 2839
 						$count[$key] = $row['airport_departure_icao_count'];
2840 2840
 					}
2841
-					array_multisort($count,SORT_DESC,$alldata);
2841
+					array_multisort($count, SORT_DESC, $alldata);
2842 2842
 					foreach ($alldata as $number) {
2843
-						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);
2843
+						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);
2844 2844
 					}
2845 2845
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
2846
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2847
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2846
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2847
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2848 2848
 					$alldata = array();
2849 2849
 					foreach ($pall as $value) {
2850 2850
 						$icao = $value['airport_arrival_icao'];
@@ -2860,9 +2860,9 @@  discard block
 block discarded – undo
2860 2860
 					foreach ($alldata as $key => $row) {
2861 2861
 						$count[$key] = $row['airport_arrival_icao_count'];
2862 2862
 					}
2863
-					array_multisort($count,SORT_DESC,$alldata);
2863
+					array_multisort($count, SORT_DESC, $alldata);
2864 2864
 					foreach ($alldata as $number) {
2865
-						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);
2865
+						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);
2866 2866
 					}
2867 2867
 					if ($globalDebug) echo 'Count all months...'."\n";
2868 2868
 					$Spotter = new Spotter($this->db);
@@ -2870,36 +2870,36 @@  discard block
 block discarded – undo
2870 2870
 					$lastyear = false;
2871 2871
 					foreach ($alldata as $number) {
2872 2872
 						if ($number['year_name'] != date('Y')) $lastyear = true;
2873
-						$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);
2873
+						$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);
2874 2874
 					}
2875 2875
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
2876 2876
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2877 2877
 					foreach ($alldata as $number) {
2878
-						$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);
2878
+						$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);
2879 2879
 					}
2880 2880
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
2881 2881
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2882 2882
 					foreach ($alldata as $number) {
2883
-						$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);
2883
+						$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);
2884 2884
 					}
2885 2885
 					if ($globalDebug) echo 'Count all military by months...'."\n";
2886 2886
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2887 2887
 					foreach ($alldata as $number) {
2888
-						$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);
2888
+						$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);
2889 2889
 					}
2890 2890
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2891 2891
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2892 2892
 				    	foreach ($alldata as $number) {
2893
-			    			$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);
2893
+			    			$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);
2894 2894
 					}
2895 2895
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2896 2896
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2897 2897
 					foreach ($alldata as $number) {
2898
-						$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);
2898
+						$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);
2899 2899
 					}
2900 2900
 					echo '...Departure'."\n";
2901
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2902
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2901
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2902
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2903 2903
 					foreach ($dall as $value) {
2904 2904
 						$icao = $value['departure_airport_icao'];
2905 2905
 						$ddate = $value['date'];
@@ -2917,11 +2917,11 @@  discard block
 block discarded – undo
2917 2917
 					}
2918 2918
 					$alldata = $pall;
2919 2919
 					foreach ($alldata as $number) {
2920
-						$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);
2920
+						$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);
2921 2921
 					}
2922 2922
 					echo '...Arrival'."\n";
2923
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2924
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2923
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2924
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2925 2925
 					foreach ($dall as $value) {
2926 2926
 						$icao = $value['arrival_airport_icao'];
2927 2927
 						$ddate = $value['date'];
@@ -2939,39 +2939,39 @@  discard block
 block discarded – undo
2939 2939
 					}
2940 2940
 					$alldata = $pall;
2941 2941
 					foreach ($alldata as $number) {
2942
-						$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);
2942
+						$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);
2943 2943
 					}
2944 2944
 					echo 'Flights data...'."\n";
2945 2945
 					echo '-> countAllDatesLastMonth...'."\n";
2946 2946
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
2947 2947
 					foreach ($alldata as $number) {
2948
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2948
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2949 2949
 					}
2950 2950
 					echo '-> countAllDates...'."\n";
2951
-					$previousdata = $this->countAllDates('',$filter_name);
2952
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2951
+					$previousdata = $this->countAllDates('', $filter_name);
2952
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2953 2953
 					$values = array();
2954 2954
 					foreach ($alldata as $cnt) {
2955 2955
 						$values[] = $cnt['date_count'];
2956 2956
 					}
2957
-					array_multisort($values,SORT_DESC,$alldata);
2958
-					array_splice($alldata,11);
2957
+					array_multisort($values, SORT_DESC, $alldata);
2958
+					array_splice($alldata, 11);
2959 2959
 					foreach ($alldata as $number) {
2960
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2960
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2961 2961
 					}
2962 2962
 				
2963 2963
 					echo '-> countAllHours...'."\n";
2964
-					$alldata = $Spotter->countAllHours('hour',$filter);
2964
+					$alldata = $Spotter->countAllHours('hour', $filter);
2965 2965
 					foreach ($alldata as $number) {
2966
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2966
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2967 2967
 					}
2968 2968
 					echo 'Insert last stats update date...'."\n";
2969 2969
 					date_default_timezone_set('UTC');
2970
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2970
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2971 2971
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2972
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
2972
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
2973 2973
 							$this->deleteOldStats($filter_name);
2974
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2974
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2975 2975
 						}
2976 2976
 					}
2977 2977
 				}
@@ -2984,16 +2984,16 @@  discard block
 block discarded – undo
2984 2984
 				// SUM all previous month to put as year
2985 2985
 				$previous_year = date('Y');
2986 2986
 				$previous_year--;
2987
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2988
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2989
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2990
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2987
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2988
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2989
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2990
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2991 2991
 				$allairlines = $this->getAllAirlineNames();
2992 2992
 				foreach ($allairlines as $data) {
2993
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2994
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2995
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2996
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2993
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2994
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2995
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2996
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2997 2997
 				}
2998 2998
 				
2999 2999
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3002,21 +3002,21 @@  discard block
 block discarded – undo
3002 3002
 						try {
3003 3003
 							$sth = $this->db->prepare($query);
3004 3004
 							$sth->execute();
3005
-						} catch(PDOException $e) {
3005
+						} catch (PDOException $e) {
3006 3006
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3007 3007
 						}
3008 3008
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3009 3009
 						try {
3010 3010
 							$sth = $this->db->prepare($query);
3011 3011
 							$sth->execute();
3012
-						} catch(PDOException $e) {
3012
+						} catch (PDOException $e) {
3013 3013
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3014 3014
 						}
3015 3015
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3016 3016
 						try {
3017 3017
 							$sth = $this->db->prepare($query);
3018 3018
 							$sth->execute();
3019
-						} catch(PDOException $e) {
3019
+						} catch (PDOException $e) {
3020 3020
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3021 3021
 						}
3022 3022
 					}
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
 					try {
3030 3030
 						$sth = $this->db->prepare($query);
3031 3031
 						$sth->execute();
3032
-					} catch(PDOException $e) {
3032
+					} catch (PDOException $e) {
3033 3033
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3034 3034
 					}
3035 3035
 					if ($globalDBdriver == 'mysql') {
@@ -3040,7 +3040,7 @@  discard block
 block discarded – undo
3040 3040
 					try {
3041 3041
 						$sth = $this->db->prepare($query);
3042 3042
 						$sth->execute();
3043
-					} catch(PDOException $e) {
3043
+					} catch (PDOException $e) {
3044 3044
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3045 3045
 					}
3046 3046
 					if ($globalDBdriver == 'mysql') {
@@ -3051,15 +3051,15 @@  discard block
 block discarded – undo
3051 3051
 					try {
3052 3052
 						$sth = $this->db->prepare($query);
3053 3053
 						$sth->execute();
3054
-					} catch(PDOException $e) {
3054
+					} catch (PDOException $e) {
3055 3055
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3056 3056
 					}
3057 3057
 				}
3058 3058
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3059 3059
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3060
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3060
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3061 3061
 						$this->deleteOldStats();
3062
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3062
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3063 3063
 						$lastyearupdate = true;
3064 3064
 					}
3065 3065
 				}
@@ -3081,7 +3081,7 @@  discard block
 block discarded – undo
3081 3081
 					try {
3082 3082
 						$sth = $this->db->prepare($query);
3083 3083
 						$sth->execute();
3084
-					} catch(PDOException $e) {
3084
+					} catch (PDOException $e) {
3085 3085
 						return "error : ".$e->getMessage();
3086 3086
 					}
3087 3087
 					echo 'Archive old tracker data...'."\n";
@@ -3097,7 +3097,7 @@  discard block
 block discarded – undo
3097 3097
 					try {
3098 3098
 						$sth = $this->db->prepare($query);
3099 3099
 						$sth->execute();
3100
-					} catch(PDOException $e) {
3100
+					} catch (PDOException $e) {
3101 3101
 						return "error : ".$e->getMessage();
3102 3102
 					}
3103 3103
 					echo 'Archive old marine data...'."\n";
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 					try {
3114 3114
 						$sth = $this->db->prepare($query);
3115 3115
 						$sth->execute();
3116
-					} catch(PDOException $e) {
3116
+					} catch (PDOException $e) {
3117 3117
 						return "error : ".$e->getMessage();
3118 3118
 					}
3119 3119
 				}
@@ -3126,7 +3126,7 @@  discard block
 block discarded – undo
3126 3126
 				try {
3127 3127
 					$sth = $this->db->prepare($query);
3128 3128
 					$sth->execute();
3129
-				} catch(PDOException $e) {
3129
+				} catch (PDOException $e) {
3130 3130
 					return "error : ".$e->getMessage();
3131 3131
 				}
3132 3132
 				echo 'Deleting old tracker data...'."\n";
@@ -3138,7 +3138,7 @@  discard block
 block discarded – undo
3138 3138
 				try {
3139 3139
 					$sth = $this->db->prepare($query);
3140 3140
 					$sth->execute();
3141
-				} catch(PDOException $e) {
3141
+				} catch (PDOException $e) {
3142 3142
 					return "error : ".$e->getMessage();
3143 3143
 				}
3144 3144
 				echo 'Deleting old marine data...'."\n";
@@ -3150,14 +3150,14 @@  discard block
 block discarded – undo
3150 3150
 				try {
3151 3151
 					$sth = $this->db->prepare($query);
3152 3152
 					$sth->execute();
3153
-				} catch(PDOException $e) {
3153
+				} catch (PDOException $e) {
3154 3154
 					return "error : ".$e->getMessage();
3155 3155
 				}
3156 3156
 			}
3157 3157
 			if (!isset($lastyearupdate)) {
3158 3158
 				echo 'Insert last stats update date...'."\n";
3159 3159
 				date_default_timezone_set('UTC');
3160
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3160
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3161 3161
 			}
3162 3162
 			if ($globalStatsResetYear) {
3163 3163
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +698 added lines, -244 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 countAllAirlineCountries($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 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";
226
-			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";
255
+			if ($limit) {
256
+				$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";
257
+			} else {
258
+				$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";
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
 			$Spotter = new Spotter($this->db);
237 272
 			$filters = array();
@@ -246,7 +281,9 @@  discard block
 block discarded – undo
246 281
 	}
247 282
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
248 283
 		global $globalStatsFilters;
249
-		if ($filter_name == '') $filter_name = $this->filter_name;
284
+		if ($filter_name == '') {
285
+			$filter_name = $this->filter_name;
286
+		}
250 287
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
251 288
 			$Spotter = new Spotter($this->db);
252 289
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -255,8 +292,11 @@  discard block
 block discarded – undo
255 292
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
256 293
 			}
257 294
 			if ($year == '' && $month == '') {
258
-				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";
259
-				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";
295
+				if ($limit) {
296
+					$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";
297
+				} else {
298
+					$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";
299
+				}
260 300
 				try {
261 301
 					$sth = $this->db->prepare($query);
262 302
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -264,11 +304,16 @@  discard block
 block discarded – undo
264 304
 					echo "error : ".$e->getMessage();
265 305
 				}
266 306
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
267
-			} else $all = array();
307
+			} else {
308
+				$all = array();
309
+			}
268 310
 		} else {
269 311
 			if ($year == '' && $month == '') {
270
-				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";
271
-				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";
312
+				if ($limit) {
313
+					$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";
314
+				} else {
315
+					$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";
316
+				}
272 317
 				try {
273 318
 					$sth = $this->db->prepare($query);
274 319
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -276,7 +321,9 @@  discard block
 block discarded – undo
276 321
 					echo "error : ".$e->getMessage();
277 322
 				}
278 323
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
279
-			} else $all = array();
324
+			} else {
325
+				$all = array();
326
+			}
280 327
 		}
281 328
 		if (empty($all)) {
282 329
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -296,7 +343,9 @@  discard block
 block discarded – undo
296 343
 
297 344
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
298 345
 		global $globalStatsFilters;
299
-		if ($filter_name == '') $filter_name = $this->filter_name;
346
+		if ($filter_name == '') {
347
+			$filter_name = $this->filter_name;
348
+		}
300 349
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
301 350
 			$Spotter = new Spotter($this->db);
302 351
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -305,8 +354,11 @@  discard block
 block discarded – undo
305 354
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
306 355
 			}
307 356
 			if ($year == '' && $month == '') {
308
-				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";
309
-				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";
357
+				if ($limit) {
358
+					$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";
359
+				} else {
360
+					$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";
361
+				}
310 362
 				try {
311 363
 					$sth = $this->db->prepare($query);
312 364
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -314,11 +366,16 @@  discard block
 block discarded – undo
314 366
 					echo "error : ".$e->getMessage();
315 367
 				}
316 368
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
317
-			} else $all = array();
369
+			} else {
370
+				$all = array();
371
+			}
318 372
 		} else {
319 373
 			if ($year == '' && $month == '') {
320
-				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";
321
-				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";
374
+				if ($limit) {
375
+					$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";
376
+				} else {
377
+					$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";
378
+				}
322 379
 				try {
323 380
 					$sth = $this->db->prepare($query);
324 381
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -326,7 +383,9 @@  discard block
 block discarded – undo
326 383
 					echo "error : ".$e->getMessage();
327 384
 				}
328 385
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
329
-			} else $all = array();
386
+			} else {
387
+				$all = array();
388
+			}
330 389
 		}
331 390
 		if (empty($all)) {
332 391
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -345,7 +404,9 @@  discard block
 block discarded – undo
345 404
 	}
346 405
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
347 406
 		global $globalStatsFilters;
348
-		if ($filter_name == '') $filter_name = $this->filter_name;
407
+		if ($filter_name == '') {
408
+			$filter_name = $this->filter_name;
409
+		}
349 410
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
350 411
 			$Spotter = new Spotter($this->db);
351 412
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -353,12 +414,18 @@  discard block
 block discarded – undo
353 414
 			foreach ($airlines as $airline) {
354 415
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
355 416
 			}
356
-			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";
357
-			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";
417
+			if ($limit) {
418
+				$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";
419
+			} else {
420
+				$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";
421
+			}
358 422
 			$query_values = array(':filter_name' => $filter_name);
359 423
 		} else {
360
-			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";
361
-			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";
424
+			if ($limit) {
425
+				$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";
426
+			} else {
427
+				$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";
428
+			}
362 429
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
363 430
 		}
364 431
 		try {
@@ -386,17 +453,29 @@  discard block
 block discarded – undo
386 453
 
387 454
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
388 455
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
389
-		if ($filter_name == '') $filter_name = $this->filter_name;
456
+		if ($filter_name == '') {
457
+			$filter_name = $this->filter_name;
458
+		}
390 459
 		if ($year == '' && $month == '') {
391
-			if ($globalVATSIM) $forsource = 'vatsim';
392
-			if ($globalIVAO) $forsource = 'ivao';
460
+			if ($globalVATSIM) {
461
+				$forsource = 'vatsim';
462
+			}
463
+			if ($globalIVAO) {
464
+				$forsource = 'ivao';
465
+			}
393 466
 			if (isset($forsource)) {
394
-				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";
395
-				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";
467
+				if ($limit) {
468
+					$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";
469
+				} else {
470
+					$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";
471
+				}
396 472
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
397 473
 			} else {
398
-				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";
399
-				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";
474
+				if ($limit) {
475
+					$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";
476
+				} else {
477
+					$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";
478
+				}
400 479
 				$query_values = array(':filter_name' => $filter_name);
401 480
 			}
402 481
 			try {
@@ -406,7 +485,9 @@  discard block
 block discarded – undo
406 485
 				echo "error : ".$e->getMessage();
407 486
 			}
408 487
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409
-		} else $all = array();
488
+		} else {
489
+			$all = array();
490
+		}
410 491
                 if (empty($all)) {
411 492
 	                $Spotter = new Spotter($this->db);
412 493
             		$filters = array();
@@ -421,7 +502,9 @@  discard block
 block discarded – undo
421 502
 	}
422 503
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423 504
 		global $globalStatsFilters;
424
-		if ($filter_name == '') $filter_name = $this->filter_name;
505
+		if ($filter_name == '') {
506
+			$filter_name = $this->filter_name;
507
+		}
425 508
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
426 509
 			$Spotter = new Spotter($this->db);
427 510
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -430,8 +513,11 @@  discard block
 block discarded – undo
430 513
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
431 514
 			}
432 515
 			if ($year == '' && $month == '') {
433
-				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";
434
-				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";
516
+				if ($limit) {
517
+					$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";
518
+				} else {
519
+					$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";
520
+				}
435 521
 				try {
436 522
 					$sth = $this->db->prepare($query);
437 523
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -439,11 +525,16 @@  discard block
 block discarded – undo
439 525
 					echo "error : ".$e->getMessage();
440 526
 				}
441 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
442
-			} else $all = array();
528
+			} else {
529
+				$all = array();
530
+			}
443 531
 		} else {
444 532
 			if ($year == '' && $month == '') {
445
-				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";
446
-				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";
533
+				if ($limit) {
534
+					$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";
535
+				} else {
536
+					$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";
537
+				}
447 538
 				try {
448 539
 					$sth = $this->db->prepare($query);
449 540
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -451,7 +542,9 @@  discard block
 block discarded – undo
451 542
 					echo "error : ".$e->getMessage();
452 543
 				}
453 544
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-			} else $all = array();
545
+			} else {
546
+				$all = array();
547
+			}
455 548
 		}
456 549
 		if (empty($all)) {
457 550
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -470,7 +563,9 @@  discard block
 block discarded – undo
470 563
 	}
471 564
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
472 565
 		global $globalStatsFilters;
473
-		if ($filter_name == '') $filter_name = $this->filter_name;
566
+		if ($filter_name == '') {
567
+			$filter_name = $this->filter_name;
568
+		}
474 569
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
475 570
 			$Spotter = new Spotter($this->db);
476 571
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -479,8 +574,11 @@  discard block
 block discarded – undo
479 574
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
480 575
 			}
481 576
 			if ($year == '' && $month == '') {
482
-				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";
483
-				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";
577
+				if ($limit) {
578
+					$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";
579
+				} else {
580
+					$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";
581
+				}
484 582
 				 try {
485 583
 					$sth = $this->db->prepare($query);
486 584
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -488,11 +586,16 @@  discard block
 block discarded – undo
488 586
 					echo "error : ".$e->getMessage();
489 587
 				}
490 588
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
491
-			} else $all = array();
589
+			} else {
590
+				$all = array();
591
+			}
492 592
 		} else {
493 593
 			if ($year == '' && $month == '') {
494
-				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";
495
-				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";
594
+				if ($limit) {
595
+					$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";
596
+				} else {
597
+					$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";
598
+				}
496 599
 				 try {
497 600
 					$sth = $this->db->prepare($query);
498 601
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -500,7 +603,9 @@  discard block
 block discarded – undo
500 603
 					echo "error : ".$e->getMessage();
501 604
 				}
502 605
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-			} else $all = array();
606
+			} else {
607
+				$all = array();
608
+			}
504 609
 		}
505 610
 		if (empty($all)) {
506 611
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -519,7 +624,9 @@  discard block
 block discarded – undo
519 624
 	}
520 625
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
521 626
 		$Connection = new Connection($this->db);
522
-		if ($filter_name == '') $filter_name = $this->filter_name;
627
+		if ($filter_name == '') {
628
+			$filter_name = $this->filter_name;
629
+		}
523 630
 		if ($Connection->tableExists('countries')) {
524 631
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
525 632
 				$Spotter = new Spotter($this->db);
@@ -529,8 +636,11 @@  discard block
 block discarded – undo
529 636
 					foreach ($airlines as $airline) {
530 637
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
531 638
 					}
532
-					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";
533
-					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";
639
+					if ($limit) {
640
+						$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";
641
+					} else {
642
+						$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";
643
+					}
534 644
 					 try {
535 645
 						$sth = $this->db->prepare($query);
536 646
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -539,11 +649,16 @@  discard block
 block discarded – undo
539 649
 					}
540 650
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541 651
 					return $all;
542
-				} else return array();
652
+				} else {
653
+					return array();
654
+				}
543 655
 			} else {
544 656
 				if ($year == '' && $month == '') {
545
-					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";
546
-					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";
657
+					if ($limit) {
658
+						$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";
659
+					} else {
660
+						$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";
661
+					}
547 662
 					 try {
548 663
 						$sth = $this->db->prepare($query);
549 664
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -552,19 +667,28 @@  discard block
 block discarded – undo
552 667
 					}
553 668
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 669
 					return $all;
555
-				} else return array();
670
+				} else {
671
+					return array();
672
+				}
556 673
 			}
557 674
 			$Spotter = new Spotter($this->db);
558 675
 			return $Spotter->countAllFlightOverCountries($limit);
559
-		} else return array();
676
+		} else {
677
+			return array();
678
+		}
560 679
 	}
561 680
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
562 681
 		$Connection = new Connection($this->db);
563
-		if ($filter_name == '') $filter_name = $this->filter_name;
682
+		if ($filter_name == '') {
683
+			$filter_name = $this->filter_name;
684
+		}
564 685
 		if ($Connection->tableExists('countries')) {
565 686
 			if ($year == '' && $month == '') {
566
-				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";
567
-				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";
687
+				if ($limit) {
688
+					$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";
689
+				} else {
690
+					$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";
691
+				}
568 692
 				 try {
569 693
 					$sth = $this->db->prepare($query);
570 694
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -580,15 +704,22 @@  discard block
 block discarded – undo
580 704
 			}
581 705
 			$Marine = new Marine($this->db);
582 706
 			return $Marine->countAllMarineOverCountries($limit,$filters,$year,$month);
583
-		} else return array();
707
+		} else {
708
+			return array();
709
+		}
584 710
 	}
585 711
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
586 712
 		$Connection = new Connection($this->db);
587
-		if ($filter_name == '') $filter_name = $this->filter_name;
713
+		if ($filter_name == '') {
714
+			$filter_name = $this->filter_name;
715
+		}
588 716
 		if ($Connection->tableExists('countries')) {
589 717
 			if ($year == '' && $month == '') {
590
-				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";
591
-				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";
718
+				if ($limit) {
719
+					$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";
720
+				} else {
721
+					$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";
722
+				}
592 723
 				 try {
593 724
 					$sth = $this->db->prepare($query);
594 725
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -600,14 +731,21 @@  discard block
 block discarded – undo
600 731
 			}
601 732
 			$Tracker = new Tracker($this->db);
602 733
 			return $Tracker->countAllTrackerOverCountries($limit,$filters,$year,$month);
603
-		} else return array();
734
+		} else {
735
+			return array();
736
+		}
604 737
 	}
605 738
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
606 739
 		global $globalStatsFilters;
607
-		if ($filter_name == '') $filter_name = $this->filter_name;
740
+		if ($filter_name == '') {
741
+			$filter_name = $this->filter_name;
742
+		}
608 743
 		if ($year == '' && $month == '') {
609
-			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";
610
-			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";
744
+			if ($limit) {
745
+				$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";
746
+			} else {
747
+				$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";
748
+			}
611 749
 			try {
612 750
 				$sth = $this->db->prepare($query);
613 751
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -615,7 +753,9 @@  discard block
 block discarded – undo
615 753
 				echo "error : ".$e->getMessage();
616 754
 			}
617 755
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
618
-		} else $all = array();
756
+		} else {
757
+			$all = array();
758
+		}
619 759
 		if (empty($all)) {
620 760
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
621 761
 			if ($filter_name != '') {
@@ -630,7 +770,9 @@  discard block
 block discarded – undo
630 770
 
631 771
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
632 772
 		global $globalStatsFilters;
633
-		if ($filter_name == '') $filter_name = $this->filter_name;
773
+		if ($filter_name == '') {
774
+			$filter_name = $this->filter_name;
775
+		}
634 776
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
635 777
 			$Spotter = new Spotter($this->db);
636 778
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -639,8 +781,11 @@  discard block
 block discarded – undo
639 781
 				foreach ($airlines as $airline) {
640 782
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
641 783
 				}
642
-				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";
643
-				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";
784
+				if ($limit) {
785
+					$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";
786
+				} else {
787
+					$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";
788
+				}
644 789
 				try {
645 790
 					$sth = $this->db->prepare($query);
646 791
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -648,11 +793,16 @@  discard block
 block discarded – undo
648 793
 					echo "error : ".$e->getMessage();
649 794
 				}
650 795
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
651
-			} else $all = array();
796
+			} else {
797
+				$all = array();
798
+			}
652 799
 		} else {
653 800
 			if ($year == '' && $month == '') {
654
-				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";
655
-				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";
801
+				if ($limit) {
802
+					$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";
803
+				} else {
804
+					$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";
805
+				}
656 806
 				try {
657 807
 					$sth = $this->db->prepare($query);
658 808
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -660,7 +810,9 @@  discard block
 block discarded – undo
660 810
 					echo "error : ".$e->getMessage();
661 811
 				}
662 812
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
663
-			} else $all = array();
813
+			} else {
814
+				$all = array();
815
+			}
664 816
 		}
665 817
 		if (empty($all)) {
666 818
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -679,7 +831,9 @@  discard block
 block discarded – undo
679 831
 	}
680 832
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
681 833
 		global $globalStatsFilters;
682
-		if ($filter_name == '') $filter_name = $this->filter_name;
834
+		if ($filter_name == '') {
835
+			$filter_name = $this->filter_name;
836
+		}
683 837
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
684 838
 			$Spotter = new Spotter($this->db);
685 839
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -688,8 +842,11 @@  discard block
 block discarded – undo
688 842
 				foreach ($airlines as $airline) {
689 843
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
690 844
 				}
691
-				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";
692
-				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";
845
+				if ($limit) {
846
+					$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";
847
+				} else {
848
+					$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";
849
+				}
693 850
 				try {
694 851
 					$sth = $this->db->prepare($query);
695 852
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -697,11 +854,16 @@  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
 		} else {
702 861
 			if ($year == '' && $month == '') {
703
-				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";
704
-				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";
862
+				if ($limit) {
863
+					$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";
864
+				} else {
865
+					$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";
866
+				}
705 867
 				try {
706 868
 					$sth = $this->db->prepare($query);
707 869
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -709,7 +871,9 @@  discard block
 block discarded – undo
709 871
 					echo "error : ".$e->getMessage();
710 872
 				}
711 873
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
712
-			} else $all = array();
874
+			} else {
875
+				$all = array();
876
+			}
713 877
 		}
714 878
 		if (empty($all)) {
715 879
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -734,7 +898,9 @@  discard block
 block discarded – undo
734 898
 				$icao = $value['airport_departure_icao'];
735 899
 				if (isset($all[$icao])) {
736 900
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
737
-				} else $all[$icao] = $value;
901
+				} else {
902
+					$all[$icao] = $value;
903
+				}
738 904
 			}
739 905
 			$count = array();
740 906
 			foreach ($all as $key => $row) {
@@ -746,7 +912,9 @@  discard block
 block discarded – undo
746 912
 	}
747 913
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
748 914
 		global $globalStatsFilters;
749
-		if ($filter_name == '') $filter_name = $this->filter_name;
915
+		if ($filter_name == '') {
916
+			$filter_name = $this->filter_name;
917
+		}
750 918
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
751 919
 			$Spotter = new Spotter($this->db);
752 920
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -755,8 +923,11 @@  discard block
 block discarded – undo
755 923
 				foreach ($airlines as $airline) {
756 924
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
757 925
 				}
758
-				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";
759
-				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";
926
+				if ($limit) {
927
+					$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";
928
+				} else {
929
+					$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";
930
+				}
760 931
 				try {
761 932
 					$sth = $this->db->prepare($query);
762 933
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -764,11 +935,16 @@  discard block
 block discarded – undo
764 935
 					echo "error : ".$e->getMessage();
765 936
 				}
766 937
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
767
-			} else $all = array();
938
+			} else {
939
+				$all = array();
940
+			}
768 941
 		} else {
769 942
 			if ($year == '' && $month == '') {
770
-				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";
771
-				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";
943
+				if ($limit) {
944
+					$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";
945
+				} else {
946
+					$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";
947
+				}
772 948
 				try {
773 949
 					$sth = $this->db->prepare($query);
774 950
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -776,7 +952,9 @@  discard block
 block discarded – undo
776 952
 					echo "error : ".$e->getMessage();
777 953
 				}
778 954
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
779
-			} else $all = array();
955
+			} else {
956
+				$all = array();
957
+			}
780 958
 		}
781 959
 		if (empty($all)) {
782 960
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -801,7 +979,9 @@  discard block
 block discarded – undo
801 979
 				$icao = $value['airport_arrival_icao'];
802 980
 				if (isset($all[$icao])) {
803 981
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
804
-				} else $all[$icao] = $value;
982
+				} else {
983
+					$all[$icao] = $value;
984
+				}
805 985
 			}
806 986
 			$count = array();
807 987
 			foreach ($all as $key => $row) {
@@ -813,7 +993,9 @@  discard block
 block discarded – undo
813 993
 	}
814 994
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
815 995
 		global $globalDBdriver, $globalStatsFilters;
816
-		if ($filter_name == '') $filter_name = $this->filter_name;
996
+		if ($filter_name == '') {
997
+			$filter_name = $this->filter_name;
998
+		}
817 999
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
818 1000
 			$Spotter = new Spotter($this->db);
819 1001
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -822,20 +1004,32 @@  discard block
 block discarded – undo
822 1004
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
823 1005
 			}
824 1006
 			if ($globalDBdriver == 'mysql') {
825
-				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";
826
-				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";
1007
+				if ($limit) {
1008
+					$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";
1009
+				} else {
1010
+					$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";
1011
+				}
827 1012
 			} else {
828
-				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";
829
-				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";
1013
+				if ($limit) {
1014
+					$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";
1015
+				} else {
1016
+					$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";
1017
+				}
830 1018
 			}
831 1019
 			$query_data = array(':filter_name' => $filter_name);
832 1020
 		} else {
833 1021
 			if ($globalDBdriver == 'mysql') {
834
-				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";
835
-				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";
1022
+				if ($limit) {
1023
+					$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";
1024
+				} else {
1025
+					$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";
1026
+				}
836 1027
 			} else {
837
-				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";
838
-				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";
1028
+				if ($limit) {
1029
+					$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";
1030
+				} else {
1031
+					$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";
1032
+				}
839 1033
 			}
840 1034
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
841 1035
 		}
@@ -863,7 +1057,9 @@  discard block
 block discarded – undo
863 1057
 	
864 1058
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
865 1059
 		global $globalStatsFilters;
866
-		if ($filter_name == '') $filter_name = $this->filter_name;
1060
+		if ($filter_name == '') {
1061
+			$filter_name = $this->filter_name;
1062
+		}
867 1063
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
868 1064
 			$Spotter = new Spotter($this->db);
869 1065
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -900,7 +1096,9 @@  discard block
 block discarded – undo
900 1096
 	}
901 1097
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
902 1098
 		global $globalDBdriver, $globalStatsFilters;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1099
+		if ($filter_name == '') {
1100
+			$filter_name = $this->filter_name;
1101
+		}
904 1102
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
905 1103
 			$Spotter = new Spotter($this->db);
906 1104
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -945,7 +1143,9 @@  discard block
 block discarded – undo
945 1143
 	}
946 1144
 	public function countAllDates($stats_airline = '',$filter_name = '') {
947 1145
 		global $globalStatsFilters;
948
-		if ($filter_name == '') $filter_name = $this->filter_name;
1146
+		if ($filter_name == '') {
1147
+			$filter_name = $this->filter_name;
1148
+		}
949 1149
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
950 1150
 			$Spotter = new Spotter($this->db);
951 1151
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -982,7 +1182,9 @@  discard block
 block discarded – undo
982 1182
 	}
983 1183
 	public function countAllDatesMarine($filter_name = '') {
984 1184
 		global $globalStatsFilters;
985
-		if ($filter_name == '') $filter_name = $this->filter_name;
1185
+		if ($filter_name == '') {
1186
+			$filter_name = $this->filter_name;
1187
+		}
986 1188
 		$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";
987 1189
 		$query_data = array(':filter_name' => $filter_name);
988 1190
 		try {
@@ -1004,7 +1206,9 @@  discard block
 block discarded – undo
1004 1206
 	}
1005 1207
 	public function countAllDatesTracker($filter_name = '') {
1006 1208
 		global $globalStatsFilters;
1007
-		if ($filter_name == '') $filter_name = $this->filter_name;
1209
+		if ($filter_name == '') {
1210
+			$filter_name = $this->filter_name;
1211
+		}
1008 1212
 		$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";
1009 1213
 		$query_data = array(':filter_name' => $filter_name);
1010 1214
 		try {
@@ -1026,7 +1230,9 @@  discard block
 block discarded – undo
1026 1230
 	}
1027 1231
 	public function countAllDatesByAirlines($filter_name = '') {
1028 1232
 		global $globalStatsFilters;
1029
-		if ($filter_name == '') $filter_name = $this->filter_name;
1233
+		if ($filter_name == '') {
1234
+			$filter_name = $this->filter_name;
1235
+		}
1030 1236
 		$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";
1031 1237
 		$query_data = array('filter_name' => $filter_name);
1032 1238
 		try {
@@ -1048,7 +1254,9 @@  discard block
 block discarded – undo
1048 1254
 	}
1049 1255
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1050 1256
 		global $globalStatsFilters, $globalDBdriver;
1051
-		if ($filter_name == '') $filter_name = $this->filter_name;
1257
+		if ($filter_name == '') {
1258
+			$filter_name = $this->filter_name;
1259
+		}
1052 1260
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1053 1261
 			$Spotter = new Spotter($this->db);
1054 1262
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1133,7 +1341,9 @@  discard block
 block discarded – undo
1133 1341
 	}
1134 1342
 	public function countAllMilitaryMonths($filter_name = '') {
1135 1343
 		global $globalStatsFilters;
1136
-		if ($filter_name == '') $filter_name = $this->filter_name;
1344
+		if ($filter_name == '') {
1345
+			$filter_name = $this->filter_name;
1346
+		}
1137 1347
 		$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";
1138 1348
 		try {
1139 1349
 			$sth = $this->db->prepare($query);
@@ -1154,7 +1364,9 @@  discard block
 block discarded – undo
1154 1364
 	}
1155 1365
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1156 1366
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1157
-		if ($filter_name == '') $filter_name = $this->filter_name;
1367
+		if ($filter_name == '') {
1368
+			$filter_name = $this->filter_name;
1369
+		}
1158 1370
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1159 1371
 			$Spotter = new Spotter($this->db);
1160 1372
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1162,12 +1374,18 @@  discard block
 block discarded – undo
1162 1374
 			foreach ($airlines as $airline) {
1163 1375
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1164 1376
 			}
1165
-			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";
1166
-			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";
1377
+			if ($limit) {
1378
+				$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";
1379
+			} else {
1380
+				$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";
1381
+			}
1167 1382
 			$query_data = array(':filter_name' => $filter_name);
1168 1383
 		} else {
1169
-			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";
1170
-			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";
1384
+			if ($limit) {
1385
+				$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";
1386
+			} else {
1387
+				$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";
1388
+			}
1171 1389
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1172 1390
 		}
1173 1391
 		if ($orderby == 'hour') {
@@ -1177,7 +1395,9 @@  discard block
 block discarded – undo
1177 1395
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1178 1396
 			}
1179 1397
 		}
1180
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1398
+		if ($orderby == 'count') {
1399
+			$query .= " ORDER BY hour_count DESC";
1400
+		}
1181 1401
 		try {
1182 1402
 			$sth = $this->db->prepare($query);
1183 1403
 			$sth->execute($query_data);
@@ -1201,8 +1421,12 @@  discard block
 block discarded – undo
1201 1421
 	}
1202 1422
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1203 1423
 		global $globalStatsFilters;
1204
-		if ($filter_name == '') $filter_name = $this->filter_name;
1205
-		if ($year == '') $year = date('Y');
1424
+		if ($filter_name == '') {
1425
+			$filter_name = $this->filter_name;
1426
+		}
1427
+		if ($year == '') {
1428
+			$year = date('Y');
1429
+		}
1206 1430
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1207 1431
 		if (empty($all)) {
1208 1432
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1221,8 +1445,12 @@  discard block
 block discarded – undo
1221 1445
 	}
1222 1446
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1223 1447
 		global $globalStatsFilters;
1224
-		if ($filter_name == '') $filter_name = $this->filter_name;
1225
-		if ($year == '') $year = date('Y');
1448
+		if ($filter_name == '') {
1449
+			$filter_name = $this->filter_name;
1450
+		}
1451
+		if ($year == '') {
1452
+			$year = date('Y');
1453
+		}
1226 1454
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1227 1455
 		if (empty($all)) {
1228 1456
 			$filters = array('year' => $year,'month' => $month);
@@ -1237,8 +1465,12 @@  discard block
 block discarded – undo
1237 1465
 	}
1238 1466
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1239 1467
 		global $globalStatsFilters;
1240
-		if ($filter_name == '') $filter_name = $this->filter_name;
1241
-		if ($year == '') $year = date('Y');
1468
+		if ($filter_name == '') {
1469
+			$filter_name = $this->filter_name;
1470
+		}
1471
+		if ($year == '') {
1472
+			$year = date('Y');
1473
+		}
1242 1474
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1243 1475
 		if (empty($all)) {
1244 1476
 			$filters = array('year' => $year,'month' => $month);
@@ -1253,8 +1485,12 @@  discard block
 block discarded – undo
1253 1485
 	}
1254 1486
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1255 1487
 		global $globalStatsFilters;
1256
-		if ($filter_name == '') $filter_name = $this->filter_name;
1257
-		if ($year == '') $year = date('Y');
1488
+		if ($filter_name == '') {
1489
+			$filter_name = $this->filter_name;
1490
+		}
1491
+		if ($year == '') {
1492
+			$year = date('Y');
1493
+		}
1258 1494
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1259 1495
 		if (empty($all)) {
1260 1496
 			$filters = array();
@@ -1270,8 +1506,12 @@  discard block
 block discarded – undo
1270 1506
 	}
1271 1507
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1272 1508
 		global $globalStatsFilters;
1273
-		if ($filter_name == '') $filter_name = $this->filter_name;
1274
-		if ($year == '') $year = date('Y');
1509
+		if ($filter_name == '') {
1510
+			$filter_name = $this->filter_name;
1511
+		}
1512
+		if ($year == '') {
1513
+			$year = date('Y');
1514
+		}
1275 1515
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1276 1516
 		if (empty($all)) {
1277 1517
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1290,7 +1530,9 @@  discard block
 block discarded – undo
1290 1530
 	}
1291 1531
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1292 1532
 		global $globalStatsFilters;
1293
-		if ($filter_name == '') $filter_name = $this->filter_name;
1533
+		if ($filter_name == '') {
1534
+			$filter_name = $this->filter_name;
1535
+		}
1294 1536
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1295 1537
 			$Spotter = new Spotter($this->db);
1296 1538
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1308,7 +1550,9 @@  discard block
 block discarded – undo
1308 1550
 				}
1309 1551
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1310 1552
 				$all = $result[0]['nb'];
1311
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1553
+			} else {
1554
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1555
+			}
1312 1556
 		} else {
1313 1557
 			if ($year == '' && $month == '') {
1314 1558
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1320,7 +1564,9 @@  discard block
 block discarded – undo
1320 1564
 				}
1321 1565
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1322 1566
 				$all = $result[0]['nb'];
1323
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1567
+			} else {
1568
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1569
+			}
1324 1570
 		}
1325 1571
 		if (empty($all)) {
1326 1572
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1339,7 +1585,9 @@  discard block
 block discarded – undo
1339 1585
 	}
1340 1586
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1341 1587
 		global $globalStatsFilters;
1342
-		if ($filter_name == '') $filter_name = $this->filter_name;
1588
+		if ($filter_name == '') {
1589
+			$filter_name = $this->filter_name;
1590
+		}
1343 1591
 		if ($year == '' && $month == '') {
1344 1592
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1345 1593
 			try {
@@ -1350,7 +1598,9 @@  discard block
 block discarded – undo
1350 1598
 			}
1351 1599
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1352 1600
 			$all = $result[0]['nb_airline'];
1353
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1601
+		} else {
1602
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1603
+		}
1354 1604
 		if (empty($all)) {
1355 1605
 			$filters = array();
1356 1606
 			$filters = array('year' => $year,'month' => $month);
@@ -1365,7 +1615,9 @@  discard block
 block discarded – undo
1365 1615
 	}
1366 1616
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1367 1617
 		global $globalStatsFilters;
1368
-		if ($filter_name == '') $filter_name = $this->filter_name;
1618
+		if ($filter_name == '') {
1619
+			$filter_name = $this->filter_name;
1620
+		}
1369 1621
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1370 1622
 			$Spotter = new Spotter($this->db);
1371 1623
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1420,7 +1672,9 @@  discard block
 block discarded – undo
1420 1672
 	}
1421 1673
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1422 1674
 		global $globalStatsFilters;
1423
-		if ($filter_name == '') $filter_name = $this->filter_name;
1675
+		if ($filter_name == '') {
1676
+			$filter_name = $this->filter_name;
1677
+		}
1424 1678
 		//if ($year == '') $year = date('Y');
1425 1679
 		if ($year == '' && $month == '') {
1426 1680
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1449,7 +1703,9 @@  discard block
 block discarded – undo
1449 1703
 	}
1450 1704
 
1451 1705
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1452
-		if ($filter_name == '') $filter_name = $this->filter_name;
1706
+		if ($filter_name == '') {
1707
+			$filter_name = $this->filter_name;
1708
+		}
1453 1709
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1454 1710
 			$Spotter = new Spotter($this->db);
1455 1711
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1473,7 +1729,9 @@  discard block
 block discarded – undo
1473 1729
 		return $all;
1474 1730
 	}
1475 1731
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1476
-		if ($filter_name == '') $filter_name = $this->filter_name;
1732
+		if ($filter_name == '') {
1733
+			$filter_name = $this->filter_name;
1734
+		}
1477 1735
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1478 1736
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1479 1737
 		try {
@@ -1486,7 +1744,9 @@  discard block
 block discarded – undo
1486 1744
 		return $all;
1487 1745
 	}
1488 1746
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1489
-		if ($filter_name == '') $filter_name = $this->filter_name;
1747
+		if ($filter_name == '') {
1748
+			$filter_name = $this->filter_name;
1749
+		}
1490 1750
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1491 1751
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1492 1752
 		try {
@@ -1497,7 +1757,9 @@  discard block
 block discarded – undo
1497 1757
 		}
1498 1758
 	}
1499 1759
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1500
-		if ($filter_name == '') $filter_name = $this->filter_name;
1760
+		if ($filter_name == '') {
1761
+			$filter_name = $this->filter_name;
1762
+		}
1501 1763
 		global $globalArchiveMonths, $globalDBdriver;
1502 1764
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1503 1765
 			$Spotter = new Spotter($this->db);
@@ -1553,7 +1815,9 @@  discard block
 block discarded – undo
1553 1815
 	}
1554 1816
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1555 1817
 		global $globalArchiveMonths, $globalDBdriver;
1556
-		if ($filter_name == '') $filter_name = $this->filter_name;
1818
+		if ($filter_name == '') {
1819
+			$filter_name = $this->filter_name;
1820
+		}
1557 1821
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1558 1822
 			$Spotter = new Spotter($this->db);
1559 1823
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1586,7 +1850,9 @@  discard block
 block discarded – undo
1586 1850
 	}
1587 1851
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1588 1852
 		global $globalArchiveMonths, $globalDBdriver;
1589
-		if ($filter_name == '') $filter_name = $this->filter_name;
1853
+		if ($filter_name == '') {
1854
+			$filter_name = $this->filter_name;
1855
+		}
1590 1856
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1591 1857
 			$Spotter = new Spotter($this->db);
1592 1858
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1617,7 +1883,9 @@  discard block
 block discarded – undo
1617 1883
 	}
1618 1884
 	public function getStatsAirlineTotal($filter_name = '') {
1619 1885
 		global $globalArchiveMonths, $globalDBdriver;
1620
-		if ($filter_name == '') $filter_name = $this->filter_name;
1886
+		if ($filter_name == '') {
1887
+			$filter_name = $this->filter_name;
1888
+		}
1621 1889
 		if ($globalDBdriver == 'mysql') {
1622 1890
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1623 1891
 		} else {
@@ -1634,7 +1902,9 @@  discard block
 block discarded – undo
1634 1902
 	}
1635 1903
 	public function getStatsOwnerTotal($filter_name = '') {
1636 1904
 		global $globalArchiveMonths, $globalDBdriver;
1637
-		if ($filter_name == '') $filter_name = $this->filter_name;
1905
+		if ($filter_name == '') {
1906
+			$filter_name = $this->filter_name;
1907
+		}
1638 1908
 		if ($globalDBdriver == 'mysql') {
1639 1909
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1640 1910
 		} else {
@@ -1651,7 +1921,9 @@  discard block
 block discarded – undo
1651 1921
 	}
1652 1922
 	public function getStatsOwner($owner_name,$filter_name = '') {
1653 1923
 		global $globalArchiveMonths, $globalDBdriver;
1654
-		if ($filter_name == '') $filter_name = $this->filter_name;
1924
+		if ($filter_name == '') {
1925
+			$filter_name = $this->filter_name;
1926
+		}
1655 1927
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1656 1928
 		try {
1657 1929
 			$sth = $this->db->prepare($query);
@@ -1660,12 +1932,17 @@  discard block
 block discarded – undo
1660 1932
 			echo "error : ".$e->getMessage();
1661 1933
 		}
1662 1934
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1663
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1664
-		else return 0;
1935
+		if (isset($all[0]['cnt'])) {
1936
+			return $all[0]['cnt'];
1937
+		} else {
1938
+			return 0;
1939
+		}
1665 1940
 	}
1666 1941
 	public function getStatsPilotTotal($filter_name = '') {
1667 1942
 		global $globalArchiveMonths, $globalDBdriver;
1668
-		if ($filter_name == '') $filter_name = $this->filter_name;
1943
+		if ($filter_name == '') {
1944
+			$filter_name = $this->filter_name;
1945
+		}
1669 1946
 		if ($globalDBdriver == 'mysql') {
1670 1947
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1671 1948
 		} else {
@@ -1682,7 +1959,9 @@  discard block
 block discarded – undo
1682 1959
 	}
1683 1960
 	public function getStatsPilot($pilot,$filter_name = '') {
1684 1961
 		global $globalArchiveMonths, $globalDBdriver;
1685
-		if ($filter_name == '') $filter_name = $this->filter_name;
1962
+		if ($filter_name == '') {
1963
+			$filter_name = $this->filter_name;
1964
+		}
1686 1965
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1687 1966
 		try {
1688 1967
 			$sth = $this->db->prepare($query);
@@ -1691,13 +1970,18 @@  discard block
 block discarded – undo
1691 1970
 			echo "error : ".$e->getMessage();
1692 1971
 		}
1693 1972
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1694
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1695
-		else return 0;
1973
+		if (isset($all[0]['cnt'])) {
1974
+			return $all[0]['cnt'];
1975
+		} else {
1976
+			return 0;
1977
+		}
1696 1978
 	}
1697 1979
 
1698 1980
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1699 1981
 		global $globalDBdriver;
1700
-		if ($filter_name == '') $filter_name = $this->filter_name;
1982
+		if ($filter_name == '') {
1983
+			$filter_name = $this->filter_name;
1984
+		}
1701 1985
 		if ($globalDBdriver == 'mysql') {
1702 1986
 			$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";
1703 1987
 		} else {
@@ -1713,7 +1997,9 @@  discard block
 block discarded – undo
1713 1997
 	}
1714 1998
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1715 1999
 		global $globalDBdriver;
1716
-		if ($filter_name == '') $filter_name = $this->filter_name;
2000
+		if ($filter_name == '') {
2001
+			$filter_name = $this->filter_name;
2002
+		}
1717 2003
 		if ($globalDBdriver == 'mysql') {
1718 2004
 			$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";
1719 2005
 		} else {
@@ -2186,27 +2472,37 @@  discard block
 block discarded – undo
2186 2472
 		date_default_timezone_set('UTC');
2187 2473
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2188 2474
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2189
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2475
+			if ($globalDebug) {
2476
+				echo '!!! Update Marine stats !!!'."\n";
2477
+			}
2190 2478
 			if (isset($last_update[0]['value'])) {
2191 2479
 				$last_update_day = $last_update[0]['value'];
2192
-			} else $last_update_day = '2012-12-12 12:12:12';
2480
+			} else {
2481
+				$last_update_day = '2012-12-12 12:12:12';
2482
+			}
2193 2483
 			$reset = false;
2194 2484
 			$Marine = new Marine($this->db);
2195 2485
 			$filtername = 'marine';
2196 2486
 			if ($Connection->tableExists('countries')) {
2197
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2487
+				if ($globalDebug) {
2488
+					echo 'Count all vessels by countries...'."\n";
2489
+				}
2198 2490
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2199 2491
 				foreach ($alldata as $number) {
2200 2492
 					$this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2201 2493
 				}
2202 2494
 			}
2203
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2495
+			if ($globalDebug) {
2496
+				echo 'Count all vessels by months...'."\n";
2497
+			}
2204 2498
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2205 2499
 			$filter_last_month = array('since_date' => $last_month);
2206 2500
 			$alldata = $Marine->countAllMonths($filter_last_month);
2207 2501
 			$lastyear = false;
2208 2502
 			foreach ($alldata as $number) {
2209
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2503
+				if ($number['year_name'] != date('Y')) {
2504
+					$lastyear = true;
2505
+				}
2210 2506
 				$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'])));
2211 2507
 			}
2212 2508
 			echo 'Marine data...'."\n";
@@ -2242,26 +2538,36 @@  discard block
 block discarded – undo
2242 2538
 		}
2243 2539
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2244 2540
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2245
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2541
+			if ($globalDebug) {
2542
+				echo '!!! Update tracker stats !!!'."\n";
2543
+			}
2246 2544
 			if (isset($last_update[0]['value'])) {
2247 2545
 				$last_update_day = $last_update[0]['value'];
2248
-			} else $last_update_day = '2012-12-12 12:12:12';
2546
+			} else {
2547
+				$last_update_day = '2012-12-12 12:12:12';
2548
+			}
2249 2549
 			$reset = false;
2250 2550
 			$Tracker = new Tracker($this->db);
2251 2551
 			if ($Connection->tableExists('countries')) {
2252
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2552
+				if ($globalDebug) {
2553
+					echo 'Count all trackers by countries...'."\n";
2554
+				}
2253 2555
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2254 2556
 				foreach ($alldata as $number) {
2255 2557
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2256 2558
 				}
2257 2559
 			}
2258
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2560
+			if ($globalDebug) {
2561
+				echo 'Count all vessels by months...'."\n";
2562
+			}
2259 2563
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2260 2564
 			$filter_last_month = array('since_date' => $last_month);
2261 2565
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2262 2566
 			$lastyear = false;
2263 2567
 			foreach ($alldata as $number) {
2264
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2568
+				if ($number['year_name'] != date('Y')) {
2569
+					$lastyear = true;
2570
+				}
2265 2571
 				$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'])));
2266 2572
 			}
2267 2573
 			echo 'Tracker data...'."\n";
@@ -2298,10 +2604,14 @@  discard block
 block discarded – undo
2298 2604
 
2299 2605
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2300 2606
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2301
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2607
+			if ($globalDebug) {
2608
+				echo '!!! Update aicraft stats !!!'."\n";
2609
+			}
2302 2610
 			if (isset($last_update[0]['value'])) {
2303 2611
 				$last_update_day = $last_update[0]['value'];
2304
-			} else $last_update_day = '2012-12-12 12:12:12';
2612
+			} else {
2613
+				$last_update_day = '2012-12-12 12:12:12';
2614
+			}
2305 2615
 			$reset = false;
2306 2616
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2307 2617
 			if ($globalStatsResetYear) {
@@ -2310,43 +2620,63 @@  discard block
 block discarded – undo
2310 2620
 			}
2311 2621
 			$Spotter = new Spotter($this->db);
2312 2622
 
2313
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2623
+			if ($globalDebug) {
2624
+				echo 'Count all aircraft types...'."\n";
2625
+			}
2314 2626
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2315 2627
 			foreach ($alldata as $number) {
2316 2628
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2317 2629
 			}
2318
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2630
+			if ($globalDebug) {
2631
+				echo 'Count all airlines...'."\n";
2632
+			}
2319 2633
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2320 2634
 			foreach ($alldata as $number) {
2321 2635
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2322 2636
 			}
2323
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2637
+			if ($globalDebug) {
2638
+				echo 'Count all registrations...'."\n";
2639
+			}
2324 2640
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2325 2641
 			foreach ($alldata as $number) {
2326 2642
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2327 2643
 			}
2328
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2644
+			if ($globalDebug) {
2645
+				echo 'Count all callsigns...'."\n";
2646
+			}
2329 2647
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2330 2648
 			foreach ($alldata as $number) {
2331 2649
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2332 2650
 			}
2333
-			if ($globalDebug) echo 'Count all owners...'."\n";
2651
+			if ($globalDebug) {
2652
+				echo 'Count all owners...'."\n";
2653
+			}
2334 2654
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2335 2655
 			foreach ($alldata as $number) {
2336 2656
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2337 2657
 			}
2338
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2658
+			if ($globalDebug) {
2659
+				echo 'Count all pilots...'."\n";
2660
+			}
2339 2661
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2340 2662
 			foreach ($alldata as $number) {
2341
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2663
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2664
+					$number['pilot_id'] = $number['pilot_name'];
2665
+				}
2342 2666
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2343 2667
 			}
2344 2668
 			
2345
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2669
+			if ($globalDebug) {
2670
+				echo 'Count all departure airports...'."\n";
2671
+			}
2346 2672
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2347
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2673
+			if ($globalDebug) {
2674
+				echo 'Count all detected departure airports...'."\n";
2675
+			}
2348 2676
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2349
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2677
+			if ($globalDebug) {
2678
+				echo 'Order departure airports...'."\n";
2679
+			}
2350 2680
 			$alldata = array();
2351 2681
 			foreach ($pall as $value) {
2352 2682
 				$icao = $value['airport_departure_icao'];
@@ -2356,7 +2686,9 @@  discard block
 block discarded – undo
2356 2686
 				$icao = $value['airport_departure_icao'];
2357 2687
 				if (isset($alldata[$icao])) {
2358 2688
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2359
-				} else $alldata[$icao] = $value;
2689
+				} else {
2690
+					$alldata[$icao] = $value;
2691
+				}
2360 2692
 			}
2361 2693
 			$count = array();
2362 2694
 			foreach ($alldata as $key => $row) {
@@ -2366,11 +2698,17 @@  discard block
 block discarded – undo
2366 2698
 			foreach ($alldata as $number) {
2367 2699
 				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);
2368 2700
 			}
2369
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2701
+			if ($globalDebug) {
2702
+				echo 'Count all arrival airports...'."\n";
2703
+			}
2370 2704
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2371
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2705
+			if ($globalDebug) {
2706
+				echo 'Count all detected arrival airports...'."\n";
2707
+			}
2372 2708
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2373
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2709
+			if ($globalDebug) {
2710
+				echo 'Order arrival airports...'."\n";
2711
+			}
2374 2712
 			$alldata = array();
2375 2713
 			foreach ($pall as $value) {
2376 2714
 				$icao = $value['airport_arrival_icao'];
@@ -2380,7 +2718,9 @@  discard block
 block discarded – undo
2380 2718
 				$icao = $value['airport_arrival_icao'];
2381 2719
 				if (isset($alldata[$icao])) {
2382 2720
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2383
-				} else $alldata[$icao] = $value;
2721
+				} else {
2722
+					$alldata[$icao] = $value;
2723
+				}
2384 2724
 			}
2385 2725
 			$count = array();
2386 2726
 			foreach ($alldata as $key => $row) {
@@ -2391,7 +2731,9 @@  discard block
 block discarded – undo
2391 2731
 				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);
2392 2732
 			}
2393 2733
 			if ($Connection->tableExists('countries')) {
2394
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2734
+				if ($globalDebug) {
2735
+					echo 'Count all flights by countries...'."\n";
2736
+				}
2395 2737
 				//$SpotterArchive = new SpotterArchive();
2396 2738
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2397 2739
 				$Spotter = new Spotter($this->db);
@@ -2402,7 +2744,9 @@  discard block
 block discarded – undo
2402 2744
 			}
2403 2745
 			
2404 2746
 			if (isset($globalAccidents) && $globalAccidents) {
2405
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2747
+				if ($globalDebug) {
2748
+					echo 'Count fatalities stats...'."\n";
2749
+				}
2406 2750
 				$Accident = new Accident($this->db);
2407 2751
 				$this->deleteStatsByType('fatalities_byyear');
2408 2752
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2418,48 +2762,68 @@  discard block
 block discarded – undo
2418 2762
 
2419 2763
 			// Add by month using getstat if month finish...
2420 2764
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2421
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2765
+			if ($globalDebug) {
2766
+				echo 'Count all flights by months...'."\n";
2767
+			}
2422 2768
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2423 2769
 			$filter_last_month = array('since_date' => $last_month);
2424 2770
 			$Spotter = new Spotter($this->db);
2425 2771
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2426 2772
 			$lastyear = false;
2427 2773
 			foreach ($alldata as $number) {
2428
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2774
+				if ($number['year_name'] != date('Y')) {
2775
+					$lastyear = true;
2776
+				}
2429 2777
 				$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'])));
2430 2778
 			}
2431
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2779
+			if ($globalDebug) {
2780
+				echo 'Count all military flights by months...'."\n";
2781
+			}
2432 2782
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2433 2783
 			foreach ($alldata as $number) {
2434 2784
 				$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'])));
2435 2785
 			}
2436
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2786
+			if ($globalDebug) {
2787
+				echo 'Count all owners by months...'."\n";
2788
+			}
2437 2789
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2438 2790
 			foreach ($alldata as $number) {
2439 2791
 				$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'])));
2440 2792
 			}
2441
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2793
+			if ($globalDebug) {
2794
+				echo 'Count all pilots by months...'."\n";
2795
+			}
2442 2796
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2443 2797
 			foreach ($alldata as $number) {
2444 2798
 				$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'])));
2445 2799
 			}
2446
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2800
+			if ($globalDebug) {
2801
+				echo 'Count all airlines by months...'."\n";
2802
+			}
2447 2803
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2448 2804
 			foreach ($alldata as $number) {
2449 2805
 				$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'])));
2450 2806
 			}
2451
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2807
+			if ($globalDebug) {
2808
+				echo 'Count all aircrafts by months...'."\n";
2809
+			}
2452 2810
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2453 2811
 			foreach ($alldata as $number) {
2454 2812
 				$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'])));
2455 2813
 			}
2456
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2814
+			if ($globalDebug) {
2815
+				echo 'Count all real arrivals by months...'."\n";
2816
+			}
2457 2817
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2458 2818
 			foreach ($alldata as $number) {
2459 2819
 				$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'])));
2460 2820
 			}
2461
-			if ($globalDebug) echo 'Airports data...'."\n";
2462
-			if ($globalDebug) echo '...Departure'."\n";
2821
+			if ($globalDebug) {
2822
+				echo 'Airports data...'."\n";
2823
+			}
2824
+			if ($globalDebug) {
2825
+				echo '...Departure'."\n";
2826
+			}
2463 2827
 			$this->deleteStatAirport('daily');
2464 2828
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2465 2829
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2577,7 +2941,9 @@  discard block
 block discarded – undo
2577 2941
 			// Count by airlines
2578 2942
 			echo '--- Stats by airlines ---'."\n";
2579 2943
 			if ($Connection->tableExists('countries')) {
2580
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2944
+				if ($globalDebug) {
2945
+					echo 'Count all flights by countries by airlines...'."\n";
2946
+				}
2581 2947
 				$SpotterArchive = new SpotterArchive($this->db);
2582 2948
 				//$Spotter = new Spotter($this->db);
2583 2949
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2586,37 +2952,53 @@  discard block
 block discarded – undo
2586 2952
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2587 2953
 				}
2588 2954
 			}
2589
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2955
+			if ($globalDebug) {
2956
+				echo 'Count all aircraft types by airlines...'."\n";
2957
+			}
2590 2958
 			$Spotter = new Spotter($this->db);
2591 2959
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2592 2960
 			foreach ($alldata as $number) {
2593 2961
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2594 2962
 			}
2595
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2963
+			if ($globalDebug) {
2964
+				echo 'Count all aircraft registrations by airlines...'."\n";
2965
+			}
2596 2966
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2597 2967
 			foreach ($alldata as $number) {
2598 2968
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2599 2969
 			}
2600
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2970
+			if ($globalDebug) {
2971
+				echo 'Count all callsigns by airlines...'."\n";
2972
+			}
2601 2973
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2602 2974
 			foreach ($alldata as $number) {
2603 2975
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2604 2976
 			}
2605
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2977
+			if ($globalDebug) {
2978
+				echo 'Count all owners by airlines...'."\n";
2979
+			}
2606 2980
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2607 2981
 			foreach ($alldata as $number) {
2608 2982
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2609 2983
 			}
2610
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2984
+			if ($globalDebug) {
2985
+				echo 'Count all pilots by airlines...'."\n";
2986
+			}
2611 2987
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2612 2988
 			foreach ($alldata as $number) {
2613 2989
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2614 2990
 			}
2615
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2991
+			if ($globalDebug) {
2992
+				echo 'Count all departure airports by airlines...'."\n";
2993
+			}
2616 2994
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2617
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2995
+			if ($globalDebug) {
2996
+				echo 'Count all detected departure airports by airlines...'."\n";
2997
+			}
2618 2998
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2619
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2999
+			if ($globalDebug) {
3000
+				echo 'Order detected departure airports by airlines...'."\n";
3001
+			}
2620 3002
 			//$alldata = array();
2621 3003
 			foreach ($dall as $value) {
2622 3004
 				$icao = $value['airport_departure_icao'];
@@ -2637,11 +3019,17 @@  discard block
 block discarded – undo
2637 3019
 			foreach ($alldata as $number) {
2638 3020
 				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);
2639 3021
 			}
2640
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3022
+			if ($globalDebug) {
3023
+				echo 'Count all arrival airports by airlines...'."\n";
3024
+			}
2641 3025
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2642
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3026
+			if ($globalDebug) {
3027
+				echo 'Count all detected arrival airports by airlines...'."\n";
3028
+			}
2643 3029
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2644
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3030
+			if ($globalDebug) {
3031
+				echo 'Order arrival airports by airlines...'."\n";
3032
+			}
2645 3033
 			//$alldata = array();
2646 3034
 			foreach ($dall as $value) {
2647 3035
 				$icao = $value['airport_arrival_icao'];
@@ -2660,37 +3048,53 @@  discard block
 block discarded – undo
2660 3048
 			}
2661 3049
 			$alldata = $pall;
2662 3050
 			foreach ($alldata as $number) {
2663
-				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);
3051
+				if ($number['airline_icao'] != '') {
3052
+					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);
3053
+				}
3054
+			}
3055
+			if ($globalDebug) {
3056
+				echo 'Count all flights by months by airlines...'."\n";
2664 3057
 			}
2665
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2666 3058
 			$Spotter = new Spotter($this->db);
2667 3059
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2668 3060
 			$lastyear = false;
2669 3061
 			foreach ($alldata as $number) {
2670
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3062
+				if ($number['year_name'] != date('Y')) {
3063
+					$lastyear = true;
3064
+				}
2671 3065
 				$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']);
2672 3066
 			}
2673
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3067
+			if ($globalDebug) {
3068
+				echo 'Count all owners by months by airlines...'."\n";
3069
+			}
2674 3070
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2675 3071
 			foreach ($alldata as $number) {
2676 3072
 				$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']);
2677 3073
 			}
2678
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3074
+			if ($globalDebug) {
3075
+				echo 'Count all pilots by months by airlines...'."\n";
3076
+			}
2679 3077
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2680 3078
 			foreach ($alldata as $number) {
2681 3079
 				$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']);
2682 3080
 			}
2683
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3081
+			if ($globalDebug) {
3082
+				echo 'Count all aircrafts by months by airlines...'."\n";
3083
+			}
2684 3084
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2685 3085
 			foreach ($alldata as $number) {
2686 3086
 				$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']);
2687 3087
 			}
2688
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3088
+			if ($globalDebug) {
3089
+				echo 'Count all real arrivals by months by airlines...'."\n";
3090
+			}
2689 3091
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2690 3092
 			foreach ($alldata as $number) {
2691 3093
 				$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']);
2692 3094
 			}
2693
-			if ($globalDebug) echo '...Departure'."\n";
3095
+			if ($globalDebug) {
3096
+				echo '...Departure'."\n";
3097
+			}
2694 3098
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2695 3099
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2696 3100
 			foreach ($dall as $value) {
@@ -2713,7 +3117,9 @@  discard block
 block discarded – undo
2713 3117
 			foreach ($alldata as $number) {
2714 3118
 				$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']);
2715 3119
 			}
2716
-			if ($globalDebug) echo '...Arrival'."\n";
3120
+			if ($globalDebug) {
3121
+				echo '...Arrival'."\n";
3122
+			}
2717 3123
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2718 3124
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2719 3125
 			foreach ($dall as $value) {
@@ -2737,13 +3143,19 @@  discard block
 block discarded – undo
2737 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'],$number['airline_icao']);
2738 3144
 			}
2739 3145
 
2740
-			if ($globalDebug) echo 'Flights data...'."\n";
2741
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3146
+			if ($globalDebug) {
3147
+				echo 'Flights data...'."\n";
3148
+			}
3149
+			if ($globalDebug) {
3150
+				echo '-> countAllDatesLastMonth...'."\n";
3151
+			}
2742 3152
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2743 3153
 			foreach ($alldata as $number) {
2744 3154
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2745 3155
 			}
2746
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3156
+			if ($globalDebug) {
3157
+				echo '-> countAllDates...'."\n";
3158
+			}
2747 3159
 			//$previousdata = $this->countAllDatesByAirlines();
2748 3160
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2749 3161
 			$values = array();
@@ -2756,14 +3168,18 @@  discard block
 block discarded – undo
2756 3168
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2757 3169
 			}
2758 3170
 			
2759
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3171
+			if ($globalDebug) {
3172
+				echo '-> countAllHours...'."\n";
3173
+			}
2760 3174
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2761 3175
 			foreach ($alldata as $number) {
2762 3176
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2763 3177
 			}
2764 3178
 
2765 3179
 			// Stats by filters
2766
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3180
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3181
+				$globalStatsFilters = array();
3182
+			}
2767 3183
 			foreach ($globalStatsFilters as $name => $filter) {
2768 3184
 				if (!empty($filter)) {
2769 3185
 					//$filter_name = $filter['name'];
@@ -2771,7 +3187,9 @@  discard block
 block discarded – undo
2771 3187
 					$reset = false;
2772 3188
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2773 3189
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2774
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3190
+						if ($globalDebug) {
3191
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3192
+						}
2775 3193
 						$this->deleteOldStats($filter_name);
2776 3194
 						unset($last_update);
2777 3195
 					}
@@ -2788,39 +3206,55 @@  discard block
 block discarded – undo
2788 3206
 						$reset = true;
2789 3207
 					}
2790 3208
 					// Count by filter
2791
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3209
+					if ($globalDebug) {
3210
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3211
+					}
2792 3212
 					$Spotter = new Spotter($this->db);
2793
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3213
+					if ($globalDebug) {
3214
+						echo 'Count all aircraft types...'."\n";
3215
+					}
2794 3216
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2795 3217
 					foreach ($alldata as $number) {
2796 3218
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2797 3219
 					}
2798
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3220
+					if ($globalDebug) {
3221
+						echo 'Count all airlines...'."\n";
3222
+					}
2799 3223
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2800 3224
 					foreach ($alldata as $number) {
2801 3225
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2802 3226
 					}
2803
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3227
+					if ($globalDebug) {
3228
+						echo 'Count all aircraft registrations...'."\n";
3229
+					}
2804 3230
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2805 3231
 					foreach ($alldata as $number) {
2806 3232
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2807 3233
 					}
2808
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3234
+					if ($globalDebug) {
3235
+						echo 'Count all callsigns...'."\n";
3236
+					}
2809 3237
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2810 3238
 					foreach ($alldata as $number) {
2811 3239
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2812 3240
 					}
2813
-					if ($globalDebug) echo 'Count all owners...'."\n";
3241
+					if ($globalDebug) {
3242
+						echo 'Count all owners...'."\n";
3243
+					}
2814 3244
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2815 3245
 					foreach ($alldata as $number) {
2816 3246
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2817 3247
 					}
2818
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3248
+					if ($globalDebug) {
3249
+						echo 'Count all pilots...'."\n";
3250
+					}
2819 3251
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2820 3252
 					foreach ($alldata as $number) {
2821 3253
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2822 3254
 					}
2823
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3255
+					if ($globalDebug) {
3256
+						echo 'Count departure airports...'."\n";
3257
+					}
2824 3258
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2825 3259
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2826 3260
 					$alldata = array();
@@ -2832,7 +3266,9 @@  discard block
 block discarded – undo
2832 3266
 						$icao = $value['airport_departure_icao'];
2833 3267
 						if (isset($alldata[$icao])) {
2834 3268
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2835
-						} else $alldata[$icao] = $value;
3269
+						} else {
3270
+							$alldata[$icao] = $value;
3271
+						}
2836 3272
 					}
2837 3273
 					$count = array();
2838 3274
 					foreach ($alldata as $key => $row) {
@@ -2842,7 +3278,9 @@  discard block
 block discarded – undo
2842 3278
 					foreach ($alldata as $number) {
2843 3279
 						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);
2844 3280
 					}
2845
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3281
+					if ($globalDebug) {
3282
+						echo 'Count all arrival airports...'."\n";
3283
+					}
2846 3284
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2847 3285
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2848 3286
 					$alldata = array();
@@ -2854,7 +3292,9 @@  discard block
 block discarded – undo
2854 3292
 						$icao = $value['airport_arrival_icao'];
2855 3293
 						if (isset($alldata[$icao])) {
2856 3294
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2857
-						} else $alldata[$icao] = $value;
3295
+						} else {
3296
+							$alldata[$icao] = $value;
3297
+						}
2858 3298
 					}
2859 3299
 					$count = array();
2860 3300
 					foreach ($alldata as $key => $row) {
@@ -2864,35 +3304,49 @@  discard block
 block discarded – undo
2864 3304
 					foreach ($alldata as $number) {
2865 3305
 						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);
2866 3306
 					}
2867
-					if ($globalDebug) echo 'Count all months...'."\n";
3307
+					if ($globalDebug) {
3308
+						echo 'Count all months...'."\n";
3309
+					}
2868 3310
 					$Spotter = new Spotter($this->db);
2869 3311
 					$alldata = $Spotter->countAllMonths($filter);
2870 3312
 					$lastyear = false;
2871 3313
 					foreach ($alldata as $number) {
2872
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3314
+						if ($number['year_name'] != date('Y')) {
3315
+							$lastyear = true;
3316
+						}
2873 3317
 						$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);
2874 3318
 					}
2875
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3319
+					if ($globalDebug) {
3320
+						echo 'Count all owners by months...'."\n";
3321
+					}
2876 3322
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2877 3323
 					foreach ($alldata as $number) {
2878 3324
 						$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);
2879 3325
 					}
2880
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3326
+					if ($globalDebug) {
3327
+						echo 'Count all pilots by months...'."\n";
3328
+					}
2881 3329
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2882 3330
 					foreach ($alldata as $number) {
2883 3331
 						$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);
2884 3332
 					}
2885
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3333
+					if ($globalDebug) {
3334
+						echo 'Count all military by months...'."\n";
3335
+					}
2886 3336
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2887 3337
 					foreach ($alldata as $number) {
2888 3338
 						$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);
2889 3339
 					}
2890
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3340
+					if ($globalDebug) {
3341
+						echo 'Count all aircrafts by months...'."\n";
3342
+					}
2891 3343
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2892 3344
 				    	foreach ($alldata as $number) {
2893 3345
 			    			$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);
2894 3346
 					}
2895
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3347
+					if ($globalDebug) {
3348
+						echo 'Count all real arrivals by months...'."\n";
3349
+					}
2896 3350
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2897 3351
 					foreach ($alldata as $number) {
2898 3352
 						$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 1 patch
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($Marine->countOverallMarineTypes(array(),$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($Marine->countOverallMarineTypes(array(), $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 = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
235
+	$marine_array = $Marine->countAllMarineTypes(true, 0, '', array(), $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,7 +543,7 @@  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
 }
@@ -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);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 617
 		print 'var series = [';
618 618
 		$flightover_data = '';
619
-		foreach($flightover_array as $flightover_item) {
619
+		foreach ($flightover_array as $flightover_item) {
620 620
 			$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
621 621
 		}
622 622
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
         <div class="row column">
667 667
             <div class="col-md-6">
668 668
 <?php
669
-	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
669
+	$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
670 670
 	if (count($airport_airport_array) > 0) {
671 671
 		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
672 672
 		print '<div id="chart3" class="chart" width="100%"></div><script>';
673 673
 		print "\n";
674 674
 		print 'var series = [';
675 675
 		$airport_data = '';
676
-		foreach($airport_airport_array as $airport_item) {
676
+		foreach ($airport_airport_array as $airport_item) {
677 677
 			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
678 678
 		}
679 679
 		$airport_data = substr($airport_data, 0, -1);
@@ -723,18 +723,18 @@  discard block
 block discarded – undo
723 723
 	}
724 724
 ?>
725 725
             </div>
726
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
726
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
727 727
 
728 728
             <div class="col-md-6">
729 729
 <?php
730
-	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
730
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
731 731
 	if (count($airport_airport_array2) > 0) {
732 732
 		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
733 733
 		print '<div id="chart4" class="chart" width="100%"></div><script>';
734 734
 		print "\n";
735 735
 		print 'var series = [';
736 736
 		$airport_data = '';
737
-		foreach($airport_airport_array2 as $airport_item)
737
+		foreach ($airport_airport_array2 as $airport_item)
738 738
 		{
739 739
 			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
740 740
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 ?>
789 789
             </div>
790 790
         </div>
791
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
791
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
792 792
 <?php 
793 793
 }
794 794
 if ($type == 'aircraft') {
@@ -800,18 +800,18 @@  discard block
 block discarded – undo
800 800
             <div class="col-md-6">
801 801
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 802
 <?php
803
-		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
+		$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
804 804
 		if (count($year_array) == 0) print _("No data available");
805 805
 		else {
806 806
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 807
 			$year_data = '';
808 808
 			$year_cnt = '';
809
-			foreach($year_array as $year_item) {
809
+			foreach ($year_array as $year_item) {
810 810
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
811 811
 				$year_cnt .= $year_item['date_count'].',';
812 812
 			}
813 813
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
814
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
814
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
815 815
 			print 'c3.generate({
816 816
 			    bindto: "#chart8",
817 817
 			    data: { x: "x",
@@ -824,22 +824,22 @@  discard block
 block discarded – undo
824 824
                     <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>
825 825
                 </div>
826 826
             </div>
827
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
827
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
828 828
             <div class="col-md-6">
829 829
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 830
 <?php
831
-		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
+		$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
832 832
 		if (count($month_array) == 0) print _("No data available");
833 833
 		else {
834 834
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 835
 			$month_data = '';
836 836
 			$month_cnt = '';
837
-			foreach($month_array as $month_item) {
837
+			foreach ($month_array as $month_item) {
838 838
 				$month_data .= '"'.$month_item['date_name'].'",';
839 839
 				$month_cnt .= $month_item['date_count'].',';
840 840
 			}
841 841
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
842
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
842
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
843 843
 			print 'c3.generate({
844 844
 			    bindto: "#chart9",
845 845
 			    data: { x: "x",
@@ -852,23 +852,23 @@  discard block
 block discarded – undo
852 852
                     <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>
853 853
                 </div>
854 854
             </div>
855
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
855
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
856 856
 
857 857
             <div class="col-md-6">
858 858
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 859
 <?php
860
-		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
+		$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
861 861
 		if (empty($date_array)) print _("No data available");
862 862
 		else {
863 863
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 864
 			$date_data = '';
865 865
 			$date_cnt = '';
866
-			foreach($date_array as $date_item) {
866
+			foreach ($date_array as $date_item) {
867 867
 				$date_data .= '"'.$date_item['date_name'].'",';
868 868
 				$date_cnt .= $date_item['date_count'].',';
869 869
 			}
870 870
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
871
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
871
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
872 872
 			print 'c3.generate({
873 873
 			    bindto: "#chart5",
874 874
 			    data: { x: "x",
@@ -881,22 +881,22 @@  discard block
 block discarded – undo
881 881
                     <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>
882 882
                 </div>
883 883
             </div>
884
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
884
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 887
 <?php
888
-		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
+		$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
889 889
 		if (empty($hour_array)) print _("No data available");
890 890
 		else {
891 891
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 892
 			$hour_data = '';
893 893
 			$hour_cnt = '';
894
-			foreach($hour_array as $hour_item) {
894
+			foreach ($hour_array as $hour_item) {
895 895
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
896 896
 				$hour_cnt .= $hour_item['hour_count'].',';
897 897
 			}
898 898
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
899
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
899
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
900 900
 			print 'c3.generate({
901 901
 			    bindto: "#chart6",
902 902
 			    data: {
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
                     <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>
910 910
                 </div>
911 911
             </div>
912
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
912
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
913 913
         </div>
914 914
 <?php
915 915
 	}
@@ -925,18 +925,18 @@  discard block
 block discarded – undo
925 925
             <div class="col-md-6">
926 926
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 927
 <?php
928
-		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
+		$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
929 929
 		if (count($year_array) == 0) print _("No data available");
930 930
 		else {
931 931
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 932
 			$year_data = '';
933 933
 			$year_cnt = '';
934
-			foreach($year_array as $year_item) {
934
+			foreach ($year_array as $year_item) {
935 935
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
936 936
 				$year_cnt .= $year_item['date_count'].',';
937 937
 			}
938 938
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
939
-			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
939
+			$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
940 940
 			print 'c3.generate({
941 941
 			    bindto: "#chart8",
942 942
 			    data: { x: "x",
@@ -950,22 +950,22 @@  discard block
 block discarded – undo
950 950
                 </div>
951 951
             </div>
952 952
             
953
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
953
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
954 954
             <div class="col-md-6">
955 955
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 956
 <?php
957
-		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
+		$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
958 958
 		if (count($month_array) == 0) print _("No data available");
959 959
 		else {
960 960
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 961
 			$month_data = '';
962 962
 			$month_cnt = '';
963
-			foreach($month_array as $month_item) {
963
+			foreach ($month_array as $month_item) {
964 964
 				$month_data .= '"'.$month_item['date_name'].'",';
965 965
 				$month_cnt .= $month_item['date_count'].',';
966 966
 			}
967 967
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
968
-			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
968
+			$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
969 969
 			print 'c3.generate({
970 970
 			    bindto: "#chart9",
971 971
 			    data: { x: "x",
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
979 979
                 </div>
980 980
             </div>
981
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
981
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
982 982
 
983 983
             <div class="col-md-6">
984 984
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 985
 <?php
986
-		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
+		$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
987 987
 		if (empty($date_array)) print _("No data available");
988 988
 		else {
989 989
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 990
 			$date_data = '';
991 991
 			$date_cnt = '';
992
-			foreach($date_array as $date_item) {
992
+			foreach ($date_array as $date_item) {
993 993
 				$date_data .= '"'.$date_item['date_name'].'",';
994 994
 				$date_cnt .= $date_item['date_count'].',';
995 995
 			}
996 996
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
997
-			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
997
+			$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
998 998
 			print 'c3.generate({
999 999
 			    bindto: "#chart5",
1000 1000
 			    data: { x: "x",
@@ -1007,22 +1007,22 @@  discard block
 block discarded – undo
1007 1007
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1008 1008
                 </div>
1009 1009
             </div>
1010
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1010
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1011 1011
             <div class="col-md-6">
1012 1012
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1013
 <?php
1014
-		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
+		$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
1015 1015
 		if (empty($hour_array)) print _("No data available");
1016 1016
 		else {
1017 1017
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1018
 			$hour_data = '';
1019 1019
 			$hour_cnt = '';
1020
-			foreach($hour_array as $hour_item) {
1020
+			foreach ($hour_array as $hour_item) {
1021 1021
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1022 1022
 				$hour_cnt .= $hour_item['hour_count'].',';
1023 1023
 			}
1024 1024
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1025
-			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1025
+			$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
1026 1026
 			print 'c3.generate({
1027 1027
 			    bindto: "#chart6",
1028 1028
 			    data: {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1036 1036
                 </div>
1037 1037
             </div>
1038
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1038
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1039 1039
         </div>
1040 1040
 <?php
1041 1041
 	}
@@ -1057,12 +1057,12 @@  discard block
 block discarded – undo
1057 1057
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1058
 			$year_data = '';
1059 1059
 			$year_cnt = '';
1060
-			foreach($year_array as $year_item) {
1060
+			foreach ($year_array as $year_item) {
1061 1061
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1062 1062
 				$year_cnt .= $year_item['date_count'].',';
1063 1063
 			}
1064 1064
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1065
-			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1065
+			$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
1066 1066
 			print 'c3.generate({
1067 1067
 			    bindto: "#chart8",
1068 1068
 			    data: { x: "x",
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                 </div>
1077 1077
             </div>
1078 1078
             
1079
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1079
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1080 1080
             <div class="col-md-6">
1081 1081
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1082
 <?php
@@ -1086,12 +1086,12 @@  discard block
 block discarded – undo
1086 1086
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1087
 			$month_data = '';
1088 1088
 			$month_cnt = '';
1089
-			foreach($month_array as $month_item) {
1089
+			foreach ($month_array as $month_item) {
1090 1090
 				$month_data .= '"'.$month_item['date_name'].'",';
1091 1091
 				$month_cnt .= $month_item['date_count'].',';
1092 1092
 			}
1093 1093
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
1094
-			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1094
+			$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1095 1095
 			print 'c3.generate({
1096 1096
 			    bindto: "#chart9",
1097 1097
 			    data: { x: "x",
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1105 1105
                 </div>
1106 1106
             </div>
1107
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1107
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1108 1108
 
1109 1109
             <div class="col-md-6">
1110 1110
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1115,12 +1115,12 @@  discard block
 block discarded – undo
1115 1115
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1116
 			$date_data = '';
1117 1117
 			$date_cnt = '';
1118
-			foreach($date_array as $date_item) {
1118
+			foreach ($date_array as $date_item) {
1119 1119
 				$date_data .= '"'.$date_item['date_name'].'",';
1120 1120
 				$date_cnt .= $date_item['date_count'].',';
1121 1121
 			}
1122 1122
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
1123
-			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1123
+			$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1124 1124
 			print 'c3.generate({
1125 1125
 			    bindto: "#chart5",
1126 1126
 			    data: { x: "x",
@@ -1133,22 +1133,22 @@  discard block
 block discarded – undo
1133 1133
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1134 1134
                 </div>
1135 1135
             </div>
1136
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1136
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1137 1137
             <div class="col-md-6">
1138 1138
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1139
 <?php
1140
-		$hour_array = $Tracker->countAllHours('hour',true);
1140
+		$hour_array = $Tracker->countAllHours('hour', true);
1141 1141
 		if (empty($hour_array)) print _("No data available");
1142 1142
 		else {
1143 1143
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1144
 			$hour_data = '';
1145 1145
 			$hour_cnt = '';
1146
-			foreach($hour_array as $hour_item) {
1146
+			foreach ($hour_array as $hour_item) {
1147 1147
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1148 1148
 				$hour_cnt .= $hour_item['hour_count'].',';
1149 1149
 			}
1150 1150
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1151
-			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1151
+			$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1152 1152
 			print 'c3.generate({
1153 1153
 			    bindto: "#chart6",
1154 1154
 			    data: {
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1162 1162
                 </div>
1163 1163
             </div>
1164
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1164
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1165 1165
         </div>
1166 1166
 <?php
1167 1167
 	}
@@ -1183,12 +1183,12 @@  discard block
 block discarded – undo
1183 1183
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1184
 			$year_data = '';
1185 1185
 			$year_cnt = '';
1186
-			foreach($year_array as $year_item) {
1186
+			foreach ($year_array as $year_item) {
1187 1187
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1188 1188
 				$year_cnt .= $year_item['date_count'].',';
1189 1189
 			}
1190 1190
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1191
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1191
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1192 1192
 			print 'c3.generate({
1193 1193
 			    bindto: "#chart21",
1194 1194
 			    data: { x: "x",
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
             -->
1205 1205
             </div>
1206 1206
             
1207
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1207
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1208 1208
             <div class="col-md-6">
1209 1209
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1210
 <?php
@@ -1214,12 +1214,12 @@  discard block
 block discarded – undo
1214 1214
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1215
 			$year_data = '';
1216 1216
 			$year_cnt = '';
1217
-			foreach($year_array as $year_item) {
1217
+			foreach ($year_array as $year_item) {
1218 1218
 				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1219 1219
 				$year_cnt .= $year_item['date_count'].',';
1220 1220
 			}
1221 1221
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1222
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1222
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1223 1223
 			print 'c3.generate({
1224 1224
 			    bindto: "#chart22",
1225 1225
 			    data: { x: "x",
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
             -->
1236 1236
             </div>
1237 1237
             
1238
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1238
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1239 1239
         </div>
1240 1240
 <?php
1241 1241
 	}
@@ -1257,12 +1257,12 @@  discard block
 block discarded – undo
1257 1257
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1258
 			$year_data = '';
1259 1259
 			$year_cnt = '';
1260
-			foreach($year_array as $year_item) {
1260
+			foreach ($year_array as $year_item) {
1261 1261
 				$year_data .= '"'.$year_item['year'].'-01-01",';
1262 1262
 				$year_cnt .= $year_item['count'].',';
1263 1263
 			}
1264 1264
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1265
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1265
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1266 1266
 			print 'c3.generate({
1267 1267
 			    bindto: "#chart32",
1268 1268
 			    data: { x: "x",
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1276 1276
                 </div>
1277 1277
             </div>
1278
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1278
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1279 1279
 
1280 1280
         <div class="row column">
1281 1281
             <div class="col-md-6">
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1288
 			$year_data = '';
1289 1289
 			$year_cnt = '';
1290
-			foreach($year_array as $year_item) {
1290
+			foreach ($year_array as $year_item) {
1291 1291
 				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1292 1292
 				$year_cnt .= $year_item['count'].',';
1293 1293
 			}
1294 1294
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1295
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1295
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1296 1296
 			print 'c3.generate({
1297 1297
 			    bindto: "#chart33",
1298 1298
 			    data: { x: "x",
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1306 1306
                 </div>
1307 1307
             </div>
1308
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1308
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1309 1309
 <br/>
1310 1310
 <?php
1311 1311
 	}
@@ -1319,19 +1319,19 @@  discard block
 block discarded – undo
1319 1319
 	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1320 1320
 	if ($year == '' && $month == '') {
1321 1321
 		if ($type == 'aircraft') {
1322
-			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1322
+			$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1323 1323
 		} elseif ($type == 'marine') {
1324
-			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1324
+			$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1325 1325
 		} elseif ($type == 'tracker') {
1326
-			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1326
+			$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1327 1327
 		}
1328 1328
 	} else {
1329 1329
 		if ($type == 'aircraft') {
1330
-			$polar = $Stats->getStatsSource('polar',$year,$month);
1330
+			$polar = $Stats->getStatsSource('polar', $year, $month);
1331 1331
 		} elseif ($type == 'marine') {
1332
-			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1332
+			$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1333 1333
 		} elseif ($type == 'tracker') {
1334
-			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1334
+			$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1335 1335
 		}
1336 1336
 	}
1337 1337
 	if (!empty($polar)) {
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			unset($polar_data);
1341 1341
 			$Spotter = new Spotter();
1342 1342
 			$data = json_decode($eachpolar['source_data']);
1343
-			foreach($data as $value => $key) {
1343
+			foreach ($data as $value => $key) {
1344 1344
 				$direction = $Spotter->parseDirection(($value*22.5));
1345 1345
 				$distance = $key;
1346 1346
 				$unit = 'km';
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 ?>
1361 1361
             <div class="col-md-6">
1362 1362
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1363
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1363
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1364 1364
         	<script>
1365 1365
         	    (function() {
1366 1366
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 		      color: color,
1385 1385
 		      unit: '<?php echo $unit; ?>'
1386 1386
 		    };
1387
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1387
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1388 1388
 		    })();
1389 1389
 		</script>
1390 1390
             </div>
@@ -1399,19 +1399,19 @@  discard block
 block discarded – undo
1399 1399
 	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1400 1400
 	if ($year == '' && $month == '') {
1401 1401
 		if ($type == 'aircraft') {
1402
-			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1402
+			$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1403 1403
 		} elseif ($type == 'marine') {
1404
-			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1404
+			$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1405 1405
 		} elseif ($type == 'tracker') {
1406
-			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1406
+			$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1407 1407
 		}
1408 1408
 	} else {
1409 1409
 		if ($type == 'aircraft') {
1410
-			$msg = $Stats->getStatsSource('msg',$year,$month);
1410
+			$msg = $Stats->getStatsSource('msg', $year, $month);
1411 1411
 		} elseif ($type == 'marine') {
1412
-			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1412
+			$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1413 1413
 		} elseif ($type == 'tracker') {
1414
-			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1414
+			$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1415 1415
 		}
1416 1416
 	}
1417 1417
 	if (!empty($msg)) {
@@ -1419,13 +1419,13 @@  discard block
 block discarded – undo
1419 1419
 		foreach ($msg as $eachmsg) {
1420 1420
 			//$eachmsg = $msg[0];
1421 1421
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
+			if ($data > 500) $max = (round(($data + 100)/100))*100;
1423 1423
 			else $max = 500;
1424 1424
 ?>
1425
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1426
         	<script>
1427 1427
 		      var g = new JustGage({
1428
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1428
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1429 1429
 			    value: <?php echo $data; ?>,
1430 1430
 			    min: 0,
1431 1431
 			    max: <?php print $max; ?>,
@@ -1447,19 +1447,19 @@  discard block
 block discarded – undo
1447 1447
 	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1448 1448
 	if ($year == '' && $month == '') {
1449 1449
 		if ($type == 'aircraft') {
1450
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1450
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1451 1451
 		} elseif ($type == 'marine') {
1452
-			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1452
+			$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1453 1453
 		} elseif ($type == 'tracker') {
1454
-			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1454
+			$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1455 1455
 		}
1456 1456
 	} else {
1457 1457
 		if ($type == 'aircraft') {
1458
-			$hist = $Stats->getStatsSource('hist',$year,$month);
1458
+			$hist = $Stats->getStatsSource('hist', $year, $month);
1459 1459
 		} elseif ($type == 'marine') {
1460
-			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1460
+			$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1461 1461
 		} elseif ($type == 'tracker') {
1462
-			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1462
+			$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1463 1463
 		}
1464 1464
 	}
1465 1465
 	foreach ($hist as $hists) {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 		$source = $hists['source_name'];
1470 1470
 		$hist_array = json_decode($hists['source_data']);
1471 1471
 		$unit = 'km';
1472
-		foreach($hist_array as $distance => $nb) {
1472
+		foreach ($hist_array as $distance => $nb) {
1473 1473
 			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1474 1474
 				$distance = round($distance*0.539957);
1475 1475
 				$unit = 'nm';
@@ -1489,18 +1489,18 @@  discard block
 block discarded – undo
1489 1489
 		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1490 1490
 ?>
1491 1491
             <div class="col-md-6">
1492
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1492
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1493 1493
 <?php
1494
-		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1494
+		print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1495 1495
 		print 'c3.generate({
1496
-		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1496
+		    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1497 1497
 		    data: { x: "x",
1498 1498
 		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1499 1499
 		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1500 1500
 		print '</script>';
1501 1501
 ?>
1502 1502
     	    </div>
1503
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1503
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1504 1504
 <?php
1505 1505
 	}
1506 1506
 ?>
Please login to merge, or discard this patch.