Completed
Push — master ( d882c6...514564 )
by Yannick
47:57 queued 18:52
created
require/class.Stats.php 1 patch
Braces   +778 added lines, -273 removed lines patch added patch discarded remove patch
@@ -22,10 +22,14 @@  discard block
 block discarded – undo
22 22
 	*/
23 23
 	public function __construct($dbc = null) {
24 24
 		global $globalFilterName;
25
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
25
+		if (isset($globalFilterName)) {
26
+			$this->filter_name = $globalFilterName;
27
+		}
26 28
 		$Connection = new Connection($dbc);
27 29
 		$this->db = $Connection->db();
28
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
30
+		if ($this->db === null) {
31
+			die('Error: No DB connection. (Stats)');
32
+		}
29 33
 	}
30 34
 
31 35
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -93,7 +97,9 @@  discard block
 block discarded – undo
93 97
 
94 98
 	public function getAllAirlineNames($filter_name = '') {
95 99
 		global $globalStatsFilters;
96
-		if ($filter_name == '') $filter_name = $this->filter_name;
100
+		if ($filter_name == '') {
101
+			$filter_name = $this->filter_name;
102
+		}
97 103
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
98 104
 		 try {
99 105
 			$sth = $this->db->prepare($query);
@@ -113,7 +119,9 @@  discard block
 block discarded – undo
113 119
 		return $all;
114 120
 	}
115 121
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
122
+		if ($filter_name == '') {
123
+			$filter_name = $this->filter_name;
124
+		}
117 125
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 126
 		try {
119 127
 			$sth = $this->db->prepare($query);
@@ -125,7 +133,9 @@  discard block
 block discarded – undo
125 133
 		return $all;
126 134
 	}
127 135
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
128
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
+		if ($filter_name == '') {
137
+			$filter_name = $this->filter_name;
138
+		}
129 139
 		$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";
130 140
 		try {
131 141
 			$sth = $this->db->prepare($query);
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
 		return $all;
138 148
 	}
139 149
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
140
-		if ($filter_name == '') $filter_name = $this->filter_name;
150
+		if ($filter_name == '') {
151
+			$filter_name = $this->filter_name;
152
+		}
141 153
 		$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";
142 154
 		try {
143 155
 			$sth = $this->db->prepare($query);
@@ -150,7 +162,9 @@  discard block
 block discarded – undo
150 162
 	}
151 163
 
152 164
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
165
+		if ($filter_name == '') {
166
+			$filter_name = $this->filter_name;
167
+		}
154 168
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 169
 		try {
156 170
 			$sth = $this->db->prepare($query);
@@ -163,7 +177,9 @@  discard block
 block discarded – undo
163 177
 	}
164 178
 
165 179
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
166
-		if ($filter_name == '') $filter_name = $this->filter_name;
180
+		if ($filter_name == '') {
181
+			$filter_name = $this->filter_name;
182
+		}
167 183
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 184
 		try {
169 185
 			$sth = $this->db->prepare($query);
@@ -178,7 +194,9 @@  discard block
 block discarded – undo
178 194
 
179 195
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
180 196
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
197
+		if ($filter_name == '') {
198
+			$filter_name = $this->filter_name;
199
+		}
182 200
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
183 201
 			$Spotter = new Spotter($this->db);
184 202
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -187,8 +205,11 @@  discard block
 block discarded – undo
187 205
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
188 206
 			}
189 207
 			if ($year == '' && $month == '') {
190
-				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";
191
-				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";
208
+				if ($limit) {
209
+					$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";
210
+				} else {
211
+					$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";
212
+				}
192 213
 				try {
193 214
 					$sth = $this->db->prepare($query);
194 215
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -196,11 +217,16 @@  discard block
 block discarded – undo
196 217
 					echo "error : ".$e->getMessage();
197 218
 				}
198 219
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-			} else $all = array();
220
+			} else {
221
+				$all = array();
222
+			}
200 223
 		} else {
201 224
 			if ($year == '' && $month == '') {
202
-				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";
203
-				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";
225
+				if ($limit) {
226
+					$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";
227
+				} else {
228
+					$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";
229
+				}
204 230
 				try {
205 231
 					$sth = $this->db->prepare($query);
206 232
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -208,7 +234,9 @@  discard block
 block discarded – undo
208 234
 					echo "error : ".$e->getMessage();
209 235
 				}
210 236
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211
-			} else $all = array();
237
+			} else {
238
+				$all = array();
239
+			}
212 240
 		}
213 241
 		if (empty($all)) {
214 242
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -227,10 +255,15 @@  discard block
 block discarded – undo
227 255
 	}
228 256
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
229 257
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
258
+		if ($filter_name == '') {
259
+			$filter_name = $this->filter_name;
260
+		}
231 261
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
262
+			if ($limit) {
263
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
264
+			} else {
265
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
266
+			}
234 267
 			try {
235 268
 				$sth = $this->db->prepare($query);
236 269
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -238,7 +271,9 @@  discard block
 block discarded – undo
238 271
 				echo "error : ".$e->getMessage();
239 272
 			}
240 273
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
274
+		} else {
275
+			$all = array();
276
+		}
242 277
 		if (empty($all)) {
243 278
 			$filters = array('year' => $year,'month' => $month);
244 279
 			if ($filter_name != '') {
@@ -252,10 +287,15 @@  discard block
 block discarded – undo
252 287
 	}
253 288
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
254 289
 		global $globalStatsFilters;
255
-		if ($filter_name == '') $filter_name = $this->filter_name;
290
+		if ($filter_name == '') {
291
+			$filter_name = $this->filter_name;
292
+		}
256 293
 		if ($year == '' && $month == '') {
257
-			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";
258
-			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";
294
+			if ($limit) {
295
+				$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";
296
+			} else {
297
+				$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";
298
+			}
259 299
 			try {
260 300
 				$sth = $this->db->prepare($query);
261 301
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -263,7 +303,9 @@  discard block
 block discarded – undo
263 303
 				echo "error : ".$e->getMessage();
264 304
 			}
265 305
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
266
-		} else $all = array();
306
+		} else {
307
+			$all = array();
308
+		}
267 309
 		if (empty($all)) {
268 310
 			$Spotter = new Spotter($this->db);
269 311
 			$filters = array();
@@ -278,7 +320,9 @@  discard block
 block discarded – undo
278 320
 	}
279 321
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
280 322
 		global $globalStatsFilters;
281
-		if ($filter_name == '') $filter_name = $this->filter_name;
323
+		if ($filter_name == '') {
324
+			$filter_name = $this->filter_name;
325
+		}
282 326
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
283 327
 			$Spotter = new Spotter($this->db);
284 328
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -287,8 +331,11 @@  discard block
 block discarded – undo
287 331
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
288 332
 			}
289 333
 			if ($year == '' && $month == '') {
290
-				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";
291
-				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";
334
+				if ($limit) {
335
+					$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";
336
+				} else {
337
+					$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";
338
+				}
292 339
 				try {
293 340
 					$sth = $this->db->prepare($query);
294 341
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -296,11 +343,16 @@  discard block
 block discarded – undo
296 343
 					echo "error : ".$e->getMessage();
297 344
 				}
298 345
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
299
-			} else $all = array();
346
+			} else {
347
+				$all = array();
348
+			}
300 349
 		} else {
301 350
 			if ($year == '' && $month == '') {
302
-				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";
303
-				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";
351
+				if ($limit) {
352
+					$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";
353
+				} else {
354
+					$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";
355
+				}
304 356
 				try {
305 357
 					$sth = $this->db->prepare($query);
306 358
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -308,7 +360,9 @@  discard block
 block discarded – undo
308 360
 					echo "error : ".$e->getMessage();
309 361
 				}
310 362
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311
-			} else $all = array();
363
+			} else {
364
+				$all = array();
365
+			}
312 366
 		}
313 367
 		if (empty($all)) {
314 368
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -328,7 +382,9 @@  discard block
 block discarded – undo
328 382
 
329 383
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
330 384
 		global $globalStatsFilters;
331
-		if ($filter_name == '') $filter_name = $this->filter_name;
385
+		if ($filter_name == '') {
386
+			$filter_name = $this->filter_name;
387
+		}
332 388
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
333 389
 			$Spotter = new Spotter($this->db);
334 390
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -337,8 +393,11 @@  discard block
 block discarded – undo
337 393
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
338 394
 			}
339 395
 			if ($year == '' && $month == '') {
340
-				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";
341
-				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";
396
+				if ($limit) {
397
+					$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";
398
+				} else {
399
+					$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";
400
+				}
342 401
 				try {
343 402
 					$sth = $this->db->prepare($query);
344 403
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -346,11 +405,16 @@  discard block
 block discarded – undo
346 405
 					echo "error : ".$e->getMessage();
347 406
 				}
348 407
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
349
-			} else $all = array();
408
+			} else {
409
+				$all = array();
410
+			}
350 411
 		} else {
351 412
 			if ($year == '' && $month == '') {
352
-				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";
353
-				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";
413
+				if ($limit) {
414
+					$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";
415
+				} else {
416
+					$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";
417
+				}
354 418
 				try {
355 419
 					$sth = $this->db->prepare($query);
356 420
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -358,7 +422,9 @@  discard block
 block discarded – undo
358 422
 					echo "error : ".$e->getMessage();
359 423
 				}
360 424
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361
-			} else $all = array();
425
+			} else {
426
+				$all = array();
427
+			}
362 428
 		}
363 429
 		if (empty($all)) {
364 430
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -377,7 +443,9 @@  discard block
 block discarded – undo
377 443
 	}
378 444
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 445
 		global $globalStatsFilters;
380
-		if ($filter_name == '') $filter_name = $this->filter_name;
446
+		if ($filter_name == '') {
447
+			$filter_name = $this->filter_name;
448
+		}
381 449
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
382 450
 			$Spotter = new Spotter($this->db);
383 451
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -385,12 +453,18 @@  discard block
 block discarded – undo
385 453
 			foreach ($airlines as $airline) {
386 454
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
387 455
 			}
388
-			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";
389
-			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";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline 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";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
390 461
 			$query_values = array(':filter_name' => $filter_name);
391 462
 		} else {
392
-			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";
393
-			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";
463
+			if ($limit) {
464
+				$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";
465
+			} else {
466
+				$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";
467
+			}
394 468
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
395 469
 		}
396 470
 		try {
@@ -418,17 +492,29 @@  discard block
 block discarded – undo
418 492
 
419 493
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
420 494
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421
-		if ($filter_name == '') $filter_name = $this->filter_name;
495
+		if ($filter_name == '') {
496
+			$filter_name = $this->filter_name;
497
+		}
422 498
 		if ($year == '' && $month == '') {
423
-			if ($globalVATSIM) $forsource = 'vatsim';
424
-			if ($globalIVAO) $forsource = 'ivao';
499
+			if ($globalVATSIM) {
500
+				$forsource = 'vatsim';
501
+			}
502
+			if ($globalIVAO) {
503
+				$forsource = 'ivao';
504
+			}
425 505
 			if (isset($forsource)) {
426
-				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";
427
-				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";
506
+				if ($limit) {
507
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
510
+				}
428 511
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
429 512
 			} else {
430
-				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";
431
-				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";
513
+				if ($limit) {
514
+					$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";
515
+				} else {
516
+					$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";
517
+				}
432 518
 				$query_values = array(':filter_name' => $filter_name);
433 519
 			}
434 520
 			try {
@@ -438,7 +524,9 @@  discard block
 block discarded – undo
438 524
 				echo "error : ".$e->getMessage();
439 525
 			}
440 526
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
441
-		} else $all = array();
527
+		} else {
528
+			$all = array();
529
+		}
442 530
                 if (empty($all)) {
443 531
 	                $Spotter = new Spotter($this->db);
444 532
             		$filters = array();
@@ -453,7 +541,9 @@  discard block
 block discarded – undo
453 541
 	}
454 542
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
455 543
 		global $globalStatsFilters;
456
-		if ($filter_name == '') $filter_name = $this->filter_name;
544
+		if ($filter_name == '') {
545
+			$filter_name = $this->filter_name;
546
+		}
457 547
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
458 548
 			$Spotter = new Spotter($this->db);
459 549
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -462,8 +552,11 @@  discard block
 block discarded – undo
462 552
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
463 553
 			}
464 554
 			if ($year == '' && $month == '') {
465
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
466
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
555
+				if ($limit) {
556
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
557
+				} else {
558
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
559
+				}
467 560
 				try {
468 561
 					$sth = $this->db->prepare($query);
469 562
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -471,11 +564,16 @@  discard block
 block discarded – undo
471 564
 					echo "error : ".$e->getMessage();
472 565
 				}
473 566
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
474
-			} else $all = array();
567
+			} else {
568
+				$all = array();
569
+			}
475 570
 		} else {
476 571
 			if ($year == '' && $month == '') {
477
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
478
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
572
+				if ($limit) {
573
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
574
+				} else {
575
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY registration_count DESC";
576
+				}
479 577
 				try {
480 578
 					$sth = $this->db->prepare($query);
481 579
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -483,7 +581,9 @@  discard block
 block discarded – undo
483 581
 					echo "error : ".$e->getMessage();
484 582
 				}
485 583
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-			} else $all = array();
584
+			} else {
585
+				$all = array();
586
+			}
487 587
 		}
488 588
 		if (empty($all)) {
489 589
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -502,7 +602,9 @@  discard block
 block discarded – undo
502 602
 	}
503 603
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
504 604
 		global $globalStatsFilters;
505
-		if ($filter_name == '') $filter_name = $this->filter_name;
605
+		if ($filter_name == '') {
606
+			$filter_name = $this->filter_name;
607
+		}
506 608
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
507 609
 			$Spotter = new Spotter($this->db);
508 610
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -511,8 +613,11 @@  discard block
 block discarded – undo
511 613
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
512 614
 			}
513 615
 			if ($year == '' && $month == '') {
514
-				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";
515
-				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";
616
+				if ($limit) {
617
+					$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";
618
+				} else {
619
+					$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";
620
+				}
516 621
 				 try {
517 622
 					$sth = $this->db->prepare($query);
518 623
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -520,11 +625,16 @@  discard block
 block discarded – undo
520 625
 					echo "error : ".$e->getMessage();
521 626
 				}
522 627
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
523
-			} else $all = array();
628
+			} else {
629
+				$all = array();
630
+			}
524 631
 		} else {
525 632
 			if ($year == '' && $month == '') {
526
-				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";
527
-				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";
633
+				if ($limit) {
634
+					$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";
635
+				} else {
636
+					$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";
637
+				}
528 638
 				 try {
529 639
 					$sth = $this->db->prepare($query);
530 640
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -532,7 +642,9 @@  discard block
 block discarded – undo
532 642
 					echo "error : ".$e->getMessage();
533 643
 				}
534 644
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535
-			} else $all = array();
645
+			} else {
646
+				$all = array();
647
+			}
536 648
 		}
537 649
 		if (empty($all)) {
538 650
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -551,7 +663,9 @@  discard block
 block discarded – undo
551 663
 	}
552 664
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
553 665
 		$Connection = new Connection($this->db);
554
-		if ($filter_name == '') $filter_name = $this->filter_name;
666
+		if ($filter_name == '') {
667
+			$filter_name = $this->filter_name;
668
+		}
555 669
 		if ($Connection->tableExists('countries')) {
556 670
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
557 671
 				$Spotter = new Spotter($this->db);
@@ -561,8 +675,11 @@  discard block
 block discarded – undo
561 675
 					foreach ($airlines as $airline) {
562 676
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
563 677
 					}
564
-					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";
565
-					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";
678
+					if ($limit) {
679
+						$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";
680
+					} else {
681
+						$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";
682
+					}
566 683
 					 try {
567 684
 						$sth = $this->db->prepare($query);
568 685
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -571,11 +688,16 @@  discard block
 block discarded – undo
571 688
 					}
572 689
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
573 690
 					return $all;
574
-				} else return array();
691
+				} else {
692
+					return array();
693
+				}
575 694
 			} else {
576 695
 				if ($year == '' && $month == '') {
577
-					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";
578
-					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";
696
+					if ($limit) {
697
+						$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";
698
+					} else {
699
+						$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";
700
+					}
579 701
 					 try {
580 702
 						$sth = $this->db->prepare($query);
581 703
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -584,20 +706,29 @@  discard block
 block discarded – undo
584 706
 					}
585 707
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
586 708
 					return $all;
587
-				} else return array();
709
+				} else {
710
+					return array();
711
+				}
588 712
 			}
589 713
 			$Spotter = new Spotter($this->db);
590 714
 			return $Spotter->countAllFlightOverCountries($limit);
591
-		} else return array();
715
+		} else {
716
+			return array();
717
+		}
592 718
 	}
593 719
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
594 720
 		$Connection = new Connection($this->db);
595
-		if ($filter_name == '') $filter_name = $this->filter_name;
721
+		if ($filter_name == '') {
722
+			$filter_name = $this->filter_name;
723
+		}
596 724
 		if ($Connection->tableExists('countries')) {
597 725
 			$all = array();
598 726
 			if ($year == '' && $month == '') {
599
-				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";
600
-				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";
727
+				if ($limit) {
728
+					$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";
729
+				} else {
730
+					$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";
731
+				}
601 732
 				 try {
602 733
 					$sth = $this->db->prepare($query);
603 734
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -615,17 +746,24 @@  discard block
 block discarded – undo
615 746
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
616 747
 			}
617 748
 			return $all;
618
-		} else return array();
749
+		} else {
750
+			return array();
751
+		}
619 752
 	}
620 753
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
621 754
 		global $globalStatsFilters;
622 755
 		$Connection = new Connection($this->db);
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
756
+		if ($filter_name == '') {
757
+			$filter_name = $this->filter_name;
758
+		}
624 759
 		if ($Connection->tableExists('countries')) {
625 760
 			$all = array();
626 761
 			if ($year == '' && $month == '') {
627
-				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";
628
-				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";
762
+				if ($limit) {
763
+					$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";
764
+				} else {
765
+					$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";
766
+				}
629 767
 				 try {
630 768
 					$sth = $this->db->prepare($query);
631 769
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -644,14 +782,21 @@  discard block
 block discarded – undo
644 782
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
645 783
 			}
646 784
 			return $all;
647
-		} else return array();
785
+		} else {
786
+			return array();
787
+		}
648 788
 	}
649 789
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
650 790
 		global $globalStatsFilters;
651
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
+		if ($filter_name == '') {
792
+			$filter_name = $this->filter_name;
793
+		}
652 794
 		if ($year == '' && $month == '') {
653
-			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";
654
-			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";
795
+			if ($limit) {
796
+				$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";
797
+			} else {
798
+				$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";
799
+			}
655 800
 			try {
656 801
 				$sth = $this->db->prepare($query);
657 802
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -659,7 +804,9 @@  discard block
 block discarded – undo
659 804
 				echo "error : ".$e->getMessage();
660 805
 			}
661 806
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662
-		} else $all = array();
807
+		} else {
808
+			$all = array();
809
+		}
663 810
 		if (empty($all)) {
664 811
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
665 812
 			if ($filter_name != '') {
@@ -674,7 +821,9 @@  discard block
 block discarded – undo
674 821
 
675 822
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
676 823
 		global $globalStatsFilters;
677
-		if ($filter_name == '') $filter_name = $this->filter_name;
824
+		if ($filter_name == '') {
825
+			$filter_name = $this->filter_name;
826
+		}
678 827
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
679 828
 			$Spotter = new Spotter($this->db);
680 829
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -683,8 +832,11 @@  discard block
 block discarded – undo
683 832
 				foreach ($airlines as $airline) {
684 833
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
685 834
 				}
686
-				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";
687
-				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";
835
+				if ($limit) {
836
+					$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";
837
+				} else {
838
+					$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";
839
+				}
688 840
 				try {
689 841
 					$sth = $this->db->prepare($query);
690 842
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -692,11 +844,16 @@  discard block
 block discarded – undo
692 844
 					echo "error : ".$e->getMessage();
693 845
 				}
694 846
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-			} else $all = array();
847
+			} else {
848
+				$all = array();
849
+			}
696 850
 		} else {
697 851
 			if ($year == '' && $month == '') {
698
-				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";
699
-				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";
852
+				if ($limit) {
853
+					$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";
854
+				} else {
855
+					$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";
856
+				}
700 857
 				try {
701 858
 					$sth = $this->db->prepare($query);
702 859
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -704,7 +861,9 @@  discard block
 block discarded – undo
704 861
 					echo "error : ".$e->getMessage();
705 862
 				}
706 863
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707
-			} else $all = array();
864
+			} else {
865
+				$all = array();
866
+			}
708 867
 		}
709 868
 		if (empty($all)) {
710 869
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -723,7 +882,9 @@  discard block
 block discarded – undo
723 882
 	}
724 883
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
725 884
 		global $globalStatsFilters;
726
-		if ($filter_name == '') $filter_name = $this->filter_name;
885
+		if ($filter_name == '') {
886
+			$filter_name = $this->filter_name;
887
+		}
727 888
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
728 889
 			$Spotter = new Spotter($this->db);
729 890
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -732,8 +893,11 @@  discard block
 block discarded – undo
732 893
 				foreach ($airlines as $airline) {
733 894
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
734 895
 				}
735
-				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";
736
-				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";
896
+				if ($limit) {
897
+					$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";
898
+				} else {
899
+					$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";
900
+				}
737 901
 				try {
738 902
 					$sth = $this->db->prepare($query);
739 903
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -741,11 +905,16 @@  discard block
 block discarded – undo
741 905
 					echo "error : ".$e->getMessage();
742 906
 				}
743 907
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
744
-			} else $all = array();
908
+			} else {
909
+				$all = array();
910
+			}
745 911
 		} else {
746 912
 			if ($year == '' && $month == '') {
747
-				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";
748
-				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";
913
+				if ($limit) {
914
+					$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";
915
+				} else {
916
+					$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";
917
+				}
749 918
 				try {
750 919
 					$sth = $this->db->prepare($query);
751 920
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -753,7 +922,9 @@  discard block
 block discarded – undo
753 922
 					echo "error : ".$e->getMessage();
754 923
 				}
755 924
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756
-			} else $all = array();
925
+			} else {
926
+				$all = array();
927
+			}
757 928
 		}
758 929
 		if (empty($all)) {
759 930
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -778,7 +949,9 @@  discard block
 block discarded – undo
778 949
 				$icao = $value['airport_departure_icao'];
779 950
 				if (isset($all[$icao])) {
780 951
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
781
-				} else $all[$icao] = $value;
952
+				} else {
953
+					$all[$icao] = $value;
954
+				}
782 955
 			}
783 956
 			$count = array();
784 957
 			foreach ($all as $key => $row) {
@@ -790,7 +963,9 @@  discard block
 block discarded – undo
790 963
 	}
791 964
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
792 965
 		global $globalStatsFilters;
793
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
794 969
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
795 970
 			$Spotter = new Spotter($this->db);
796 971
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -799,8 +974,11 @@  discard block
 block discarded – undo
799 974
 				foreach ($airlines as $airline) {
800 975
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
801 976
 				}
802
-				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";
803
-				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";
977
+				if ($limit) {
978
+					$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";
979
+				} else {
980
+					$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";
981
+				}
804 982
 				try {
805 983
 					$sth = $this->db->prepare($query);
806 984
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -808,11 +986,16 @@  discard block
 block discarded – undo
808 986
 					echo "error : ".$e->getMessage();
809 987
 				}
810 988
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
811
-			} else $all = array();
989
+			} else {
990
+				$all = array();
991
+			}
812 992
 		} else {
813 993
 			if ($year == '' && $month == '') {
814
-				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";
815
-				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";
994
+				if ($limit) {
995
+					$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";
996
+				} else {
997
+					$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";
998
+				}
816 999
 				try {
817 1000
 					$sth = $this->db->prepare($query);
818 1001
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -820,7 +1003,9 @@  discard block
 block discarded – undo
820 1003
 					echo "error : ".$e->getMessage();
821 1004
 				}
822 1005
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823
-			} else $all = array();
1006
+			} else {
1007
+				$all = array();
1008
+			}
824 1009
 		}
825 1010
 		if (empty($all)) {
826 1011
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -845,7 +1030,9 @@  discard block
 block discarded – undo
845 1030
 				$icao = $value['airport_arrival_icao'];
846 1031
 				if (isset($all[$icao])) {
847 1032
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
848
-				} else $all[$icao] = $value;
1033
+				} else {
1034
+					$all[$icao] = $value;
1035
+				}
849 1036
 			}
850 1037
 			$count = array();
851 1038
 			foreach ($all as $key => $row) {
@@ -857,7 +1044,9 @@  discard block
 block discarded – undo
857 1044
 	}
858 1045
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
859 1046
 		global $globalDBdriver, $globalStatsFilters;
860
-		if ($filter_name == '') $filter_name = $this->filter_name;
1047
+		if ($filter_name == '') {
1048
+			$filter_name = $this->filter_name;
1049
+		}
861 1050
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
862 1051
 			$Spotter = new Spotter($this->db);
863 1052
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -866,20 +1055,32 @@  discard block
 block discarded – undo
866 1055
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
867 1056
 			}
868 1057
 			if ($globalDBdriver == 'mysql') {
869
-				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";
870
-				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";
1058
+				if ($limit) {
1059
+					$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";
1060
+				} else {
1061
+					$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";
1062
+				}
871 1063
 			} else {
872
-				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";
873
-				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";
1064
+				if ($limit) {
1065
+					$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";
1066
+				} else {
1067
+					$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";
1068
+				}
874 1069
 			}
875 1070
 			$query_data = array(':filter_name' => $filter_name);
876 1071
 		} else {
877 1072
 			if ($globalDBdriver == 'mysql') {
878
-				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";
879
-				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";
1073
+				if ($limit) {
1074
+					$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";
1075
+				} else {
1076
+					$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";
1077
+				}
880 1078
 			} else {
881
-				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";
882
-				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";
1079
+				if ($limit) {
1080
+					$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";
1081
+				} else {
1082
+					$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";
1083
+				}
883 1084
 			}
884 1085
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
885 1086
 		}
@@ -907,13 +1108,21 @@  discard block
 block discarded – undo
907 1108
 
908 1109
 	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
909 1110
 		global $globalDBdriver, $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1111
+		if ($filter_name == '') {
1112
+			$filter_name = $this->filter_name;
1113
+		}
911 1114
 		if ($globalDBdriver == 'mysql') {
912
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
913
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1115
+			if ($limit) {
1116
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1117
+			} else {
1118
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1119
+			}
914 1120
 		} else {
915
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
916
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1121
+			if ($limit) {
1122
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1123
+			} else {
1124
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1125
+			}
917 1126
 		}
918 1127
 		$query_data = array(':filter_name' => $filter_name);
919 1128
 		try {
@@ -936,13 +1145,21 @@  discard block
 block discarded – undo
936 1145
 
937 1146
 	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
938 1147
 		global $globalDBdriver, $globalStatsFilters;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1148
+		if ($filter_name == '') {
1149
+			$filter_name = $this->filter_name;
1150
+		}
940 1151
 		if ($globalDBdriver == 'mysql') {
941
-			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 = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
942
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1152
+			if ($limit) {
1153
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1154
+			} else {
1155
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1156
+			}
943 1157
 		} else {
944
-			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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
945
-			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 = 'tracker_bymonth' AND filter_name = :filter_name";
1158
+			if ($limit) {
1159
+				$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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1160
+			} else {
1161
+				$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 = 'tracker_bymonth' AND filter_name = :filter_name";
1162
+			}
946 1163
 		}
947 1164
 		$query_data = array(':filter_name' => $filter_name);
948 1165
 		try {
@@ -965,7 +1182,9 @@  discard block
 block discarded – undo
965 1182
 	
966 1183
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
967 1184
 		global $globalStatsFilters;
968
-		if ($filter_name == '') $filter_name = $this->filter_name;
1185
+		if ($filter_name == '') {
1186
+			$filter_name = $this->filter_name;
1187
+		}
969 1188
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
970 1189
 			$Spotter = new Spotter($this->db);
971 1190
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1002,7 +1221,9 @@  discard block
 block discarded – undo
1002 1221
 	}
1003 1222
 	public function countAllMarineDatesLastMonth($filter_name = '') {
1004 1223
 		global $globalStatsFilters;
1005
-		if ($filter_name == '') $filter_name = $this->filter_name;
1224
+		if ($filter_name == '') {
1225
+			$filter_name = $this->filter_name;
1226
+		}
1006 1227
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name";
1007 1228
 		$query_data = array(':filter_name' => $filter_name);
1008 1229
 		try {
@@ -1024,7 +1245,9 @@  discard block
 block discarded – undo
1024 1245
 	}
1025 1246
 	public function countAllTrackerDatesLastMonth($filter_name = '') {
1026 1247
 		global $globalStatsFilters;
1027
-		if ($filter_name == '') $filter_name = $this->filter_name;
1248
+		if ($filter_name == '') {
1249
+			$filter_name = $this->filter_name;
1250
+		}
1028 1251
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name";
1029 1252
 		$query_data = array(':filter_name' => $filter_name);
1030 1253
 		try {
@@ -1046,7 +1269,9 @@  discard block
 block discarded – undo
1046 1269
 	}
1047 1270
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1048 1271
 		global $globalDBdriver, $globalStatsFilters;
1049
-		if ($filter_name == '') $filter_name = $this->filter_name;
1272
+		if ($filter_name == '') {
1273
+			$filter_name = $this->filter_name;
1274
+		}
1050 1275
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1051 1276
 			$Spotter = new Spotter($this->db);
1052 1277
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1091,7 +1316,9 @@  discard block
 block discarded – undo
1091 1316
 	}
1092 1317
 	public function countAllMarineDatesLast7Days($filter_name = '') {
1093 1318
 		global $globalDBdriver, $globalStatsFilters;
1094
-		if ($filter_name == '') $filter_name = $this->filter_name;
1319
+		if ($filter_name == '') {
1320
+			$filter_name = $this->filter_name;
1321
+		}
1095 1322
 		if ($globalDBdriver == 'mysql') {
1096 1323
 			$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1097 1324
 		} else {
@@ -1117,7 +1344,9 @@  discard block
 block discarded – undo
1117 1344
 	}
1118 1345
 	public function countAllTrackerDatesLast7Days($filter_name = '') {
1119 1346
 		global $globalDBdriver, $globalStatsFilters;
1120
-		if ($filter_name == '') $filter_name = $this->filter_name;
1347
+		if ($filter_name == '') {
1348
+			$filter_name = $this->filter_name;
1349
+		}
1121 1350
 		if ($globalDBdriver == 'mysql') {
1122 1351
 			$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1123 1352
 		} else {
@@ -1143,7 +1372,9 @@  discard block
 block discarded – undo
1143 1372
 	}
1144 1373
 	public function countAllDates($stats_airline = '',$filter_name = '') {
1145 1374
 		global $globalStatsFilters;
1146
-		if ($filter_name == '') $filter_name = $this->filter_name;
1375
+		if ($filter_name == '') {
1376
+			$filter_name = $this->filter_name;
1377
+		}
1147 1378
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1148 1379
 			$Spotter = new Spotter($this->db);
1149 1380
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1180,7 +1411,9 @@  discard block
 block discarded – undo
1180 1411
 	}
1181 1412
 	public function countAllDatesMarine($filter_name = '') {
1182 1413
 		global $globalStatsFilters;
1183
-		if ($filter_name == '') $filter_name = $this->filter_name;
1414
+		if ($filter_name == '') {
1415
+			$filter_name = $this->filter_name;
1416
+		}
1184 1417
 		$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";
1185 1418
 		$query_data = array(':filter_name' => $filter_name);
1186 1419
 		try {
@@ -1202,7 +1435,9 @@  discard block
 block discarded – undo
1202 1435
 	}
1203 1436
 	public function countAllDatesTracker($filter_name = '') {
1204 1437
 		global $globalStatsFilters;
1205
-		if ($filter_name == '') $filter_name = $this->filter_name;
1438
+		if ($filter_name == '') {
1439
+			$filter_name = $this->filter_name;
1440
+		}
1206 1441
 		$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";
1207 1442
 		$query_data = array(':filter_name' => $filter_name);
1208 1443
 		try {
@@ -1224,7 +1459,9 @@  discard block
 block discarded – undo
1224 1459
 	}
1225 1460
 	public function countAllDatesByAirlines($filter_name = '') {
1226 1461
 		global $globalStatsFilters;
1227
-		if ($filter_name == '') $filter_name = $this->filter_name;
1462
+		if ($filter_name == '') {
1463
+			$filter_name = $this->filter_name;
1464
+		}
1228 1465
 		$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";
1229 1466
 		$query_data = array('filter_name' => $filter_name);
1230 1467
 		try {
@@ -1246,7 +1483,9 @@  discard block
 block discarded – undo
1246 1483
 	}
1247 1484
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1248 1485
 		global $globalStatsFilters, $globalDBdriver;
1249
-		if ($filter_name == '') $filter_name = $this->filter_name;
1486
+		if ($filter_name == '') {
1487
+			$filter_name = $this->filter_name;
1488
+		}
1250 1489
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1251 1490
 			$Spotter = new Spotter($this->db);
1252 1491
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1331,7 +1570,9 @@  discard block
 block discarded – undo
1331 1570
 	}
1332 1571
 	public function countAllMilitaryMonths($filter_name = '') {
1333 1572
 		global $globalStatsFilters;
1334
-		if ($filter_name == '') $filter_name = $this->filter_name;
1573
+		if ($filter_name == '') {
1574
+			$filter_name = $this->filter_name;
1575
+		}
1335 1576
 		$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";
1336 1577
 		try {
1337 1578
 			$sth = $this->db->prepare($query);
@@ -1352,7 +1593,9 @@  discard block
 block discarded – undo
1352 1593
 	}
1353 1594
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1354 1595
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355
-		if ($filter_name == '') $filter_name = $this->filter_name;
1596
+		if ($filter_name == '') {
1597
+			$filter_name = $this->filter_name;
1598
+		}
1356 1599
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1357 1600
 			$Spotter = new Spotter($this->db);
1358 1601
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1360,12 +1603,18 @@  discard block
 block discarded – undo
1360 1603
 			foreach ($airlines as $airline) {
1361 1604
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1362 1605
 			}
1363
-			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";
1364
-			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";
1606
+			if ($limit) {
1607
+				$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";
1608
+			} else {
1609
+				$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";
1610
+			}
1365 1611
 			$query_data = array(':filter_name' => $filter_name);
1366 1612
 		} else {
1367
-			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";
1368
-			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";
1613
+			if ($limit) {
1614
+				$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";
1615
+			} else {
1616
+				$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";
1617
+			}
1369 1618
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1370 1619
 		}
1371 1620
 		if ($orderby == 'hour') {
@@ -1375,7 +1624,9 @@  discard block
 block discarded – undo
1375 1624
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1376 1625
 			}
1377 1626
 		}
1378
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1627
+		if ($orderby == 'count') {
1628
+			$query .= " ORDER BY hour_count DESC";
1629
+		}
1379 1630
 		try {
1380 1631
 			$sth = $this->db->prepare($query);
1381 1632
 			$sth->execute($query_data);
@@ -1399,9 +1650,14 @@  discard block
 block discarded – undo
1399 1650
 	}
1400 1651
 	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1401 1652
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402
-		if ($filter_name == '') $filter_name = $this->filter_name;
1403
-		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1404
-		else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1653
+		if ($filter_name == '') {
1654
+			$filter_name = $this->filter_name;
1655
+		}
1656
+		if ($limit) {
1657
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1658
+		} else {
1659
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1660
+		}
1405 1661
 		$query_data = array(':filter_name' => $filter_name);
1406 1662
 		if ($orderby == 'hour') {
1407 1663
 			if ($globalDBdriver == 'mysql') {
@@ -1410,7 +1666,9 @@  discard block
 block discarded – undo
1410 1666
 				$query .= " ORDER BY CAST(marine_date AS integer) ASC";
1411 1667
 			}
1412 1668
 		}
1413
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1669
+		if ($orderby == 'count') {
1670
+			$query .= " ORDER BY hour_count DESC";
1671
+		}
1414 1672
 		try {
1415 1673
 			$sth = $this->db->prepare($query);
1416 1674
 			$sth->execute($query_data);
@@ -1430,9 +1688,14 @@  discard block
 block discarded – undo
1430 1688
 	}
1431 1689
 	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1432 1690
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433
-		if ($filter_name == '') $filter_name = $this->filter_name;
1434
-		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1435
-		else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1691
+		if ($filter_name == '') {
1692
+			$filter_name = $this->filter_name;
1693
+		}
1694
+		if ($limit) {
1695
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1696
+		} else {
1697
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1698
+		}
1436 1699
 		$query_data = array(':filter_name' => $filter_name);
1437 1700
 		if ($orderby == 'hour') {
1438 1701
 			if ($globalDBdriver == 'mysql') {
@@ -1441,7 +1704,9 @@  discard block
 block discarded – undo
1441 1704
 				$query .= " ORDER BY CAST(tracker_date AS integer) ASC";
1442 1705
 			}
1443 1706
 		}
1444
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1707
+		if ($orderby == 'count') {
1708
+			$query .= " ORDER BY hour_count DESC";
1709
+		}
1445 1710
 		try {
1446 1711
 			$sth = $this->db->prepare($query);
1447 1712
 			$sth->execute($query_data);
@@ -1461,8 +1726,12 @@  discard block
 block discarded – undo
1461 1726
 	}
1462 1727
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1463 1728
 		global $globalStatsFilters;
1464
-		if ($filter_name == '') $filter_name = $this->filter_name;
1465
-		if ($year == '') $year = date('Y');
1729
+		if ($filter_name == '') {
1730
+			$filter_name = $this->filter_name;
1731
+		}
1732
+		if ($year == '') {
1733
+			$year = date('Y');
1734
+		}
1466 1735
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1467 1736
 		if (empty($all)) {
1468 1737
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1481,8 +1750,12 @@  discard block
 block discarded – undo
1481 1750
 	}
1482 1751
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1483 1752
 		global $globalStatsFilters;
1484
-		if ($filter_name == '') $filter_name = $this->filter_name;
1485
-		if ($year == '') $year = date('Y');
1753
+		if ($filter_name == '') {
1754
+			$filter_name = $this->filter_name;
1755
+		}
1756
+		if ($year == '') {
1757
+			$year = date('Y');
1758
+		}
1486 1759
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1487 1760
 		if (empty($all)) {
1488 1761
 			$filters = array('year' => $year,'month' => $month);
@@ -1497,8 +1770,12 @@  discard block
 block discarded – undo
1497 1770
 	}
1498 1771
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1499 1772
 		global $globalStatsFilters;
1500
-		if ($filter_name == '') $filter_name = $this->filter_name;
1501
-		if ($year == '') $year = date('Y');
1773
+		if ($filter_name == '') {
1774
+			$filter_name = $this->filter_name;
1775
+		}
1776
+		if ($year == '') {
1777
+			$year = date('Y');
1778
+		}
1502 1779
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1503 1780
 		if (empty($all)) {
1504 1781
 			$filters = array('year' => $year,'month' => $month);
@@ -1513,8 +1790,12 @@  discard block
 block discarded – undo
1513 1790
 	}
1514 1791
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1515 1792
 		global $globalStatsFilters;
1516
-		if ($filter_name == '') $filter_name = $this->filter_name;
1517
-		if ($year == '') $year = date('Y');
1793
+		if ($filter_name == '') {
1794
+			$filter_name = $this->filter_name;
1795
+		}
1796
+		if ($year == '') {
1797
+			$year = date('Y');
1798
+		}
1518 1799
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1519 1800
 		if (empty($all)) {
1520 1801
 			$filters = array();
@@ -1530,8 +1811,12 @@  discard block
 block discarded – undo
1530 1811
 	}
1531 1812
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1532 1813
 		global $globalStatsFilters;
1533
-		if ($filter_name == '') $filter_name = $this->filter_name;
1534
-		if ($year == '') $year = date('Y');
1814
+		if ($filter_name == '') {
1815
+			$filter_name = $this->filter_name;
1816
+		}
1817
+		if ($year == '') {
1818
+			$year = date('Y');
1819
+		}
1535 1820
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1536 1821
 		if (empty($all)) {
1537 1822
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1550,7 +1835,9 @@  discard block
 block discarded – undo
1550 1835
 	}
1551 1836
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1552 1837
 		global $globalStatsFilters;
1553
-		if ($filter_name == '') $filter_name = $this->filter_name;
1838
+		if ($filter_name == '') {
1839
+			$filter_name = $this->filter_name;
1840
+		}
1554 1841
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1555 1842
 			$Spotter = new Spotter($this->db);
1556 1843
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1568,7 +1855,9 @@  discard block
 block discarded – undo
1568 1855
 				}
1569 1856
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1857
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1858
+			} else {
1859
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1860
+			}
1572 1861
 		} else {
1573 1862
 			if ($year == '' && $month == '') {
1574 1863
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1580,7 +1869,9 @@  discard block
 block discarded – undo
1580 1869
 				}
1581 1870
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1871
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1872
+			} else {
1873
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1874
+			}
1584 1875
 		}
1585 1876
 		if (empty($all)) {
1586 1877
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1599,7 +1890,9 @@  discard block
 block discarded – undo
1599 1890
 	}
1600 1891
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1601 1892
 		global $globalStatsFilters;
1602
-		if ($filter_name == '') $filter_name = $this->filter_name;
1893
+		if ($filter_name == '') {
1894
+			$filter_name = $this->filter_name;
1895
+		}
1603 1896
 		if ($year == '' && $month == '') {
1604 1897
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1605 1898
 			try {
@@ -1610,7 +1903,9 @@  discard block
 block discarded – undo
1610 1903
 			}
1611 1904
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1905
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1906
+		} else {
1907
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1908
+		}
1614 1909
 		if (empty($all)) {
1615 1910
 			$filters = array();
1616 1911
 			$filters = array('year' => $year,'month' => $month);
@@ -1625,7 +1920,9 @@  discard block
 block discarded – undo
1625 1920
 	}
1626 1921
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1627 1922
 		global $globalStatsFilters;
1628
-		if ($filter_name == '') $filter_name = $this->filter_name;
1923
+		if ($filter_name == '') {
1924
+			$filter_name = $this->filter_name;
1925
+		}
1629 1926
 		$all = array();
1630 1927
 		if ($year == '' && $month == '') {
1631 1928
 			$query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1652,7 +1949,9 @@  discard block
 block discarded – undo
1652 1949
 	}
1653 1950
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1654 1951
 		global $globalStatsFilters;
1655
-		if ($filter_name == '') $filter_name = $this->filter_name;
1952
+		if ($filter_name == '') {
1953
+			$filter_name = $this->filter_name;
1954
+		}
1656 1955
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1657 1956
 			$Spotter = new Spotter($this->db);
1658 1957
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1707,7 +2006,9 @@  discard block
 block discarded – undo
1707 2006
 	}
1708 2007
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1709 2008
 		global $globalStatsFilters;
1710
-		if ($filter_name == '') $filter_name = $this->filter_name;
2009
+		if ($filter_name == '') {
2010
+			$filter_name = $this->filter_name;
2011
+		}
1711 2012
 		//if ($year == '') $year = date('Y');
1712 2013
 		if ($year == '' && $month == '') {
1713 2014
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1736,7 +2037,9 @@  discard block
 block discarded – undo
1736 2037
 	}
1737 2038
 
1738 2039
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1739
-		if ($filter_name == '') $filter_name = $this->filter_name;
2040
+		if ($filter_name == '') {
2041
+			$filter_name = $this->filter_name;
2042
+		}
1740 2043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1741 2044
 			$Spotter = new Spotter($this->db);
1742 2045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1760,7 +2063,9 @@  discard block
 block discarded – undo
1760 2063
 		return $all;
1761 2064
 	}
1762 2065
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1763
-		if ($filter_name == '') $filter_name = $this->filter_name;
2066
+		if ($filter_name == '') {
2067
+			$filter_name = $this->filter_name;
2068
+		}
1764 2069
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765 2070
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1766 2071
 		try {
@@ -1773,7 +2078,9 @@  discard block
 block discarded – undo
1773 2078
 		return $all;
1774 2079
 	}
1775 2080
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1776
-		if ($filter_name == '') $filter_name = $this->filter_name;
2081
+		if ($filter_name == '') {
2082
+			$filter_name = $this->filter_name;
2083
+		}
1777 2084
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778 2085
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1779 2086
 		try {
@@ -1784,7 +2091,9 @@  discard block
 block discarded – undo
1784 2091
 		}
1785 2092
 	}
1786 2093
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1787
-		if ($filter_name == '') $filter_name = $this->filter_name;
2094
+		if ($filter_name == '') {
2095
+			$filter_name = $this->filter_name;
2096
+		}
1788 2097
 		global $globalArchiveMonths, $globalDBdriver;
1789 2098
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1790 2099
 			$Spotter = new Spotter($this->db);
@@ -1840,7 +2149,9 @@  discard block
 block discarded – undo
1840 2149
 	}
1841 2150
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 2151
 		global $globalArchiveMonths, $globalDBdriver;
1843
-		if ($filter_name == '') $filter_name = $this->filter_name;
2152
+		if ($filter_name == '') {
2153
+			$filter_name = $this->filter_name;
2154
+		}
1844 2155
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1845 2156
 			$Spotter = new Spotter($this->db);
1846 2157
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1873,7 +2184,9 @@  discard block
 block discarded – undo
1873 2184
 	}
1874 2185
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 2186
 		global $globalArchiveMonths, $globalDBdriver;
1876
-		if ($filter_name == '') $filter_name = $this->filter_name;
2187
+		if ($filter_name == '') {
2188
+			$filter_name = $this->filter_name;
2189
+		}
1877 2190
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1878 2191
 			$Spotter = new Spotter($this->db);
1879 2192
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1904,7 +2217,9 @@  discard block
 block discarded – undo
1904 2217
 	}
1905 2218
 	public function getStatsAirlineTotal($filter_name = '') {
1906 2219
 		global $globalArchiveMonths, $globalDBdriver;
1907
-		if ($filter_name == '') $filter_name = $this->filter_name;
2220
+		if ($filter_name == '') {
2221
+			$filter_name = $this->filter_name;
2222
+		}
1908 2223
 		if ($globalDBdriver == 'mysql') {
1909 2224
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1910 2225
 		} else {
@@ -1921,7 +2236,9 @@  discard block
 block discarded – undo
1921 2236
 	}
1922 2237
 	public function getStatsOwnerTotal($filter_name = '') {
1923 2238
 		global $globalArchiveMonths, $globalDBdriver;
1924
-		if ($filter_name == '') $filter_name = $this->filter_name;
2239
+		if ($filter_name == '') {
2240
+			$filter_name = $this->filter_name;
2241
+		}
1925 2242
 		if ($globalDBdriver == 'mysql') {
1926 2243
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1927 2244
 		} else {
@@ -1938,7 +2255,9 @@  discard block
 block discarded – undo
1938 2255
 	}
1939 2256
 	public function getStatsOwner($owner_name,$filter_name = '') {
1940 2257
 		global $globalArchiveMonths, $globalDBdriver;
1941
-		if ($filter_name == '') $filter_name = $this->filter_name;
2258
+		if ($filter_name == '') {
2259
+			$filter_name = $this->filter_name;
2260
+		}
1942 2261
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 2262
 		try {
1944 2263
 			$sth = $this->db->prepare($query);
@@ -1947,12 +2266,17 @@  discard block
 block discarded – undo
1947 2266
 			echo "error : ".$e->getMessage();
1948 2267
 		}
1949 2268
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1950
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1951
-		else return 0;
2269
+		if (isset($all[0]['cnt'])) {
2270
+			return $all[0]['cnt'];
2271
+		} else {
2272
+			return 0;
2273
+		}
1952 2274
 	}
1953 2275
 	public function getStatsPilotTotal($filter_name = '') {
1954 2276
 		global $globalArchiveMonths, $globalDBdriver;
1955
-		if ($filter_name == '') $filter_name = $this->filter_name;
2277
+		if ($filter_name == '') {
2278
+			$filter_name = $this->filter_name;
2279
+		}
1956 2280
 		if ($globalDBdriver == 'mysql') {
1957 2281
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1958 2282
 		} else {
@@ -1969,7 +2293,9 @@  discard block
 block discarded – undo
1969 2293
 	}
1970 2294
 	public function getStatsPilot($pilot,$filter_name = '') {
1971 2295
 		global $globalArchiveMonths, $globalDBdriver;
1972
-		if ($filter_name == '') $filter_name = $this->filter_name;
2296
+		if ($filter_name == '') {
2297
+			$filter_name = $this->filter_name;
2298
+		}
1973 2299
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 2300
 		try {
1975 2301
 			$sth = $this->db->prepare($query);
@@ -1978,13 +2304,18 @@  discard block
 block discarded – undo
1978 2304
 			echo "error : ".$e->getMessage();
1979 2305
 		}
1980 2306
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1981
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1982
-		else return 0;
2307
+		if (isset($all[0]['cnt'])) {
2308
+			return $all[0]['cnt'];
2309
+		} else {
2310
+			return 0;
2311
+		}
1983 2312
 	}
1984 2313
 
1985 2314
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1986 2315
 		global $globalDBdriver;
1987
-		if ($filter_name == '') $filter_name = $this->filter_name;
2316
+		if ($filter_name == '') {
2317
+			$filter_name = $this->filter_name;
2318
+		}
1988 2319
 		if ($globalDBdriver == 'mysql') {
1989 2320
 			$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";
1990 2321
 		} else {
@@ -2000,7 +2331,9 @@  discard block
 block discarded – undo
2000 2331
 	}
2001 2332
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2002 2333
 		global $globalDBdriver;
2003
-		if ($filter_name == '') $filter_name = $this->filter_name;
2334
+		if ($filter_name == '') {
2335
+			$filter_name = $this->filter_name;
2336
+		}
2004 2337
 		if ($globalDBdriver == 'mysql') {
2005 2338
 			$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";
2006 2339
 		} else {
@@ -2519,27 +2852,37 @@  discard block
 block discarded – undo
2519 2852
 		date_default_timezone_set('UTC');
2520 2853
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2521 2854
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2522
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2855
+			if ($globalDebug) {
2856
+				echo '!!! Update Marine stats !!!'."\n";
2857
+			}
2523 2858
 			if (isset($last_update[0]['value'])) {
2524 2859
 				$last_update_day = $last_update[0]['value'];
2525
-			} else $last_update_day = '2012-12-12 12:12:12';
2860
+			} else {
2861
+				$last_update_day = '2012-12-12 12:12:12';
2862
+			}
2526 2863
 			$reset = false;
2527 2864
 			$Marine = new Marine($this->db);
2528 2865
 			$filtername = 'marine';
2529 2866
 			if ($Connection->tableExists('countries')) {
2530
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2867
+				if ($globalDebug) {
2868
+					echo 'Count all vessels by countries...'."\n";
2869
+				}
2531 2870
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2532 2871
 				foreach ($alldata as $number) {
2533 2872
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2534 2873
 				}
2535 2874
 			}
2536
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2875
+			if ($globalDebug) {
2876
+				echo 'Count all vessels by months...'."\n";
2877
+			}
2537 2878
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2538 2879
 			$filter_last_month = array('since_date' => $last_month);
2539 2880
 			$alldata = $Marine->countAllMonths($filter_last_month);
2540 2881
 			$lastyear = false;
2541 2882
 			foreach ($alldata as $number) {
2542
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2883
+				if ($number['year_name'] != date('Y')) {
2884
+					$lastyear = true;
2885
+				}
2543 2886
 				$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'])));
2544 2887
 			}
2545 2888
 			echo 'Marine data...'."\n";
@@ -2569,7 +2912,9 @@  discard block
 block discarded – undo
2569 2912
 			foreach ($alldata as $number) {
2570 2913
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2571 2914
 			}
2572
-			if ($globalDebug) echo 'Count all types...'."\n";
2915
+			if ($globalDebug) {
2916
+				echo 'Count all types...'."\n";
2917
+			}
2573 2918
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2574 2919
 			foreach ($alldata as $number) {
2575 2920
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2581,26 +2926,36 @@  discard block
 block discarded – undo
2581 2926
 		}
2582 2927
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2928
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2584
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2929
+			if ($globalDebug) {
2930
+				echo '!!! Update tracker stats !!!'."\n";
2931
+			}
2585 2932
 			if (isset($last_update[0]['value'])) {
2586 2933
 				$last_update_day = $last_update[0]['value'];
2587
-			} else $last_update_day = '2012-12-12 12:12:12';
2934
+			} else {
2935
+				$last_update_day = '2012-12-12 12:12:12';
2936
+			}
2588 2937
 			$reset = false;
2589 2938
 			$Tracker = new Tracker($this->db);
2590 2939
 			if ($Connection->tableExists('countries')) {
2591
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2940
+				if ($globalDebug) {
2941
+					echo 'Count all trackers by countries...'."\n";
2942
+				}
2592 2943
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2593 2944
 				foreach ($alldata as $number) {
2594 2945
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2595 2946
 				}
2596 2947
 			}
2597
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2948
+			if ($globalDebug) {
2949
+				echo 'Count all vessels by months...'."\n";
2950
+			}
2598 2951
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2599 2952
 			$filter_last_month = array('since_date' => $last_month);
2600 2953
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2601 2954
 			$lastyear = false;
2602 2955
 			foreach ($alldata as $number) {
2603
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2956
+				if ($number['year_name'] != date('Y')) {
2957
+					$lastyear = true;
2958
+				}
2604 2959
 				$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'])));
2605 2960
 			}
2606 2961
 			echo 'Tracker data...'."\n";
@@ -2630,7 +2985,9 @@  discard block
 block discarded – undo
2630 2985
 			foreach ($alldata as $number) {
2631 2986
 				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2632 2987
 			}
2633
-			if ($globalDebug) echo 'Count all types...'."\n";
2988
+			if ($globalDebug) {
2989
+				echo 'Count all types...'."\n";
2990
+			}
2634 2991
 			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2635 2992
 			foreach ($alldata as $number) {
2636 2993
 				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
@@ -2642,10 +2999,14 @@  discard block
 block discarded – undo
2642 2999
 
2643 3000
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2644 3001
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2645
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
3002
+			if ($globalDebug) {
3003
+				echo '!!! Update aicraft stats !!!'."\n";
3004
+			}
2646 3005
 			if (isset($last_update[0]['value'])) {
2647 3006
 				$last_update_day = $last_update[0]['value'];
2648
-			} else $last_update_day = '2012-12-12 12:12:12';
3007
+			} else {
3008
+				$last_update_day = '2012-12-12 12:12:12';
3009
+			}
2649 3010
 			$reset = false;
2650 3011
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2651 3012
 			if ($globalStatsResetYear) {
@@ -2654,43 +3015,63 @@  discard block
 block discarded – undo
2654 3015
 			}
2655 3016
 			$Spotter = new Spotter($this->db);
2656 3017
 
2657
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
3018
+			if ($globalDebug) {
3019
+				echo 'Count all aircraft types...'."\n";
3020
+			}
2658 3021
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2659 3022
 			foreach ($alldata as $number) {
2660 3023
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2661 3024
 			}
2662
-			if ($globalDebug) echo 'Count all airlines...'."\n";
3025
+			if ($globalDebug) {
3026
+				echo 'Count all airlines...'."\n";
3027
+			}
2663 3028
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2664 3029
 			foreach ($alldata as $number) {
2665 3030
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2666 3031
 			}
2667
-			if ($globalDebug) echo 'Count all registrations...'."\n";
3032
+			if ($globalDebug) {
3033
+				echo 'Count all registrations...'."\n";
3034
+			}
2668 3035
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2669 3036
 			foreach ($alldata as $number) {
2670 3037
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2671 3038
 			}
2672
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
3039
+			if ($globalDebug) {
3040
+				echo 'Count all callsigns...'."\n";
3041
+			}
2673 3042
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2674 3043
 			foreach ($alldata as $number) {
2675 3044
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2676 3045
 			}
2677
-			if ($globalDebug) echo 'Count all owners...'."\n";
3046
+			if ($globalDebug) {
3047
+				echo 'Count all owners...'."\n";
3048
+			}
2678 3049
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2679 3050
 			foreach ($alldata as $number) {
2680 3051
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2681 3052
 			}
2682
-			if ($globalDebug) echo 'Count all pilots...'."\n";
3053
+			if ($globalDebug) {
3054
+				echo 'Count all pilots...'."\n";
3055
+			}
2683 3056
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2684 3057
 			foreach ($alldata as $number) {
2685
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
3058
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
3059
+					$number['pilot_id'] = $number['pilot_name'];
3060
+				}
2686 3061
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2687 3062
 			}
2688 3063
 			
2689
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
3064
+			if ($globalDebug) {
3065
+				echo 'Count all departure airports...'."\n";
3066
+			}
2690 3067
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2691
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
3068
+			if ($globalDebug) {
3069
+				echo 'Count all detected departure airports...'."\n";
3070
+			}
2692 3071
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2693
-			if ($globalDebug) echo 'Order departure airports...'."\n";
3072
+			if ($globalDebug) {
3073
+				echo 'Order departure airports...'."\n";
3074
+			}
2694 3075
 			$alldata = array();
2695 3076
 			foreach ($pall as $value) {
2696 3077
 				$icao = $value['airport_departure_icao'];
@@ -2700,7 +3081,9 @@  discard block
 block discarded – undo
2700 3081
 				$icao = $value['airport_departure_icao'];
2701 3082
 				if (isset($alldata[$icao])) {
2702 3083
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2703
-				} else $alldata[$icao] = $value;
3084
+				} else {
3085
+					$alldata[$icao] = $value;
3086
+				}
2704 3087
 			}
2705 3088
 			$count = array();
2706 3089
 			foreach ($alldata as $key => $row) {
@@ -2710,11 +3093,17 @@  discard block
 block discarded – undo
2710 3093
 			foreach ($alldata as $number) {
2711 3094
 				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);
2712 3095
 			}
2713
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
3096
+			if ($globalDebug) {
3097
+				echo 'Count all arrival airports...'."\n";
3098
+			}
2714 3099
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2715
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
3100
+			if ($globalDebug) {
3101
+				echo 'Count all detected arrival airports...'."\n";
3102
+			}
2716 3103
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2717
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
3104
+			if ($globalDebug) {
3105
+				echo 'Order arrival airports...'."\n";
3106
+			}
2718 3107
 			$alldata = array();
2719 3108
 			foreach ($pall as $value) {
2720 3109
 				$icao = $value['airport_arrival_icao'];
@@ -2724,7 +3113,9 @@  discard block
 block discarded – undo
2724 3113
 				$icao = $value['airport_arrival_icao'];
2725 3114
 				if (isset($alldata[$icao])) {
2726 3115
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2727
-				} else $alldata[$icao] = $value;
3116
+				} else {
3117
+					$alldata[$icao] = $value;
3118
+				}
2728 3119
 			}
2729 3120
 			$count = array();
2730 3121
 			foreach ($alldata as $key => $row) {
@@ -2735,7 +3126,9 @@  discard block
 block discarded – undo
2735 3126
 				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);
2736 3127
 			}
2737 3128
 			if ($Connection->tableExists('countries')) {
2738
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
3129
+				if ($globalDebug) {
3130
+					echo 'Count all flights by countries...'."\n";
3131
+				}
2739 3132
 				//$SpotterArchive = new SpotterArchive();
2740 3133
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 3134
 				$Spotter = new Spotter($this->db);
@@ -2746,7 +3139,9 @@  discard block
 block discarded – undo
2746 3139
 			}
2747 3140
 			
2748 3141
 			if (isset($globalAccidents) && $globalAccidents) {
2749
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
3142
+				if ($globalDebug) {
3143
+					echo 'Count fatalities stats...'."\n";
3144
+				}
2750 3145
 				$Accident = new Accident($this->db);
2751 3146
 				$this->deleteStatsByType('fatalities_byyear');
2752 3147
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2762,48 +3157,68 @@  discard block
 block discarded – undo
2762 3157
 
2763 3158
 			// Add by month using getstat if month finish...
2764 3159
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2765
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
3160
+			if ($globalDebug) {
3161
+				echo 'Count all flights by months...'."\n";
3162
+			}
2766 3163
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2767 3164
 			$filter_last_month = array('since_date' => $last_month);
2768 3165
 			$Spotter = new Spotter($this->db);
2769 3166
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2770 3167
 			$lastyear = false;
2771 3168
 			foreach ($alldata as $number) {
2772
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3169
+				if ($number['year_name'] != date('Y')) {
3170
+					$lastyear = true;
3171
+				}
2773 3172
 				$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'])));
2774 3173
 			}
2775
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
3174
+			if ($globalDebug) {
3175
+				echo 'Count all military flights by months...'."\n";
3176
+			}
2776 3177
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 3178
 			foreach ($alldata as $number) {
2778 3179
 				$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'])));
2779 3180
 			}
2780
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
3181
+			if ($globalDebug) {
3182
+				echo 'Count all owners by months...'."\n";
3183
+			}
2781 3184
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 3185
 			foreach ($alldata as $number) {
2783 3186
 				$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'])));
2784 3187
 			}
2785
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
3188
+			if ($globalDebug) {
3189
+				echo 'Count all pilots by months...'."\n";
3190
+			}
2786 3191
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 3192
 			foreach ($alldata as $number) {
2788 3193
 				$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'])));
2789 3194
 			}
2790
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
3195
+			if ($globalDebug) {
3196
+				echo 'Count all airlines by months...'."\n";
3197
+			}
2791 3198
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 3199
 			foreach ($alldata as $number) {
2793 3200
 				$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'])));
2794 3201
 			}
2795
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3202
+			if ($globalDebug) {
3203
+				echo 'Count all aircrafts by months...'."\n";
3204
+			}
2796 3205
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 3206
 			foreach ($alldata as $number) {
2798 3207
 				$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'])));
2799 3208
 			}
2800
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3209
+			if ($globalDebug) {
3210
+				echo 'Count all real arrivals by months...'."\n";
3211
+			}
2801 3212
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 3213
 			foreach ($alldata as $number) {
2803 3214
 				$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'])));
2804 3215
 			}
2805
-			if ($globalDebug) echo 'Airports data...'."\n";
2806
-			if ($globalDebug) echo '...Departure'."\n";
3216
+			if ($globalDebug) {
3217
+				echo 'Airports data...'."\n";
3218
+			}
3219
+			if ($globalDebug) {
3220
+				echo '...Departure'."\n";
3221
+			}
2807 3222
 			$this->deleteStatAirport('daily');
2808 3223
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2809 3224
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2921,7 +3336,9 @@  discard block
 block discarded – undo
2921 3336
 			// Count by airlines
2922 3337
 			echo '--- Stats by airlines ---'."\n";
2923 3338
 			if ($Connection->tableExists('countries')) {
2924
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3339
+				if ($globalDebug) {
3340
+					echo 'Count all flights by countries by airlines...'."\n";
3341
+				}
2925 3342
 				$SpotterArchive = new SpotterArchive($this->db);
2926 3343
 				//$Spotter = new Spotter($this->db);
2927 3344
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2930,37 +3347,53 @@  discard block
 block discarded – undo
2930 3347
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2931 3348
 				}
2932 3349
 			}
2933
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3350
+			if ($globalDebug) {
3351
+				echo 'Count all aircraft types by airlines...'."\n";
3352
+			}
2934 3353
 			$Spotter = new Spotter($this->db);
2935 3354
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2936 3355
 			foreach ($alldata as $number) {
2937 3356
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2938 3357
 			}
2939
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3358
+			if ($globalDebug) {
3359
+				echo 'Count all aircraft registrations by airlines...'."\n";
3360
+			}
2940 3361
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2941 3362
 			foreach ($alldata as $number) {
2942 3363
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2943 3364
 			}
2944
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3365
+			if ($globalDebug) {
3366
+				echo 'Count all callsigns by airlines...'."\n";
3367
+			}
2945 3368
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2946 3369
 			foreach ($alldata as $number) {
2947 3370
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2948 3371
 			}
2949
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3372
+			if ($globalDebug) {
3373
+				echo 'Count all owners by airlines...'."\n";
3374
+			}
2950 3375
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2951 3376
 			foreach ($alldata as $number) {
2952 3377
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2953 3378
 			}
2954
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3379
+			if ($globalDebug) {
3380
+				echo 'Count all pilots by airlines...'."\n";
3381
+			}
2955 3382
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2956 3383
 			foreach ($alldata as $number) {
2957 3384
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2958 3385
 			}
2959
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3386
+			if ($globalDebug) {
3387
+				echo 'Count all departure airports by airlines...'."\n";
3388
+			}
2960 3389
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2961
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3390
+			if ($globalDebug) {
3391
+				echo 'Count all detected departure airports by airlines...'."\n";
3392
+			}
2962 3393
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2963
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3394
+			if ($globalDebug) {
3395
+				echo 'Order detected departure airports by airlines...'."\n";
3396
+			}
2964 3397
 			//$alldata = array();
2965 3398
 			foreach ($dall as $value) {
2966 3399
 				$icao = $value['airport_departure_icao'];
@@ -2981,11 +3414,17 @@  discard block
 block discarded – undo
2981 3414
 			foreach ($alldata as $number) {
2982 3415
 				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);
2983 3416
 			}
2984
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3417
+			if ($globalDebug) {
3418
+				echo 'Count all arrival airports by airlines...'."\n";
3419
+			}
2985 3420
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2986
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3421
+			if ($globalDebug) {
3422
+				echo 'Count all detected arrival airports by airlines...'."\n";
3423
+			}
2987 3424
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2988
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3425
+			if ($globalDebug) {
3426
+				echo 'Order arrival airports by airlines...'."\n";
3427
+			}
2989 3428
 			//$alldata = array();
2990 3429
 			foreach ($dall as $value) {
2991 3430
 				$icao = $value['airport_arrival_icao'];
@@ -3004,37 +3443,53 @@  discard block
 block discarded – undo
3004 3443
 			}
3005 3444
 			$alldata = $pall;
3006 3445
 			foreach ($alldata as $number) {
3007
-				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);
3446
+				if ($number['airline_icao'] != '') {
3447
+					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);
3448
+				}
3449
+			}
3450
+			if ($globalDebug) {
3451
+				echo 'Count all flights by months by airlines...'."\n";
3008 3452
 			}
3009
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3453
 			$Spotter = new Spotter($this->db);
3011 3454
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
3012 3455
 			$lastyear = false;
3013 3456
 			foreach ($alldata as $number) {
3014
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3457
+				if ($number['year_name'] != date('Y')) {
3458
+					$lastyear = true;
3459
+				}
3015 3460
 				$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']);
3016 3461
 			}
3017
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3462
+			if ($globalDebug) {
3463
+				echo 'Count all owners by months by airlines...'."\n";
3464
+			}
3018 3465
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3466
 			foreach ($alldata as $number) {
3020 3467
 				$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']);
3021 3468
 			}
3022
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3469
+			if ($globalDebug) {
3470
+				echo 'Count all pilots by months by airlines...'."\n";
3471
+			}
3023 3472
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3473
 			foreach ($alldata as $number) {
3025 3474
 				$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']);
3026 3475
 			}
3027
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3476
+			if ($globalDebug) {
3477
+				echo 'Count all aircrafts by months by airlines...'."\n";
3478
+			}
3028 3479
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3480
 			foreach ($alldata as $number) {
3030 3481
 				$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']);
3031 3482
 			}
3032
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3483
+			if ($globalDebug) {
3484
+				echo 'Count all real arrivals by months by airlines...'."\n";
3485
+			}
3033 3486
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3487
 			foreach ($alldata as $number) {
3035 3488
 				$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']);
3036 3489
 			}
3037
-			if ($globalDebug) echo '...Departure'."\n";
3490
+			if ($globalDebug) {
3491
+				echo '...Departure'."\n";
3492
+			}
3038 3493
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
3039 3494
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
3040 3495
 			foreach ($dall as $value) {
@@ -3057,7 +3512,9 @@  discard block
 block discarded – undo
3057 3512
 			foreach ($alldata as $number) {
3058 3513
 				$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']);
3059 3514
 			}
3060
-			if ($globalDebug) echo '...Arrival'."\n";
3515
+			if ($globalDebug) {
3516
+				echo '...Arrival'."\n";
3517
+			}
3061 3518
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
3062 3519
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
3063 3520
 			foreach ($dall as $value) {
@@ -3081,13 +3538,19 @@  discard block
 block discarded – undo
3081 3538
 				$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']);
3082 3539
 			}
3083 3540
 
3084
-			if ($globalDebug) echo 'Flights data...'."\n";
3085
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3541
+			if ($globalDebug) {
3542
+				echo 'Flights data...'."\n";
3543
+			}
3544
+			if ($globalDebug) {
3545
+				echo '-> countAllDatesLastMonth...'."\n";
3546
+			}
3086 3547
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3548
 			foreach ($alldata as $number) {
3088 3549
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3089 3550
 			}
3090
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3551
+			if ($globalDebug) {
3552
+				echo '-> countAllDates...'."\n";
3553
+			}
3091 3554
 			//$previousdata = $this->countAllDatesByAirlines();
3092 3555
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3093 3556
 			$values = array();
@@ -3100,14 +3563,18 @@  discard block
 block discarded – undo
3100 3563
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3101 3564
 			}
3102 3565
 			
3103
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3566
+			if ($globalDebug) {
3567
+				echo '-> countAllHours...'."\n";
3568
+			}
3104 3569
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3105 3570
 			foreach ($alldata as $number) {
3106 3571
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3107 3572
 			}
3108 3573
 
3109 3574
 			// Stats by filters
3110
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3575
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3576
+				$globalStatsFilters = array();
3577
+			}
3111 3578
 			foreach ($globalStatsFilters as $name => $filter) {
3112 3579
 				if (!empty($filter)) {
3113 3580
 					//$filter_name = $filter['name'];
@@ -3115,7 +3582,9 @@  discard block
 block discarded – undo
3115 3582
 					$reset = false;
3116 3583
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
3117 3584
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
3118
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3585
+						if ($globalDebug) {
3586
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3587
+						}
3119 3588
 						$this->deleteOldStats($filter_name);
3120 3589
 						unset($last_update);
3121 3590
 					}
@@ -3132,39 +3601,55 @@  discard block
 block discarded – undo
3132 3601
 						$reset = true;
3133 3602
 					}
3134 3603
 					// Count by filter
3135
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3604
+					if ($globalDebug) {
3605
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3606
+					}
3136 3607
 					$Spotter = new Spotter($this->db);
3137
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3608
+					if ($globalDebug) {
3609
+						echo 'Count all aircraft types...'."\n";
3610
+					}
3138 3611
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3139 3612
 					foreach ($alldata as $number) {
3140 3613
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3141 3614
 					}
3142
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3615
+					if ($globalDebug) {
3616
+						echo 'Count all airlines...'."\n";
3617
+					}
3143 3618
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3144 3619
 					foreach ($alldata as $number) {
3145 3620
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3146 3621
 					}
3147
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3622
+					if ($globalDebug) {
3623
+						echo 'Count all aircraft registrations...'."\n";
3624
+					}
3148 3625
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3149 3626
 					foreach ($alldata as $number) {
3150 3627
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3151 3628
 					}
3152
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3629
+					if ($globalDebug) {
3630
+						echo 'Count all callsigns...'."\n";
3631
+					}
3153 3632
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3154 3633
 					foreach ($alldata as $number) {
3155 3634
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3156 3635
 					}
3157
-					if ($globalDebug) echo 'Count all owners...'."\n";
3636
+					if ($globalDebug) {
3637
+						echo 'Count all owners...'."\n";
3638
+					}
3158 3639
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3159 3640
 					foreach ($alldata as $number) {
3160 3641
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3161 3642
 					}
3162
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3643
+					if ($globalDebug) {
3644
+						echo 'Count all pilots...'."\n";
3645
+					}
3163 3646
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3164 3647
 					foreach ($alldata as $number) {
3165 3648
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3166 3649
 					}
3167
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3650
+					if ($globalDebug) {
3651
+						echo 'Count departure airports...'."\n";
3652
+					}
3168 3653
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169 3654
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3170 3655
 					$alldata = array();
@@ -3176,7 +3661,9 @@  discard block
 block discarded – undo
3176 3661
 						$icao = $value['airport_departure_icao'];
3177 3662
 						if (isset($alldata[$icao])) {
3178 3663
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
3179
-						} else $alldata[$icao] = $value;
3664
+						} else {
3665
+							$alldata[$icao] = $value;
3666
+						}
3180 3667
 					}
3181 3668
 					$count = array();
3182 3669
 					foreach ($alldata as $key => $row) {
@@ -3186,7 +3673,9 @@  discard block
 block discarded – undo
3186 3673
 					foreach ($alldata as $number) {
3187 3674
 						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);
3188 3675
 					}
3189
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3676
+					if ($globalDebug) {
3677
+						echo 'Count all arrival airports...'."\n";
3678
+					}
3190 3679
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191 3680
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3192 3681
 					$alldata = array();
@@ -3198,7 +3687,9 @@  discard block
 block discarded – undo
3198 3687
 						$icao = $value['airport_arrival_icao'];
3199 3688
 						if (isset($alldata[$icao])) {
3200 3689
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
3201
-						} else $alldata[$icao] = $value;
3690
+						} else {
3691
+							$alldata[$icao] = $value;
3692
+						}
3202 3693
 					}
3203 3694
 					$count = array();
3204 3695
 					foreach ($alldata as $key => $row) {
@@ -3208,35 +3699,49 @@  discard block
 block discarded – undo
3208 3699
 					foreach ($alldata as $number) {
3209 3700
 						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);
3210 3701
 					}
3211
-					if ($globalDebug) echo 'Count all months...'."\n";
3702
+					if ($globalDebug) {
3703
+						echo 'Count all months...'."\n";
3704
+					}
3212 3705
 					$Spotter = new Spotter($this->db);
3213 3706
 					$alldata = $Spotter->countAllMonths($filter);
3214 3707
 					$lastyear = false;
3215 3708
 					foreach ($alldata as $number) {
3216
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3709
+						if ($number['year_name'] != date('Y')) {
3710
+							$lastyear = true;
3711
+						}
3217 3712
 						$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);
3218 3713
 					}
3219
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3714
+					if ($globalDebug) {
3715
+						echo 'Count all owners by months...'."\n";
3716
+					}
3220 3717
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3718
 					foreach ($alldata as $number) {
3222 3719
 						$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);
3223 3720
 					}
3224
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3721
+					if ($globalDebug) {
3722
+						echo 'Count all pilots by months...'."\n";
3723
+					}
3225 3724
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3725
 					foreach ($alldata as $number) {
3227 3726
 						$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);
3228 3727
 					}
3229
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3728
+					if ($globalDebug) {
3729
+						echo 'Count all military by months...'."\n";
3730
+					}
3230 3731
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3732
 					foreach ($alldata as $number) {
3232 3733
 						$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);
3233 3734
 					}
3234
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3735
+					if ($globalDebug) {
3736
+						echo 'Count all aircrafts by months...'."\n";
3737
+					}
3235 3738
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3739
 				    	foreach ($alldata as $number) {
3237 3740
 			    			$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);
3238 3741
 					}
3239
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3742
+					if ($globalDebug) {
3743
+						echo 'Count all real arrivals by months...'."\n";
3744
+					}
3240 3745
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3746
 					foreach ($alldata as $number) {
3242 3747
 						$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.
require/class.SBS.php 1 patch
Braces   +248 added lines, -87 removed lines patch added patch discarded remove patch
@@ -19,9 +19,13 @@  discard block
 block discarded – undo
19 19
 		// Not yet finished, no CRC checks
20 20
 		$data = array();
21 21
 		$typehex = substr($buffer,0,1);
22
-		if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
23
-		elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
24
-		else $hex = substr($buffer,1,-1);
22
+		if ($typehex == '*' || $typehex == ':') {
23
+			$hex = substr($buffer,1,-1);
24
+		} elseif ($typehex == '@' || $typehex == '%') {
25
+			$hex = substr($buffer,13,-13);
26
+		} else {
27
+			$hex = substr($buffer,1,-1);
28
+		}
25 29
 		$bin = gmp_strval( gmp_init($hex,16), 2);
26 30
 		//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
27 31
 		if (strlen($hex) == 28) {
@@ -64,8 +68,9 @@  discard block
 block discarded – undo
64 68
 					//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
65 69
 					$cprlat = intval(substr($bin,54,17),2)/131072.0;
66 70
 					$cprlon = intval(substr($bin,71,17),2)/131072.0;
67
-					if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
68
-					elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
71
+					if ($oe == 0) {
72
+						$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
73
+					} elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
69 74
 						$cprlat_odd = $cprlat;
70 75
 						$cprlon_odd = $cprlon;
71 76
 						$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -73,8 +78,12 @@  discard block
 block discarded – undo
73 78
 						$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
74 79
 						$lat_even = (360.0/60)*($j%60+$cprlat_even);
75 80
 						$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
76
-						if ($lat_even >= 270) $lat_even = $lat_even - 360;
77
-						if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
81
+						if ($lat_even >= 270) {
82
+							$lat_even = $lat_even - 360;
83
+						}
84
+						if ($lat_odd >= 270) {
85
+							$lat_odd = $lat_odd - 360;
86
+						}
78 87
 						// check latitude zone
79 88
 						if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
80 89
 							if ($this::$latlon[$icao]['created'] > time()) {
@@ -82,7 +91,9 @@  discard block
 block discarded – undo
82 91
 								$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
83 92
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
84 93
 								$lat = $lat_even;
85
-								if ($lon > 180) $lon = $lon -360;
94
+								if ($lon > 180) {
95
+									$lon = $lon -360;
96
+								}
86 97
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 98
 									//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
88 99
 									$data['latitude'] = $lat;
@@ -93,14 +104,18 @@  discard block
 block discarded – undo
93 104
 								$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
94 105
 								$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
95 106
 								$lat = $lat_odd;
96
-								if ($lon > 180) $lon = $lon -360;
107
+								if ($lon > 180) {
108
+									$lon = $lon -360;
109
+								}
97 110
 								if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
98 111
 									//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
99 112
 									$data['latitude'] = $lat;
100 113
 									$data['longitude'] = $lon;
101 114
 								}
102 115
 							}
103
-						} else echo "Not cprNL";
116
+						} else {
117
+							echo "Not cprNL";
118
+						}
104 119
 						unset($this::$latlon[$icao]);
105 120
 					}
106 121
 				} elseif ($tc == 19) {
@@ -109,11 +124,17 @@  discard block
 block discarded – undo
109 124
 					$v_ew = intval(substr($bin,46,10),2);
110 125
 					$v_ns_dir = intval(substr($bin,56,1));
111 126
 					$v_ns = intval(substr($bin,57,10),2);
112
-					if ($v_ew_dir) $v_ew = -1*$v_ew;
113
-					if ($v_ns_dir) $v_ns = -1*$v_ns;
127
+					if ($v_ew_dir) {
128
+						$v_ew = -1*$v_ew;
129
+					}
130
+					if ($v_ns_dir) {
131
+						$v_ns = -1*$v_ns;
132
+					}
114 133
 					$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
115 134
 					$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
116
-					if ($heading <0) $heading = $heading+360;
135
+					if ($heading <0) {
136
+						$heading = $heading+360;
137
+					}
117 138
 					$data['speed'] = $speed;
118 139
 					$data['heading'] = $heading;
119 140
 				}
@@ -128,72 +149,194 @@  discard block
 block discarded – undo
128 149
 	 * Lookup table to convert the latitude to index.
129 150
 	*/
130 151
 	private function cprNL($lat) {
131
-		if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
132
-		if ($lat < 10.47047130) return 59;
133
-		if ($lat < 14.82817437) return 58;
134
-		if ($lat < 18.18626357) return 57;
135
-		if ($lat < 21.02939493) return 56;
136
-		if ($lat < 23.54504487) return 55;
137
-		if ($lat < 25.82924707) return 54;
138
-		if ($lat < 27.93898710) return 53;
139
-		if ($lat < 29.91135686) return 52;
140
-		if ($lat < 31.77209708) return 51;
141
-		if ($lat < 33.53993436) return 50;
142
-		if ($lat < 35.22899598) return 49;
143
-		if ($lat < 36.85025108) return 48;
144
-		if ($lat < 38.41241892) return 47;
145
-		if ($lat < 39.92256684) return 46;
146
-		if ($lat < 41.38651832) return 45;
147
-		if ($lat < 42.80914012) return 44;
148
-		if ($lat < 44.19454951) return 43;
149
-		if ($lat < 45.54626723) return 42;
150
-		if ($lat < 46.86733252) return 41;
151
-		if ($lat < 48.16039128) return 40;
152
-		if ($lat < 49.42776439) return 39;
153
-		if ($lat < 50.67150166) return 38;
154
-		if ($lat < 51.89342469) return 37;
155
-		if ($lat < 53.09516153) return 36;
156
-		if ($lat < 54.27817472) return 35;
157
-		if ($lat < 55.44378444) return 34;
158
-		if ($lat < 56.59318756) return 33;
159
-		if ($lat < 57.72747354) return 32;
160
-		if ($lat < 58.84763776) return 31;
161
-		if ($lat < 59.95459277) return 30;
162
-		if ($lat < 61.04917774) return 29;
163
-		if ($lat < 62.13216659) return 28;
164
-		if ($lat < 63.20427479) return 27;
165
-		if ($lat < 64.26616523) return 26;
166
-		if ($lat < 65.31845310) return 25;
167
-		if ($lat < 66.36171008) return 24;
168
-		if ($lat < 67.39646774) return 23;
169
-		if ($lat < 68.42322022) return 22;
170
-		if ($lat < 69.44242631) return 21;
171
-		if ($lat < 70.45451075) return 20;
172
-		if ($lat < 71.45986473) return 19;
173
-		if ($lat < 72.45884545) return 18;
174
-		if ($lat < 73.45177442) return 17;
175
-		if ($lat < 74.43893416) return 16;
176
-		if ($lat < 75.42056257) return 15;
177
-		if ($lat < 76.39684391) return 14;
178
-		if ($lat < 77.36789461) return 13;
179
-		if ($lat < 78.33374083) return 12;
180
-		if ($lat < 79.29428225) return 11;
181
-		if ($lat < 80.24923213) return 10;
182
-		if ($lat < 81.19801349) return 9;
183
-		if ($lat < 82.13956981) return 8;
184
-		if ($lat < 83.07199445) return 7;
185
-		if ($lat < 83.99173563) return 6;
186
-		if ($lat < 84.89166191) return 5;
187
-		if ($lat < 85.75541621) return 4;
188
-		if ($lat < 86.53536998) return 3;
189
-		if ($lat < 87.00000000) return 2;
152
+		if ($lat < 0) {
153
+			$lat = -$lat;
154
+		}
155
+		// Table is simmetric about the equator.
156
+		if ($lat < 10.47047130) {
157
+			return 59;
158
+		}
159
+		if ($lat < 14.82817437) {
160
+			return 58;
161
+		}
162
+		if ($lat < 18.18626357) {
163
+			return 57;
164
+		}
165
+		if ($lat < 21.02939493) {
166
+			return 56;
167
+		}
168
+		if ($lat < 23.54504487) {
169
+			return 55;
170
+		}
171
+		if ($lat < 25.82924707) {
172
+			return 54;
173
+		}
174
+		if ($lat < 27.93898710) {
175
+			return 53;
176
+		}
177
+		if ($lat < 29.91135686) {
178
+			return 52;
179
+		}
180
+		if ($lat < 31.77209708) {
181
+			return 51;
182
+		}
183
+		if ($lat < 33.53993436) {
184
+			return 50;
185
+		}
186
+		if ($lat < 35.22899598) {
187
+			return 49;
188
+		}
189
+		if ($lat < 36.85025108) {
190
+			return 48;
191
+		}
192
+		if ($lat < 38.41241892) {
193
+			return 47;
194
+		}
195
+		if ($lat < 39.92256684) {
196
+			return 46;
197
+		}
198
+		if ($lat < 41.38651832) {
199
+			return 45;
200
+		}
201
+		if ($lat < 42.80914012) {
202
+			return 44;
203
+		}
204
+		if ($lat < 44.19454951) {
205
+			return 43;
206
+		}
207
+		if ($lat < 45.54626723) {
208
+			return 42;
209
+		}
210
+		if ($lat < 46.86733252) {
211
+			return 41;
212
+		}
213
+		if ($lat < 48.16039128) {
214
+			return 40;
215
+		}
216
+		if ($lat < 49.42776439) {
217
+			return 39;
218
+		}
219
+		if ($lat < 50.67150166) {
220
+			return 38;
221
+		}
222
+		if ($lat < 51.89342469) {
223
+			return 37;
224
+		}
225
+		if ($lat < 53.09516153) {
226
+			return 36;
227
+		}
228
+		if ($lat < 54.27817472) {
229
+			return 35;
230
+		}
231
+		if ($lat < 55.44378444) {
232
+			return 34;
233
+		}
234
+		if ($lat < 56.59318756) {
235
+			return 33;
236
+		}
237
+		if ($lat < 57.72747354) {
238
+			return 32;
239
+		}
240
+		if ($lat < 58.84763776) {
241
+			return 31;
242
+		}
243
+		if ($lat < 59.95459277) {
244
+			return 30;
245
+		}
246
+		if ($lat < 61.04917774) {
247
+			return 29;
248
+		}
249
+		if ($lat < 62.13216659) {
250
+			return 28;
251
+		}
252
+		if ($lat < 63.20427479) {
253
+			return 27;
254
+		}
255
+		if ($lat < 64.26616523) {
256
+			return 26;
257
+		}
258
+		if ($lat < 65.31845310) {
259
+			return 25;
260
+		}
261
+		if ($lat < 66.36171008) {
262
+			return 24;
263
+		}
264
+		if ($lat < 67.39646774) {
265
+			return 23;
266
+		}
267
+		if ($lat < 68.42322022) {
268
+			return 22;
269
+		}
270
+		if ($lat < 69.44242631) {
271
+			return 21;
272
+		}
273
+		if ($lat < 70.45451075) {
274
+			return 20;
275
+		}
276
+		if ($lat < 71.45986473) {
277
+			return 19;
278
+		}
279
+		if ($lat < 72.45884545) {
280
+			return 18;
281
+		}
282
+		if ($lat < 73.45177442) {
283
+			return 17;
284
+		}
285
+		if ($lat < 74.43893416) {
286
+			return 16;
287
+		}
288
+		if ($lat < 75.42056257) {
289
+			return 15;
290
+		}
291
+		if ($lat < 76.39684391) {
292
+			return 14;
293
+		}
294
+		if ($lat < 77.36789461) {
295
+			return 13;
296
+		}
297
+		if ($lat < 78.33374083) {
298
+			return 12;
299
+		}
300
+		if ($lat < 79.29428225) {
301
+			return 11;
302
+		}
303
+		if ($lat < 80.24923213) {
304
+			return 10;
305
+		}
306
+		if ($lat < 81.19801349) {
307
+			return 9;
308
+		}
309
+		if ($lat < 82.13956981) {
310
+			return 8;
311
+		}
312
+		if ($lat < 83.07199445) {
313
+			return 7;
314
+		}
315
+		if ($lat < 83.99173563) {
316
+			return 6;
317
+		}
318
+		if ($lat < 84.89166191) {
319
+			return 5;
320
+		}
321
+		if ($lat < 85.75541621) {
322
+			return 4;
323
+		}
324
+		if ($lat < 86.53536998) {
325
+			return 3;
326
+		}
327
+		if ($lat < 87.00000000) {
328
+			return 2;
329
+		}
190 330
 		return 1;
191 331
 	}
192 332
 
193 333
 	private function cprN($lat,$isodd) {
194 334
 		$nl = $this->cprNL($lat) - $isodd;
195
-		if ($nl > 1) return $nl;
196
-		else return 1;
335
+		if ($nl > 1) {
336
+			return $nl;
337
+		} else {
338
+			return 1;
339
+		}
197 340
 	}
198 341
 
199 342
 	private function parityCheck($msg, $bin) {
@@ -216,10 +359,13 @@  discard block
 block discarded – undo
216 359
 		$crc = 0;
217 360
 		$checksum = intval(substr($msg,22,6),16);
218 361
 		for ($j = 0; $j < strlen($bin); $j++) {
219
-			if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
362
+			if ($bin[$j]) {
363
+				$crc = $crc^intval($modes_checksum_table[$j],0);
364
+			}
220 365
 		}
221
-		if ($crc == $checksum) return true;
222
-		else {
366
+		if ($crc == $checksum) {
367
+			return true;
368
+		} else {
223 369
 			//echo "**** CRC ERROR ****\n";
224 370
 			return false;
225 371
 		}
@@ -269,22 +415,37 @@  discard block
 block discarded – undo
269 415
 			$msg['date_log'] = date('Y/m/d',$data['timestamp']);
270 416
 			$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
271 417
 			$msg['callsign'] = '';
272
-			if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
273
-			else $msg['altitude'] = '';
418
+			if (isset($data['altitude'])) {
419
+				$msg['altitude'] = $data['altitude'];
420
+			} else {
421
+				$msg['altitude'] = '';
422
+			}
274 423
 			$msg['speed'] = $data['speed'];
275
-			if (isset($data['heading'])) $msg['track'] = $data['heading'];
276
-			else $msg['track'] = '';
424
+			if (isset($data['heading'])) {
425
+				$msg['track'] = $data['heading'];
426
+			} else {
427
+				$msg['track'] = '';
428
+			}
277 429
 			$msg['latitude'] = $data['latitude'];
278 430
 			$msg['longitude'] = $data['longitude'];
279
-			if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
280
-			else $msg['verticalrate'] = '';
281
-			if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
282
-			else $msg['squawk'] = 0;
431
+			if (isset($data['verticalrate'])) {
432
+				$msg['verticalrate'] = $data['verticalrate'];
433
+			} else {
434
+				$msg['verticalrate'] = '';
435
+			}
436
+			if (isset($data['squawk'])) {
437
+				$msg['squawk'] = $data['squawk'];
438
+			} else {
439
+				$msg['squawk'] = 0;
440
+			}
283 441
 			$msg['alert'] = 0;
284 442
 			$msg['emergency'] = 0;
285 443
 			$msg['SPI'] = 0;
286
-			if (isset($data['ground'])) $msg['ground'] = 1;
287
-			else $msg['ground'] = 0;
444
+			if (isset($data['ground'])) {
445
+				$msg['ground'] = 1;
446
+			} else {
447
+				$msg['ground'] = 0;
448
+			}
288 449
 			$result[] = implode(',',$msg);
289 450
 		}
290 451
 		return $result;
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +101 added lines, -45 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 99
 		//global $cookies;
97 100
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
101
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
102
+					$cookies[] = $cookie;
103
+		}
100 104
 		return strlen($headerLine); // Needed by curl
101 105
 	}
102 106
 
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		curl_setopt($ch, CURLOPT_URL, $url);
108 112
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 113
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
114
+		if ($referer != '') {
115
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		}
111 117
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 118
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 119
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +125,9 @@  discard block
 block discarded – undo
119 125
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
120 126
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 127
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
128
+		if (curl_errno($ch) && $globalDebug) {
129
+			echo 'Download error: '.curl_error($ch);
130
+		}
123 131
 		curl_close($ch);
124 132
 		fclose($fp);
125 133
 	}
@@ -127,12 +135,16 @@  discard block
 block discarded – undo
127 135
 	public static function gunzip($in_file,$out_file_name = '') {
128 136
 		//echo $in_file.' -> '.$out_file_name."\n";
129 137
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
138
+		if ($out_file_name == '') {
139
+			$out_file_name = str_replace('.gz', '', $in_file);
140
+		}
131 141
 		if ($in_file != '' && file_exists($in_file)) {
132 142
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
143
+			if (function_exists('gzopen')) {
144
+				$file = gzopen($in_file,'rb');
145
+			} elseif (function_exists('gzopen64')) {
146
+				$file = gzopen64($in_file,'rb');
147
+			} else {
136 148
 				echo 'gzopen not available';
137 149
 				die;
138 150
 			}
@@ -148,11 +160,14 @@  discard block
 block discarded – undo
148 160
 	public static function bunzip2($in_file,$out_file_name = '') {
149 161
 		//echo $in_file.' -> '.$out_file_name."\n";
150 162
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
163
+		if ($out_file_name == '') {
164
+			$out_file_name = str_replace('.bz2', '', $in_file);
165
+		}
152 166
 		if ($in_file != '' && file_exists($in_file)) {
153 167
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
168
+			if (function_exists('bzopen')) {
169
+				$file = bzopen($in_file,'rb');
170
+			} else {
156 171
 				echo 'bzopen not available';
157 172
 				die;
158 173
 			}
@@ -171,10 +186,16 @@  discard block
 block discarded – undo
171 186
 	* @return Array array of the tables in HTML page
172 187
 	*/
173 188
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
189
+		if (!is_string($data)) {
190
+			return array();
191
+		}
192
+		if ($data == '') {
193
+			return array();
194
+		}
176 195
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
196
+		if ($html === false) {
197
+			return array();
198
+		}
178 199
 		$tabledata=array();
179 200
 		foreach($html->find('tr') as $element)
180 201
 		{
@@ -209,7 +230,9 @@  discard block
 block discarded – undo
209 230
 	*/
210 231
 	public function text2array($data) {
211 232
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
233
+		if ($html === false) {
234
+			return array();
235
+		}
213 236
 		$tabledata=array();
214 237
 		foreach($html->find('p') as $element)
215 238
 		{
@@ -230,7 +253,9 @@  discard block
 block discarded – undo
230 253
 	* @return Float Distance in $unit
231 254
 	*/
232 255
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
256
+		if ($lat == $latc && $lon == $lonc) {
257
+			return 0;
258
+		}
234 259
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
235 260
 		if ($unit == "km") {
236 261
 			return round($dist * 1.609344);
@@ -269,7 +294,9 @@  discard block
 block discarded – undo
269 294
 		$dX = $latc - $lat;
270 295
 		$dY = $lonc - $lon;
271 296
 		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
297
+		if ($azimuth < 0) {
298
+			return $azimuth+360;
299
+		}
273 300
 		return $azimuth;
274 301
 	}
275 302
 	
@@ -283,10 +310,16 @@  discard block
 block discarded – undo
283 310
 	public function withinThreshold ($timeDifference, $distance) {
284 311
 		$x = abs($timeDifference);
285 312
 		$d = abs($distance);
286
-		if ($x == 0 || $d == 0) return true;
313
+		if ($x == 0 || $d == 0) {
314
+			return true;
315
+		}
287 316
 		// may be due to Internet jitter; distance is realistic
288
-		if ($x < 0.7 && $d < 2000) return true;
289
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
317
+		if ($x < 0.7 && $d < 2000) {
318
+			return true;
319
+		} else {
320
+			return $d/$x < 1500*0.27778;
321
+		}
322
+		// 1500 km/h max
290 323
 	}
291 324
 
292 325
 
@@ -314,11 +347,17 @@  discard block
 block discarded – undo
314 347
 	
315 348
 	public function convertDM($coord,$latlong) {
316 349
 		if ($latlong == 'latitude') {
317
-			if ($coord < 0) $NSEW = 'S';
318
-			else $NSEW = 'N';
350
+			if ($coord < 0) {
351
+				$NSEW = 'S';
352
+			} else {
353
+				$NSEW = 'N';
354
+			}
319 355
 		} else {
320
-			if ($coord < 0) $NSEW = 'W';
321
-			else $NSEW = 'E';
356
+			if ($coord < 0) {
357
+				$NSEW = 'W';
358
+			} else {
359
+				$NSEW = 'E';
360
+			}
322 361
 		}
323 362
 		$coord = abs($coord);
324 363
 		$deg = floor($coord);
@@ -361,7 +400,9 @@  discard block
 block discarded – undo
361 400
 	public function hex2str($hex) {
362 401
 		$str = '';
363 402
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
403
+		for($i=0;$i<$hexln;$i+=2) {
404
+			$str .= chr(hexdec(substr($hex,$i,2)));
405
+		}
365 406
 		return $str;
366 407
 	}
367 408
 	
@@ -398,8 +439,11 @@  discard block
 block discarded – undo
398 439
 		$b = $lat2 - $lat1;
399 440
 		$c = -($a*$lat1+$b*$lon1);
400 441
 		$d = $a*$lat3+$b*$lon3+$c;
401
-		if ($d > -$approx && $d < $approx) return true;
402
-		else return false;
442
+		if ($d > -$approx && $d < $approx) {
443
+			return true;
444
+		} else {
445
+			return false;
446
+		}
403 447
 	}
404 448
 	
405 449
 	public function array_merge_noappend() {
@@ -458,7 +502,9 @@  discard block
 block discarded – undo
458 502
 			return $result;
459 503
 		}
460 504
 		$handle = @opendir('./locale');
461
-		if ($handle === false) return $result;
505
+		if ($handle === false) {
506
+			return $result;
507
+		}
462 508
 		while (false !== ($file = readdir($handle))) {
463 509
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
464 510
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -529,8 +575,9 @@  discard block
 block discarded – undo
529 575
 		$error = false; 
530 576
 		if ($fp_out = gzopen($dest, $mode)) { 
531 577
 			if ($fp_in = fopen($source,'rb')) { 
532
-				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
578
+				while (!feof($fp_in)) {
579
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
580
+				}
534 581
 				fclose($fp_in); 
535 582
 			} else {
536 583
 				$error = true; 
@@ -539,14 +586,17 @@  discard block
 block discarded – undo
539 586
 		} else {
540 587
 			$error = true; 
541 588
 		}
542
-		if ($error)
543
-			return false; 
544
-		else
545
-			return $dest; 
589
+		if ($error) {
590
+					return false;
591
+		} else {
592
+					return $dest;
593
+		}
546 594
 	} 
547 595
 	
548 596
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
597
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
598
+			return $string;
599
+		}
550 600
 		$chars = array(
551 601
 		    // Decompositions for Latin-1 Supplement
552 602
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -670,7 +720,9 @@  discard block
 block discarded – undo
670 720
 		$ip = gethostbyname($host);
671 721
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
672 722
 		$r = @socket_connect($s, $ip, $port);
673
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
723
+		if (!socket_set_nonblock($s)) {
724
+			echo "Unable to set nonblock on socket\n";
725
+		}
674 726
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
675 727
 			return $s;
676 728
 		}
@@ -715,18 +767,22 @@  discard block
 block discarded – undo
715 767
 		//NOTE: use a trailing slash for folders!!!
716 768
 		//see http://bugs.php.net/bug.php?id=27609
717 769
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
770
+		if ($path{strlen($path)-1}=='/') {
771
+			// recursively return a temporary file path
719 772
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720
-		else if (is_dir($path))
721
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
773
+		} else if (is_dir($path)) {
774
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
775
+		}
722 776
 		// check tmp file for read/write capabilities
723 777
 		$rm = file_exists($path);
724 778
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
726
-			return false;
779
+		if ($f===false) {
780
+					return false;
781
+		}
727 782
 		fclose($f);
728
-		if (!$rm)
729
-			unlink($path);
783
+		if (!$rm) {
784
+					unlink($path);
785
+		}
730 786
 		return true;
731 787
 	}
732 788
 }
Please login to merge, or discard this patch.
airport-detailed.php 1 patch
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		$limit_start = 0;
16 16
 		$limit_end = 25;
17 17
 		$absolute_difference = 25;
18
-	}  else {
18
+	} else {
19 19
 		$limit_explode = explode(",", $_GET['limit']);
20 20
 		$limit_start = $limit_explode[0];
21 21
 		$limit_end = $limit_explode[1];
@@ -47,7 +47,9 @@  discard block
 block discarded – undo
47 47
 			$METAR = new METAR();
48 48
 			$metar_info = $METAR->getMETAR($airport_icao);
49 49
 			//print_r($metar_info);
50
-			if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']);
50
+			if (isset($metar_info[0]['metar'])) {
51
+				$metar_parse = $METAR->parse($metar_info[0]['metar']);
52
+			}
51 53
             		//print_r($metar_parse);
52 54
 		}
53 55
 		
@@ -61,7 +63,9 @@  discard block
 block discarded – undo
61 63
 		print '<option></option>';
62 64
 		$Stats = new Stats();
63 65
 		$airport_names = $Stats->getAllAirportNames();
64
-		if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
66
+		if (empty($airport_names)) {
67
+			$airport_names = $Spotter->getAllAirportNames();
68
+		}
65 69
 		ksort($airport_names);
66 70
 		foreach($airport_names as $airport_name)
67 71
 		{
@@ -95,7 +99,9 @@  discard block
 block discarded – undo
95 99
 			print '</div>';
96 100
 			print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
97 101
 			print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>';
98
-			if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>';
102
+			if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') {
103
+				print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>';
104
+			}
99 105
 			print '</div>';
100 106
 			
101 107
 			$Stats = new Stats();
@@ -103,7 +109,9 @@  discard block
 block discarded – undo
103 109
 			// Use spotter also
104 110
 			if (isset($globalTimezone)) {
105 111
 				date_default_timezone_set($globalTimezone);
106
-			} else date_default_timezone_set('UTC');
112
+			} else {
113
+				date_default_timezone_set('UTC');
114
+			}
107 115
 			if (count($all_data) > 0) {
108 116
 				print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
109 117
 				print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
getImages.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,8 +105,11 @@
 block discarded – undo
105 105
     } elseif (isset($_GET['satellite'])) {
106 106
         readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107 107
     } else {
108
-        if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
109
-	else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
108
+        if ($color == 'FF0000') {
109
+        	readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
110
+        } else {
111
+		readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
112
+	}
110 113
     }
111 114
 }
112 115
 ?>
113 116
\ No newline at end of file
Please login to merge, or discard this patch.
install/install-action.php 1 patch
Braces   +78 added lines, -28 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
 	if ($error != '') {
76 76
 		$_SESSION['error'] = $error;
77 77
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database'));
78
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
78
+	} else {
79
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
80
+	}
79 81
 	$_SESSION['install'] = 'database_import';
80 82
 	$_SESSION['next'] = 'Create and import tables';
81 83
 	$result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -93,7 +95,9 @@  discard block
 block discarded – undo
93 95
 		if ($error != '') {
94 96
 			$_SESSION['error'] = $error;
95 97
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
96
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
98
+		} else {
99
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
100
+		}
97 101
 		if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
98 102
 			$_SESSION['install'] = 'populate';
99 103
 			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		$error .= $check_version;
108 112
 		$_SESSION['error'] = $error;
109 113
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
110
-		if (!isset($_SESSION['next'])) $_SESSION['next'] = '';
114
+		if (!isset($_SESSION['next'])) {
115
+			$_SESSION['next'] = '';
116
+		}
111 117
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
112 118
 		print json_encode($result);
113 119
 	} else {
@@ -115,7 +121,9 @@  discard block
 block discarded – undo
115 121
 		if ($error != '') {
116 122
 			$_SESSION['error'] = $error;
117 123
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed'));
118
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
124
+		} else {
125
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
126
+		}
119 127
 		$_SESSION['install'] = 'sources';
120 128
 		$_SESSION['next'] = 'Insert data in source table';
121 129
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -128,8 +136,10 @@  discard block
 block discarded – undo
128 136
 	if ($error != '') {
129 137
 		$_SESSION['error'] = $error;
130 138
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database'));
131
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
132
-/*
139
+	} else {
140
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
141
+	}
142
+	/*
133 143
 	$_SESSION['install'] = 'airspace';
134 144
 	$_SESSION['next'] = 'Populate airspace table';
135 145
 	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -154,7 +164,9 @@  discard block
 block discarded – undo
154 164
 	if ($error != '') {
155 165
 		$_SESSION['error'] = $error;
156 166
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157
-	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
167
+	} else {
168
+		$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
169
+	}
158 170
 	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159 171
 	    $_SESSION['install'] = 'notam';
160 172
 	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
@@ -188,7 +200,9 @@  discard block
 block discarded – undo
188 200
 		if ($error != '') {
189 201
 			$_SESSION['error'] = $error;
190 202
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
191
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
203
+		} else {
204
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
205
+		}
192 206
 		$_SESSION['install'] = 'populate_flarm';
193 207
 		$_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM';
194 208
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -209,18 +223,26 @@  discard block
 block discarded – undo
209 223
 		if ($error != '') {
210 224
 			$_SESSION['error'] = $error;
211 225
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
212
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
226
+		} else {
227
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
228
+		}
213 229
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
214 230
 			$_SESSION['install'] = 'vatsim';
215
-			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
216
-			else $_SESSION['next'] = 'Insert VATSIM data';
231
+			if (file_exists('tmp/ivae_feb2013.zip')) {
232
+				$_SESSION['next'] = 'Insert IVAO data';
233
+			} else {
234
+				$_SESSION['next'] = 'Insert VATSIM data';
235
+			}
217 236
 		} elseif (isset($globalVATSIM) && $globalVATSIM) {
218 237
 			$_SESSION['install'] = 'vatsim';
219 238
 			$_SESSION['next'] = 'Insert VATSIM data';
220 239
 		} elseif (isset($globalIVAO) && $globalIVAO) {
221 240
 			$_SESSION['install'] = 'vatsim';
222
-			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
223
-			else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
241
+			if (file_exists('tmp/ivae_feb2013.zip')) {
242
+				$_SESSION['next'] = 'Insert IVAO data';
243
+			} else {
244
+				$_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
245
+			}
224 246
 		} elseif (isset($globalphpVMS) && $globalphpVMS) {
225 247
 			$_SESSION['install'] = 'vatsim';
226 248
 			$_SESSION['next'] = 'Insert phpVMS data';
@@ -245,7 +267,9 @@  discard block
 block discarded – undo
245 267
 		if ($error != '') {
246 268
 			$_SESSION['error'] = $error;
247 269
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data'));
248
-		} else 	$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
270
+		} else {
271
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
272
+		}
249 273
 		$_SESSION['install'] = 'translation';
250 274
 		$_SESSION['next'] = 'Populate translation table with externals data';
251 275
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -265,7 +289,9 @@  discard block
 block discarded – undo
265 289
 		if ($error != '') {
266 290
 			$_SESSION['error'] = $error;
267 291
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
268
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
292
+		} else {
293
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
294
+		}
269 295
 		if ($_SESSION['waypoints'] == 1) {
270 296
 			$_SESSION['install'] = 'waypoints';
271 297
 			$_SESSION['next'] = 'Populate waypoints table';
@@ -300,7 +326,9 @@  discard block
 block discarded – undo
300 326
 		if ($error != '') {
301 327
 			$_SESSION['error'] = $error;
302 328
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
303
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
329
+		} else {
330
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
331
+		}
304 332
 		$_SESSION['install'] = 'sources';
305 333
 		$_SESSION['next'] = 'Insert data in source table';
306 334
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
@@ -321,12 +349,16 @@  discard block
 block discarded – undo
321 349
 			if ($error != '') {
322 350
 				$_SESSION['error'] = $error;
323 351
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
324
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
352
+			} else {
353
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
354
+			}
325 355
 		} else {
326 356
 			if ($error != '') {
327 357
 				$_SESSION['error'] = $error;
328 358
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)'));
329
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
359
+			} else {
360
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
361
+			}
330 362
 		}
331 363
 		/*
332 364
 		if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
@@ -376,7 +408,9 @@  discard block
 block discarded – undo
376 408
 		$Source = new Source();
377 409
 		$Source->deleteAllLocation();
378 410
 		foreach ($sources as $src) {
379
-			if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
411
+			if (isset($src['latitude']) && $src['latitude'] != '') {
412
+				$Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
413
+			}
380 414
 		}
381 415
 		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table'));
382 416
 		unset($_SESSION['sources']);
@@ -387,15 +421,21 @@  discard block
 block discarded – undo
387 421
 	*/
388 422
 	if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
389 423
 		$_SESSION['install'] = 'vatsim';
390
-		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
391
-		else $_SESSION['next'] = 'Insert VATSIM data';
424
+		if (file_exists('tmp/ivae_feb2013.zip')) {
425
+			$_SESSION['next'] = 'Insert IVAO data';
426
+		} else {
427
+			$_SESSION['next'] = 'Insert VATSIM data';
428
+		}
392 429
 	} elseif (isset($globalVATSIM) && $globalVATSIM) {
393 430
 		$_SESSION['install'] = 'vatsim';
394 431
 		$_SESSION['next'] = 'Insert VATSIM data';
395 432
 	} elseif (isset($globalIVAO) && $globalIVAO) {
396 433
 		$_SESSION['install'] = 'vatsim';
397
-		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
398
-		else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
434
+		if (file_exists('tmp/ivae_feb2013.zip')) {
435
+			$_SESSION['next'] = 'Insert IVAO data';
436
+		} else {
437
+			$_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
438
+		}
399 439
 	} elseif (isset($globalphpVMS) && $globalphpVMS) {
400 440
 		$_SESSION['install'] = 'vatsim';
401 441
 		$_SESSION['next'] = 'Insert phpVMS data';
@@ -416,33 +456,43 @@  discard block
 block discarded – undo
416 456
 			if ($error != '') {
417 457
 				$_SESSION['error'] = $error;
418 458
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
419
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
459
+			} else {
460
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
461
+			}
420 462
 		} else {
421 463
 			$error .= update_db::update_vatsim();
422 464
 			if ($error != '') {
423 465
 				$_SESSION['error'] = $error;
424 466
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
425
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
467
+			} else {
468
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
469
+			}
426 470
 		}
427 471
 	} elseif (isset($globalVATSIM) && $globalVATSIM) {
428 472
 		$error .= update_db::update_vatsim();
429 473
 		if ($error != '') {
430 474
 			$_SESSION['error'] = $error;
431 475
 			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
432
-		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
476
+		} else {
477
+			$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
478
+		}
433 479
 	} elseif (isset($globalIVAO) && $globalIVAO) {
434 480
 		if (file_exists('tmp/ivae_feb2013.zip')) {
435 481
 			$error .= update_db::update_IVAO();
436 482
 			if ($error != '') {
437 483
 				$_SESSION['error'] = $error;
438 484
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
439
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
485
+			} else {
486
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
487
+			}
440 488
 		} else {
441 489
 			$error .= update_db::update_vatsim();
442 490
 			if ($error != '') {
443 491
 				$_SESSION['error'] = $error;
444 492
 				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)'));
445
-			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
493
+			} else {
494
+				$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
495
+			}
446 496
 		}
447 497
 	} elseif (isset($globalphpVMS) && $globalphpVMS) {
448 498
 		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data'));
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +490 added lines, -180 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2276,8 +2432,11 @@  discard block
 block discarded – undo
2276 2432
 			if ($Connection->tableExists('aircraft')) {
2277 2433
 				if (!$Connection->tableExists('config')) {
2278 2434
 					$version = '1';
2279
-					if ($update) return self::update_from_1();
2280
-					else return $version;
2435
+					if ($update) {
2436
+						return self::update_from_1();
2437
+					} else {
2438
+						return $version;
2439
+					}
2281 2440
 				} else {
2282 2441
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2283 2442
 					try {
@@ -2290,203 +2449,354 @@  discard block
 block discarded – undo
2290 2449
 					if ($update) {
2291 2450
 						if ($result['value'] == '2') {
2292 2451
 							$error = self::update_from_2();
2293
-							if ($error != '') return $error;
2294
-							else return self::check_version(true);
2452
+							if ($error != '') {
2453
+								return $error;
2454
+							} else {
2455
+								return self::check_version(true);
2456
+							}
2295 2457
 						} elseif ($result['value'] == '3') {
2296 2458
 							$error = self::update_from_3();
2297
-							if ($error != '') return $error;
2298
-							else return self::check_version(true);
2459
+							if ($error != '') {
2460
+								return $error;
2461
+							} else {
2462
+								return self::check_version(true);
2463
+							}
2299 2464
 						} elseif ($result['value'] == '4') {
2300 2465
 							$error = self::update_from_4();
2301
-							if ($error != '') return $error;
2302
-							else return self::check_version(true);
2466
+							if ($error != '') {
2467
+								return $error;
2468
+							} else {
2469
+								return self::check_version(true);
2470
+							}
2303 2471
 						} elseif ($result['value'] == '5') {
2304 2472
 							$error = self::update_from_5();
2305
-							if ($error != '') return $error;
2306
-							else return self::check_version(true);
2473
+							if ($error != '') {
2474
+								return $error;
2475
+							} else {
2476
+								return self::check_version(true);
2477
+							}
2307 2478
 						} elseif ($result['value'] == '6') {
2308 2479
 							$error = self::update_from_6();
2309
-							if ($error != '') return $error;
2310
-							else return self::check_version(true);
2480
+							if ($error != '') {
2481
+								return $error;
2482
+							} else {
2483
+								return self::check_version(true);
2484
+							}
2311 2485
 						} elseif ($result['value'] == '7') {
2312 2486
 							$error = self::update_from_7();
2313
-							if ($error != '') return $error;
2314
-							else return self::check_version(true);
2487
+							if ($error != '') {
2488
+								return $error;
2489
+							} else {
2490
+								return self::check_version(true);
2491
+							}
2315 2492
 						} elseif ($result['value'] == '8') {
2316 2493
 							$error = self::update_from_8();
2317
-							if ($error != '') return $error;
2318
-							else return self::check_version(true);
2494
+							if ($error != '') {
2495
+								return $error;
2496
+							} else {
2497
+								return self::check_version(true);
2498
+							}
2319 2499
 						} elseif ($result['value'] == '9') {
2320 2500
 							$error = self::update_from_9();
2321
-							if ($error != '') return $error;
2322
-							else return self::check_version(true);
2501
+							if ($error != '') {
2502
+								return $error;
2503
+							} else {
2504
+								return self::check_version(true);
2505
+							}
2323 2506
 						} elseif ($result['value'] == '10') {
2324 2507
 							$error = self::update_from_10();
2325
-							if ($error != '') return $error;
2326
-							else return self::check_version(true);
2508
+							if ($error != '') {
2509
+								return $error;
2510
+							} else {
2511
+								return self::check_version(true);
2512
+							}
2327 2513
 						} elseif ($result['value'] == '11') {
2328 2514
 							$error = self::update_from_11();
2329
-							if ($error != '') return $error;
2330
-							else return self::check_version(true);
2515
+							if ($error != '') {
2516
+								return $error;
2517
+							} else {
2518
+								return self::check_version(true);
2519
+							}
2331 2520
 						} elseif ($result['value'] == '12') {
2332 2521
 							$error = self::update_from_12();
2333
-							if ($error != '') return $error;
2334
-							else return self::check_version(true);
2522
+							if ($error != '') {
2523
+								return $error;
2524
+							} else {
2525
+								return self::check_version(true);
2526
+							}
2335 2527
 						} elseif ($result['value'] == '13') {
2336 2528
 							$error = self::update_from_13();
2337
-							if ($error != '') return $error;
2338
-							else return self::check_version(true);
2529
+							if ($error != '') {
2530
+								return $error;
2531
+							} else {
2532
+								return self::check_version(true);
2533
+							}
2339 2534
 						} elseif ($result['value'] == '14') {
2340 2535
 							$error = self::update_from_14();
2341
-							if ($error != '') return $error;
2342
-							else return self::check_version(true);
2536
+							if ($error != '') {
2537
+								return $error;
2538
+							} else {
2539
+								return self::check_version(true);
2540
+							}
2343 2541
 						} elseif ($result['value'] == '15') {
2344 2542
 							$error = self::update_from_15();
2345
-							if ($error != '') return $error;
2346
-							else return self::check_version(true);
2543
+							if ($error != '') {
2544
+								return $error;
2545
+							} else {
2546
+								return self::check_version(true);
2547
+							}
2347 2548
 						} elseif ($result['value'] == '16') {
2348 2549
 							$error = self::update_from_16();
2349
-							if ($error != '') return $error;
2350
-							else return self::check_version(true);
2550
+							if ($error != '') {
2551
+								return $error;
2552
+							} else {
2553
+								return self::check_version(true);
2554
+							}
2351 2555
 						} elseif ($result['value'] == '17') {
2352 2556
 							$error = self::update_from_17();
2353
-							if ($error != '') return $error;
2354
-							else return self::check_version(true);
2557
+							if ($error != '') {
2558
+								return $error;
2559
+							} else {
2560
+								return self::check_version(true);
2561
+							}
2355 2562
 						} elseif ($result['value'] == '18') {
2356 2563
 							$error = self::update_from_18();
2357
-							if ($error != '') return $error;
2358
-							else return self::check_version(true);
2564
+							if ($error != '') {
2565
+								return $error;
2566
+							} else {
2567
+								return self::check_version(true);
2568
+							}
2359 2569
 						} elseif ($result['value'] == '19') {
2360 2570
 							$error = self::update_from_19();
2361
-							if ($error != '') return $error;
2362
-							else return self::check_version(true);
2571
+							if ($error != '') {
2572
+								return $error;
2573
+							} else {
2574
+								return self::check_version(true);
2575
+							}
2363 2576
 						} elseif ($result['value'] == '20') {
2364 2577
 							$error = self::update_from_20();
2365
-							if ($error != '') return $error;
2366
-							else return self::check_version(true);
2578
+							if ($error != '') {
2579
+								return $error;
2580
+							} else {
2581
+								return self::check_version(true);
2582
+							}
2367 2583
 						} elseif ($result['value'] == '21') {
2368 2584
 							$error = self::update_from_21();
2369
-							if ($error != '') return $error;
2370
-							else return self::check_version(true);
2585
+							if ($error != '') {
2586
+								return $error;
2587
+							} else {
2588
+								return self::check_version(true);
2589
+							}
2371 2590
 						} elseif ($result['value'] == '22') {
2372 2591
 							$error = self::update_from_22();
2373
-							if ($error != '') return $error;
2374
-							else return self::check_version(true);
2592
+							if ($error != '') {
2593
+								return $error;
2594
+							} else {
2595
+								return self::check_version(true);
2596
+							}
2375 2597
 						} elseif ($result['value'] == '23') {
2376 2598
 							$error = self::update_from_23();
2377
-							if ($error != '') return $error;
2378
-							else return self::check_version(true);
2599
+							if ($error != '') {
2600
+								return $error;
2601
+							} else {
2602
+								return self::check_version(true);
2603
+							}
2379 2604
 						} elseif ($result['value'] == '24') {
2380 2605
 							$error = self::update_from_24();
2381
-							if ($error != '') return $error;
2382
-							else return self::check_version(true);
2606
+							if ($error != '') {
2607
+								return $error;
2608
+							} else {
2609
+								return self::check_version(true);
2610
+							}
2383 2611
 						} elseif ($result['value'] == '25') {
2384 2612
 							$error = self::update_from_25();
2385
-							if ($error != '') return $error;
2386
-							else return self::check_version(true);
2613
+							if ($error != '') {
2614
+								return $error;
2615
+							} else {
2616
+								return self::check_version(true);
2617
+							}
2387 2618
 						} elseif ($result['value'] == '26') {
2388 2619
 							$error = self::update_from_26();
2389
-							if ($error != '') return $error;
2390
-							else return self::check_version(true);
2620
+							if ($error != '') {
2621
+								return $error;
2622
+							} else {
2623
+								return self::check_version(true);
2624
+							}
2391 2625
 						} elseif ($result['value'] == '27') {
2392 2626
 							$error = self::update_from_27();
2393
-							if ($error != '') return $error;
2394
-							else return self::check_version(true);
2627
+							if ($error != '') {
2628
+								return $error;
2629
+							} else {
2630
+								return self::check_version(true);
2631
+							}
2395 2632
 						} elseif ($result['value'] == '28') {
2396 2633
 							$error = self::update_from_28();
2397
-							if ($error != '') return $error;
2398
-							else return self::check_version(true);
2634
+							if ($error != '') {
2635
+								return $error;
2636
+							} else {
2637
+								return self::check_version(true);
2638
+							}
2399 2639
 						} elseif ($result['value'] == '29') {
2400 2640
 							$error = self::update_from_29();
2401
-							if ($error != '') return $error;
2402
-							else return self::check_version(true);
2641
+							if ($error != '') {
2642
+								return $error;
2643
+							} else {
2644
+								return self::check_version(true);
2645
+							}
2403 2646
 						} elseif ($result['value'] == '30') {
2404 2647
 							$error = self::update_from_30();
2405
-							if ($error != '') return $error;
2406
-							else return self::check_version(true);
2648
+							if ($error != '') {
2649
+								return $error;
2650
+							} else {
2651
+								return self::check_version(true);
2652
+							}
2407 2653
 						} elseif ($result['value'] == '31') {
2408 2654
 							$error = self::update_from_31();
2409
-							if ($error != '') return $error;
2410
-							else return self::check_version(true);
2655
+							if ($error != '') {
2656
+								return $error;
2657
+							} else {
2658
+								return self::check_version(true);
2659
+							}
2411 2660
 						} elseif ($result['value'] == '32') {
2412 2661
 							$error = self::update_from_32();
2413
-							if ($error != '') return $error;
2414
-							else return self::check_version(true);
2662
+							if ($error != '') {
2663
+								return $error;
2664
+							} else {
2665
+								return self::check_version(true);
2666
+							}
2415 2667
 						} elseif ($result['value'] == '33') {
2416 2668
 							$error = self::update_from_33();
2417
-							if ($error != '') return $error;
2418
-							else return self::check_version(true);
2669
+							if ($error != '') {
2670
+								return $error;
2671
+							} else {
2672
+								return self::check_version(true);
2673
+							}
2419 2674
 						} elseif ($result['value'] == '34') {
2420 2675
 							$error = self::update_from_34();
2421
-							if ($error != '') return $error;
2422
-							else return self::check_version(true);
2676
+							if ($error != '') {
2677
+								return $error;
2678
+							} else {
2679
+								return self::check_version(true);
2680
+							}
2423 2681
 						} elseif ($result['value'] == '35') {
2424 2682
 							$error = self::update_from_35();
2425
-							if ($error != '') return $error;
2426
-							else return self::check_version(true);
2683
+							if ($error != '') {
2684
+								return $error;
2685
+							} else {
2686
+								return self::check_version(true);
2687
+							}
2427 2688
 						} elseif ($result['value'] == '36') {
2428 2689
 							$error = self::update_from_36();
2429
-							if ($error != '') return $error;
2430
-							else return self::check_version(true);
2690
+							if ($error != '') {
2691
+								return $error;
2692
+							} else {
2693
+								return self::check_version(true);
2694
+							}
2431 2695
 						} elseif ($result['value'] == '37') {
2432 2696
 							$error = self::update_from_37();
2433
-							if ($error != '') return $error;
2434
-							else return self::check_version(true);
2697
+							if ($error != '') {
2698
+								return $error;
2699
+							} else {
2700
+								return self::check_version(true);
2701
+							}
2435 2702
 						} elseif ($result['value'] == '38') {
2436 2703
 							$error = self::update_from_38();
2437
-							if ($error != '') return $error;
2438
-							else return self::check_version(true);
2704
+							if ($error != '') {
2705
+								return $error;
2706
+							} else {
2707
+								return self::check_version(true);
2708
+							}
2439 2709
 						} elseif ($result['value'] == '39') {
2440 2710
 							$error = self::update_from_39();
2441
-							if ($error != '') return $error;
2442
-							else return self::check_version(true);
2711
+							if ($error != '') {
2712
+								return $error;
2713
+							} else {
2714
+								return self::check_version(true);
2715
+							}
2443 2716
 						} elseif ($result['value'] == '40') {
2444 2717
 							$error = self::update_from_40();
2445
-							if ($error != '') return $error;
2446
-							else return self::check_version(true);
2718
+							if ($error != '') {
2719
+								return $error;
2720
+							} else {
2721
+								return self::check_version(true);
2722
+							}
2447 2723
 						} elseif ($result['value'] == '41') {
2448 2724
 							$error = self::update_from_41();
2449
-							if ($error != '') return $error;
2450
-							else return self::check_version(true);
2725
+							if ($error != '') {
2726
+								return $error;
2727
+							} else {
2728
+								return self::check_version(true);
2729
+							}
2451 2730
 						} elseif ($result['value'] == '42') {
2452 2731
 							$error = self::update_from_42();
2453
-							if ($error != '') return $error;
2454
-							else return self::check_version(true);
2732
+							if ($error != '') {
2733
+								return $error;
2734
+							} else {
2735
+								return self::check_version(true);
2736
+							}
2455 2737
 						} elseif ($result['value'] == '43') {
2456 2738
 							$error = self::update_from_43();
2457
-							if ($error != '') return $error;
2458
-							else return self::check_version(true);
2739
+							if ($error != '') {
2740
+								return $error;
2741
+							} else {
2742
+								return self::check_version(true);
2743
+							}
2459 2744
 						} elseif ($result['value'] == '44') {
2460 2745
 							$error = self::update_from_44();
2461
-							if ($error != '') return $error;
2462
-							else return self::check_version(true);
2746
+							if ($error != '') {
2747
+								return $error;
2748
+							} else {
2749
+								return self::check_version(true);
2750
+							}
2463 2751
 						} elseif ($result['value'] == '45') {
2464 2752
 							$error = self::update_from_45();
2465
-							if ($error != '') return $error;
2466
-							else return self::check_version(true);
2753
+							if ($error != '') {
2754
+								return $error;
2755
+							} else {
2756
+								return self::check_version(true);
2757
+							}
2467 2758
 						} elseif ($result['value'] == '46') {
2468 2759
 							$error = self::update_from_46();
2469
-							if ($error != '') return $error;
2470
-							else return self::check_version(true);
2760
+							if ($error != '') {
2761
+								return $error;
2762
+							} else {
2763
+								return self::check_version(true);
2764
+							}
2471 2765
 						} elseif ($result['value'] == '47') {
2472 2766
 							$error = self::update_from_47();
2473
-							if ($error != '') return $error;
2474
-							else return self::check_version(true);
2767
+							if ($error != '') {
2768
+								return $error;
2769
+							} else {
2770
+								return self::check_version(true);
2771
+							}
2475 2772
 						} elseif ($result['value'] == '48') {
2476 2773
 							$error = self::update_from_48();
2477
-							if ($error != '') return $error;
2478
-							else return self::check_version(true);
2774
+							if ($error != '') {
2775
+								return $error;
2776
+							} else {
2777
+								return self::check_version(true);
2778
+							}
2479 2779
 						} elseif ($result['value'] == '49') {
2480 2780
 							$error = self::update_from_49();
2481
-							if ($error != '') return $error;
2482
-							else return self::check_version(true);
2483
-						} else return '';
2781
+							if ($error != '') {
2782
+								return $error;
2783
+							} else {
2784
+								return self::check_version(true);
2785
+							}
2786
+						} else {
2787
+							return '';
2788
+						}
2484 2789
 					} else {
2485
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2486
-						else return 0;
2790
+						if (isset($result['value']) && $result['value'] != '') {
2791
+							return $result['value'];
2792
+						} else {
2793
+							return 0;
2794
+						}
2487 2795
 					}
2488 2796
 				}
2489
-			} else return $version;
2797
+			} else {
2798
+				return $version;
2799
+			}
2490 2800
 		}
2491 2801
 	}
2492 2802
 }
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1151 added lines, -399 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 110
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 127
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1270,13 +1423,17 @@  discard block
 block discarded – undo
1270 1423
 						$sth = $Connection->db->prepare($query);
1271 1424
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1272 1425
 					} catch(PDOException $e) {
1273
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1426
+						if ($globalDebug) {
1427
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1428
+						}
1274 1429
 					}
1275 1430
 				}
1276 1431
 				$i++;
1277 1432
 			}
1278 1433
 			fclose($handle);
1279
-			if ($globalTransaction) $Connection->db->commit();
1434
+			if ($globalTransaction) {
1435
+				$Connection->db->commit();
1436
+			}
1280 1437
 		}
1281 1438
 		return '';
1282 1439
         }
@@ -1301,7 +1458,9 @@  discard block
 block discarded – undo
1301 1458
 			$i = 0;
1302 1459
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1303 1460
 			//$Connection->db->beginTransaction();
1304
-			if ($globalTransaction) $Connection->db->beginTransaction();
1461
+			if ($globalTransaction) {
1462
+				$Connection->db->beginTransaction();
1463
+			}
1305 1464
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1306 1465
 			{
1307 1466
 				if ($i > 0) {
@@ -1317,7 +1476,9 @@  discard block
 block discarded – undo
1317 1476
 				$i++;
1318 1477
 			}
1319 1478
 			fclose($handle);
1320
-			if ($globalTransaction) $Connection->db->commit();
1479
+			if ($globalTransaction) {
1480
+				$Connection->db->commit();
1481
+			}
1321 1482
 		}
1322 1483
 		return '';
1323 1484
         }
@@ -1337,7 +1498,9 @@  discard block
 block discarded – undo
1337 1498
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1338 1499
 		{
1339 1500
 			$i = 0;
1340
-			if ($globalTransaction) $Connection->db->beginTransaction();
1501
+			if ($globalTransaction) {
1502
+				$Connection->db->beginTransaction();
1503
+			}
1341 1504
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1342 1505
 			{
1343 1506
 				if ($i > 0) {
@@ -1354,7 +1517,9 @@  discard block
 block discarded – undo
1354 1517
 				$i++;
1355 1518
 			}
1356 1519
 			fclose($handle);
1357
-			if ($globalTransaction) $Connection->db->commit();
1520
+			if ($globalTransaction) {
1521
+				$Connection->db->commit();
1522
+			}
1358 1523
 		}
1359 1524
 		return '';
1360 1525
 	}
@@ -1373,7 +1538,9 @@  discard block
 block discarded – undo
1373 1538
 		$Connection = new Connection();
1374 1539
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1375 1540
 		{
1376
-			if ($globalTransaction) $Connection->db->beginTransaction();
1541
+			if ($globalTransaction) {
1542
+				$Connection->db->beginTransaction();
1543
+			}
1377 1544
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1378 1545
 			{
1379 1546
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1388,7 +1555,9 @@  discard block
 block discarded – undo
1388 1555
 				}
1389 1556
 			}
1390 1557
 			fclose($handle);
1391
-			if ($globalTransaction) $Connection->db->commit();
1558
+			if ($globalTransaction) {
1559
+				$Connection->db->commit();
1560
+			}
1392 1561
 		}
1393 1562
 		return '';
1394 1563
         }
@@ -1464,9 +1633,14 @@  discard block
 block discarded – undo
1464 1633
 				if ($i > 0 && $data[0] != '') {
1465 1634
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1466 1635
 					$period = str_replace(',','',$data[14]);
1467
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1468
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1469
-					else $launch_date = NULL;
1636
+					if (!empty($period) && strpos($period,'days')) {
1637
+						$period = str_replace(' days','',$period)*24*60;
1638
+					}
1639
+					if ($data[18] != '') {
1640
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1641
+					} else {
1642
+						$launch_date = NULL;
1643
+					}
1470 1644
 					$data = array_map(function($value) {
1471 1645
 						return trim($value) === '' ? null : $value;
1472 1646
 					}, $data);
@@ -1829,7 +2003,9 @@  discard block
 block discarded – undo
1829 2003
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1830 2004
 		{
1831 2005
 			$i = 0;
1832
-			if ($globalTransaction) $Connection->db->beginTransaction();
2006
+			if ($globalTransaction) {
2007
+				$Connection->db->beginTransaction();
2008
+			}
1833 2009
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1834 2010
 			{
1835 2011
 				$i++;
@@ -1857,7 +2033,9 @@  discard block
 block discarded – undo
1857 2033
 				}
1858 2034
 			}
1859 2035
 			fclose($handle);
1860
-			if ($globalTransaction) $Connection->db->commit();
2036
+			if ($globalTransaction) {
2037
+				$Connection->db->commit();
2038
+			}
1861 2039
 		}
1862 2040
 		return '';
1863 2041
 	}
@@ -1900,7 +2078,9 @@  discard block
 block discarded – undo
1900 2078
 		$Connection = new Connection();
1901 2079
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1902 2080
 		{
1903
-			if ($globalTransaction) $Connection->db->beginTransaction();
2081
+			if ($globalTransaction) {
2082
+				$Connection->db->beginTransaction();
2083
+			}
1904 2084
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1905 2085
 			{
1906 2086
 				if(count($row) > 1) {
@@ -1914,7 +2094,9 @@  discard block
 block discarded – undo
1914 2094
 				}
1915 2095
 			}
1916 2096
 			fclose($handle);
1917
-			if ($globalTransaction) $Connection->db->commit();
2097
+			if ($globalTransaction) {
2098
+				$Connection->db->commit();
2099
+			}
1918 2100
 		}
1919 2101
 		return '';
1920 2102
         }
@@ -1934,8 +2116,9 @@  discard block
 block discarded – undo
1934 2116
 	        }
1935 2117
 
1936 2118
 
1937
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1938
-		else {
2119
+		if ($globalDBdriver == 'mysql') {
2120
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2121
+		} else {
1939 2122
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1940 2123
 			$query = "CREATE EXTENSION postgis";
1941 2124
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1954,7 +2137,9 @@  discard block
 block discarded – undo
1954 2137
 		global $tmp_dir, $globalDebug;
1955 2138
 		include_once('class.create_db.php');
1956 2139
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1957
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2140
+		if ($globalDebug) {
2141
+			echo "NOTAM from FlightAirMap website : Download...";
2142
+		}
1958 2143
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1959 2144
 		$error = '';
1960 2145
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -1964,20 +2149,34 @@  discard block
 block discarded – undo
1964 2149
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1965 2150
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1966 2151
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1967
-						if ($globalDebug) echo "Gunzip...";
2152
+						if ($globalDebug) {
2153
+							echo "Gunzip...";
2154
+						}
1968 2155
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
1969
-						if ($globalDebug) echo "Add to DB...";
2156
+						if ($globalDebug) {
2157
+							echo "Add to DB...";
2158
+						}
1970 2159
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
1971 2160
 						$NOTAM = new NOTAM();
1972 2161
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1973 2162
 						update_db::insert_notam_version($notam_md5);
1974
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
1975
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1976
-			} elseif ($globalDebug) echo "No new version.";
1977
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2163
+					} else {
2164
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2165
+					}
2166
+				} else {
2167
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2168
+				}
2169
+			} elseif ($globalDebug) {
2170
+				echo "No new version.";
2171
+			}
2172
+		} else {
2173
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2174
+		}
1978 2175
 		if ($error != '') {
1979 2176
 			return $error;
1980
-		} elseif ($globalDebug) echo "Done\n";
2177
+		} elseif ($globalDebug) {
2178
+			echo "Done\n";
2179
+		}
1981 2180
 		return '';
1982 2181
 	}
1983 2182
 
@@ -2032,68 +2231,114 @@  discard block
 block discarded – undo
2032 2231
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2033 2232
 		if (extension_loaded('zip')) {
2034 2233
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2035
-				if ($globalDebug) echo "Unzip...";
2234
+				if ($globalDebug) {
2235
+					echo "Unzip...";
2236
+				}
2036 2237
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2037
-				if ($globalDebug) echo "Add to DB...";
2238
+				if ($globalDebug) {
2239
+					echo "Add to DB...";
2240
+				}
2038 2241
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2039
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2242
+				if ($globalDebug) {
2243
+					echo "Copy airlines logos to airlines images directory...";
2244
+				}
2040 2245
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2041
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2042
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2043
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2044
-		} else $error = "ZIP module not loaded but required for IVAO.";
2246
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2247
+						$error = "Failed to copy airlines logo.";
2248
+					}
2249
+				} else {
2250
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2251
+				}
2252
+			} else {
2253
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2254
+			}
2255
+		} else {
2256
+			$error = "ZIP module not loaded but required for IVAO.";
2257
+		}
2045 2258
 		if ($error != '') {
2046 2259
 			return $error;
2047
-		} elseif ($globalDebug) echo "Done\n";
2260
+		} elseif ($globalDebug) {
2261
+			echo "Done\n";
2262
+		}
2048 2263
 		return '';
2049 2264
 	}
2050 2265
 
2051 2266
 	public static function update_routes() {
2052 2267
 		global $tmp_dir, $globalDebug;
2053 2268
 		$error = '';
2054
-		if ($globalDebug) echo "Routes : Download...";
2269
+		if ($globalDebug) {
2270
+			echo "Routes : Download...";
2271
+		}
2055 2272
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2056 2273
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2057
-			if ($globalDebug) echo "Gunzip...";
2274
+			if ($globalDebug) {
2275
+				echo "Gunzip...";
2276
+			}
2058 2277
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2059
-			if ($globalDebug) echo "Add to DB...";
2278
+			if ($globalDebug) {
2279
+				echo "Add to DB...";
2280
+			}
2060 2281
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2061
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2282
+		} else {
2283
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2284
+		}
2062 2285
 		if ($error != '') {
2063 2286
 			return $error;
2064
-		} elseif ($globalDebug) echo "Done\n";
2287
+		} elseif ($globalDebug) {
2288
+			echo "Done\n";
2289
+		}
2065 2290
 		return '';
2066 2291
 	}
2067 2292
 	public static function update_oneworld() {
2068 2293
 		global $tmp_dir, $globalDebug;
2069 2294
 		$error = '';
2070
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2295
+		if ($globalDebug) {
2296
+			echo "Schedules Oneworld : Download...";
2297
+		}
2071 2298
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2072 2299
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2073
-			if ($globalDebug) echo "Gunzip...";
2300
+			if ($globalDebug) {
2301
+				echo "Gunzip...";
2302
+			}
2074 2303
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2075
-			if ($globalDebug) echo "Add to DB...";
2304
+			if ($globalDebug) {
2305
+				echo "Add to DB...";
2306
+			}
2076 2307
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2077
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2308
+		} else {
2309
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2310
+		}
2078 2311
 		if ($error != '') {
2079 2312
 			return $error;
2080
-		} elseif ($globalDebug) echo "Done\n";
2313
+		} elseif ($globalDebug) {
2314
+			echo "Done\n";
2315
+		}
2081 2316
 		return '';
2082 2317
 	}
2083 2318
 	public static function update_skyteam() {
2084 2319
 		global $tmp_dir, $globalDebug;
2085 2320
 		$error = '';
2086
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2321
+		if ($globalDebug) {
2322
+			echo "Schedules Skyteam : Download...";
2323
+		}
2087 2324
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2088 2325
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2089
-			if ($globalDebug) echo "Gunzip...";
2326
+			if ($globalDebug) {
2327
+				echo "Gunzip...";
2328
+			}
2090 2329
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2091
-			if ($globalDebug) echo "Add to DB...";
2330
+			if ($globalDebug) {
2331
+				echo "Add to DB...";
2332
+			}
2092 2333
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2093
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2334
+		} else {
2335
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2336
+		}
2094 2337
 		if ($error != '') {
2095 2338
 			return $error;
2096
-		} elseif ($globalDebug) echo "Done\n";
2339
+		} elseif ($globalDebug) {
2340
+			echo "Done\n";
2341
+		}
2097 2342
 		return '';
2098 2343
 	}
2099 2344
 	public static function update_ModeS() {
@@ -2110,340 +2355,590 @@  discard block
 block discarded – undo
2110 2355
 			exit;
2111 2356
 		} elseif ($globalDebug) echo "Done\n";
2112 2357
 */
2113
-		if ($globalDebug) echo "Modes : Download...";
2114
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2358
+		if ($globalDebug) {
2359
+			echo "Modes : Download...";
2360
+		}
2361
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2115 2362
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2116 2363
 
2117 2364
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2118 2365
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2119
-			if ($globalDebug) echo "Unzip...";
2120
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2366
+			if ($globalDebug) {
2367
+				echo "Unzip...";
2368
+			}
2369
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2121 2370
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2122
-			if ($globalDebug) echo "Add to DB...";
2371
+			if ($globalDebug) {
2372
+				echo "Add to DB...";
2373
+			}
2123 2374
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2124 2375
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2125
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2376
+		} else {
2377
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2378
+		}
2126 2379
 		if ($error != '') {
2127 2380
 			return $error;
2128
-		} elseif ($globalDebug) echo "Done\n";
2381
+		} elseif ($globalDebug) {
2382
+			echo "Done\n";
2383
+		}
2129 2384
 		return '';
2130 2385
 	}
2131 2386
 
2132 2387
 	public static function update_ModeS_faa() {
2133 2388
 		global $tmp_dir, $globalDebug;
2134
-		if ($globalDebug) echo "Modes FAA: Download...";
2389
+		if ($globalDebug) {
2390
+			echo "Modes FAA: Download...";
2391
+		}
2135 2392
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2136 2393
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2137
-			if ($globalDebug) echo "Unzip...";
2394
+			if ($globalDebug) {
2395
+				echo "Unzip...";
2396
+			}
2138 2397
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2139
-			if ($globalDebug) echo "Add to DB...";
2398
+			if ($globalDebug) {
2399
+				echo "Add to DB...";
2400
+			}
2140 2401
 			$error = update_db::modes_faa();
2141
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2402
+		} else {
2403
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2404
+		}
2142 2405
 		if ($error != '') {
2143 2406
 			return $error;
2144
-		} elseif ($globalDebug) echo "Done\n";
2407
+		} elseif ($globalDebug) {
2408
+			echo "Done\n";
2409
+		}
2145 2410
 		return '';
2146 2411
 	}
2147 2412
 
2148 2413
 	public static function update_ModeS_flarm() {
2149 2414
 		global $tmp_dir, $globalDebug;
2150
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2415
+		if ($globalDebug) {
2416
+			echo "Modes Flarmnet: Download...";
2417
+		}
2151 2418
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2152 2419
 		if (file_exists($tmp_dir.'data.fln')) {
2153
-			if ($globalDebug) echo "Add to DB...";
2420
+			if ($globalDebug) {
2421
+				echo "Add to DB...";
2422
+			}
2154 2423
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2155
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2424
+		} else {
2425
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2426
+		}
2156 2427
 		if ($error != '') {
2157 2428
 			return $error;
2158
-		} elseif ($globalDebug) echo "Done\n";
2429
+		} elseif ($globalDebug) {
2430
+			echo "Done\n";
2431
+		}
2159 2432
 		return '';
2160 2433
 	}
2161 2434
 
2162 2435
 	public static function update_ModeS_ogn() {
2163 2436
 		global $tmp_dir, $globalDebug;
2164
-		if ($globalDebug) echo "Modes OGN: Download...";
2437
+		if ($globalDebug) {
2438
+			echo "Modes OGN: Download...";
2439
+		}
2165 2440
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2166 2441
 		if (file_exists($tmp_dir.'ogn.csv')) {
2167
-			if ($globalDebug) echo "Add to DB...";
2442
+			if ($globalDebug) {
2443
+				echo "Add to DB...";
2444
+			}
2168 2445
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2169
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2446
+		} else {
2447
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2448
+		}
2170 2449
 		if ($error != '') {
2171 2450
 			return $error;
2172
-		} elseif ($globalDebug) echo "Done\n";
2451
+		} elseif ($globalDebug) {
2452
+			echo "Done\n";
2453
+		}
2173 2454
 		return '';
2174 2455
 	}
2175 2456
 
2176 2457
 	public static function update_owner() {
2177 2458
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2178 2459
 		
2179
-		if ($globalDebug) echo "Owner France: Download...";
2460
+		if ($globalDebug) {
2461
+			echo "Owner France: Download...";
2462
+		}
2180 2463
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2181 2464
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2182
-			if ($globalDebug) echo "Add to DB...";
2465
+			if ($globalDebug) {
2466
+				echo "Add to DB...";
2467
+			}
2183 2468
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2184
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2469
+		} else {
2470
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2471
+		}
2185 2472
 		if ($error != '') {
2186 2473
 			return $error;
2187
-		} elseif ($globalDebug) echo "Done\n";
2474
+		} elseif ($globalDebug) {
2475
+			echo "Done\n";
2476
+		}
2188 2477
 		
2189
-		if ($globalDebug) echo "Owner Ireland: Download...";
2478
+		if ($globalDebug) {
2479
+			echo "Owner Ireland: Download...";
2480
+		}
2190 2481
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2191 2482
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2192
-			if ($globalDebug) echo "Add to DB...";
2483
+			if ($globalDebug) {
2484
+				echo "Add to DB...";
2485
+			}
2193 2486
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2194
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2487
+		} else {
2488
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2489
+		}
2195 2490
 		if ($error != '') {
2196 2491
 			return $error;
2197
-		} elseif ($globalDebug) echo "Done\n";
2198
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2492
+		} elseif ($globalDebug) {
2493
+			echo "Done\n";
2494
+		}
2495
+		if ($globalDebug) {
2496
+			echo "Owner Switzerland: Download...";
2497
+		}
2199 2498
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2200 2499
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2201
-			if ($globalDebug) echo "Add to DB...";
2500
+			if ($globalDebug) {
2501
+				echo "Add to DB...";
2502
+			}
2202 2503
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2203
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2504
+		} else {
2505
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2506
+		}
2204 2507
 		if ($error != '') {
2205 2508
 			return $error;
2206
-		} elseif ($globalDebug) echo "Done\n";
2207
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2509
+		} elseif ($globalDebug) {
2510
+			echo "Done\n";
2511
+		}
2512
+		if ($globalDebug) {
2513
+			echo "Owner Czech Republic: Download...";
2514
+		}
2208 2515
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2209 2516
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2210
-			if ($globalDebug) echo "Add to DB...";
2517
+			if ($globalDebug) {
2518
+				echo "Add to DB...";
2519
+			}
2211 2520
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2212
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2521
+		} else {
2522
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2523
+		}
2213 2524
 		if ($error != '') {
2214 2525
 			return $error;
2215
-		} elseif ($globalDebug) echo "Done\n";
2216
-		if ($globalDebug) echo "Owner Australia: Download...";
2526
+		} elseif ($globalDebug) {
2527
+			echo "Done\n";
2528
+		}
2529
+		if ($globalDebug) {
2530
+			echo "Owner Australia: Download...";
2531
+		}
2217 2532
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2218 2533
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2219
-			if ($globalDebug) echo "Add to DB...";
2534
+			if ($globalDebug) {
2535
+				echo "Add to DB...";
2536
+			}
2220 2537
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2221
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2538
+		} else {
2539
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2540
+		}
2222 2541
 		if ($error != '') {
2223 2542
 			return $error;
2224
-		} elseif ($globalDebug) echo "Done\n";
2225
-		if ($globalDebug) echo "Owner Austria: Download...";
2543
+		} elseif ($globalDebug) {
2544
+			echo "Done\n";
2545
+		}
2546
+		if ($globalDebug) {
2547
+			echo "Owner Austria: Download...";
2548
+		}
2226 2549
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2227 2550
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2228
-			if ($globalDebug) echo "Add to DB...";
2551
+			if ($globalDebug) {
2552
+				echo "Add to DB...";
2553
+			}
2229 2554
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2230
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2555
+		} else {
2556
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2557
+		}
2231 2558
 		if ($error != '') {
2232 2559
 			return $error;
2233
-		} elseif ($globalDebug) echo "Done\n";
2234
-		if ($globalDebug) echo "Owner Chile: Download...";
2560
+		} elseif ($globalDebug) {
2561
+			echo "Done\n";
2562
+		}
2563
+		if ($globalDebug) {
2564
+			echo "Owner Chile: Download...";
2565
+		}
2235 2566
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2236 2567
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2237
-			if ($globalDebug) echo "Add to DB...";
2568
+			if ($globalDebug) {
2569
+				echo "Add to DB...";
2570
+			}
2238 2571
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2239
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2572
+		} else {
2573
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2574
+		}
2240 2575
 		if ($error != '') {
2241 2576
 			return $error;
2242
-		} elseif ($globalDebug) echo "Done\n";
2243
-		if ($globalDebug) echo "Owner Colombia: Download...";
2577
+		} elseif ($globalDebug) {
2578
+			echo "Done\n";
2579
+		}
2580
+		if ($globalDebug) {
2581
+			echo "Owner Colombia: Download...";
2582
+		}
2244 2583
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2245 2584
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2246
-			if ($globalDebug) echo "Add to DB...";
2585
+			if ($globalDebug) {
2586
+				echo "Add to DB...";
2587
+			}
2247 2588
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2248
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2589
+		} else {
2590
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2591
+		}
2249 2592
 		if ($error != '') {
2250 2593
 			return $error;
2251
-		} elseif ($globalDebug) echo "Done\n";
2252
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2594
+		} elseif ($globalDebug) {
2595
+			echo "Done\n";
2596
+		}
2597
+		if ($globalDebug) {
2598
+			echo "Owner Bosnia Herzegobina: Download...";
2599
+		}
2253 2600
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2254 2601
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2255
-			if ($globalDebug) echo "Add to DB...";
2602
+			if ($globalDebug) {
2603
+				echo "Add to DB...";
2604
+			}
2256 2605
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2257
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2606
+		} else {
2607
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2608
+		}
2258 2609
 		if ($error != '') {
2259 2610
 			return $error;
2260
-		} elseif ($globalDebug) echo "Done\n";
2261
-		if ($globalDebug) echo "Owner Brazil: Download...";
2611
+		} elseif ($globalDebug) {
2612
+			echo "Done\n";
2613
+		}
2614
+		if ($globalDebug) {
2615
+			echo "Owner Brazil: Download...";
2616
+		}
2262 2617
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2263 2618
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2264
-			if ($globalDebug) echo "Add to DB...";
2619
+			if ($globalDebug) {
2620
+				echo "Add to DB...";
2621
+			}
2265 2622
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2266
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2623
+		} else {
2624
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2625
+		}
2267 2626
 		if ($error != '') {
2268 2627
 			return $error;
2269
-		} elseif ($globalDebug) echo "Done\n";
2270
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2628
+		} elseif ($globalDebug) {
2629
+			echo "Done\n";
2630
+		}
2631
+		if ($globalDebug) {
2632
+			echo "Owner Cayman Islands: Download...";
2633
+		}
2271 2634
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2272 2635
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2273
-			if ($globalDebug) echo "Add to DB...";
2636
+			if ($globalDebug) {
2637
+				echo "Add to DB...";
2638
+			}
2274 2639
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2275
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2640
+		} else {
2641
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2642
+		}
2276 2643
 		if ($error != '') {
2277 2644
 			return $error;
2278
-		} elseif ($globalDebug) echo "Done\n";
2279
-		if ($globalDebug) echo "Owner Croatia: Download...";
2645
+		} elseif ($globalDebug) {
2646
+			echo "Done\n";
2647
+		}
2648
+		if ($globalDebug) {
2649
+			echo "Owner Croatia: Download...";
2650
+		}
2280 2651
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2281 2652
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2282
-			if ($globalDebug) echo "Add to DB...";
2653
+			if ($globalDebug) {
2654
+				echo "Add to DB...";
2655
+			}
2283 2656
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2284
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2657
+		} else {
2658
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2659
+		}
2285 2660
 		if ($error != '') {
2286 2661
 			return $error;
2287
-		} elseif ($globalDebug) echo "Done\n";
2288
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2662
+		} elseif ($globalDebug) {
2663
+			echo "Done\n";
2664
+		}
2665
+		if ($globalDebug) {
2666
+			echo "Owner Luxembourg: Download...";
2667
+		}
2289 2668
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2290 2669
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2291
-			if ($globalDebug) echo "Add to DB...";
2670
+			if ($globalDebug) {
2671
+				echo "Add to DB...";
2672
+			}
2292 2673
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2293
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2674
+		} else {
2675
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2676
+		}
2294 2677
 		if ($error != '') {
2295 2678
 			return $error;
2296
-		} elseif ($globalDebug) echo "Done\n";
2297
-		if ($globalDebug) echo "Owner Maldives: Download...";
2679
+		} elseif ($globalDebug) {
2680
+			echo "Done\n";
2681
+		}
2682
+		if ($globalDebug) {
2683
+			echo "Owner Maldives: Download...";
2684
+		}
2298 2685
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2299 2686
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2300
-			if ($globalDebug) echo "Add to DB...";
2687
+			if ($globalDebug) {
2688
+				echo "Add to DB...";
2689
+			}
2301 2690
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2302
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2691
+		} else {
2692
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2693
+		}
2303 2694
 		if ($error != '') {
2304 2695
 			return $error;
2305
-		} elseif ($globalDebug) echo "Done\n";
2306
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2696
+		} elseif ($globalDebug) {
2697
+			echo "Done\n";
2698
+		}
2699
+		if ($globalDebug) {
2700
+			echo "Owner New Zealand: Download...";
2701
+		}
2307 2702
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2308 2703
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2309
-			if ($globalDebug) echo "Add to DB...";
2704
+			if ($globalDebug) {
2705
+				echo "Add to DB...";
2706
+			}
2310 2707
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2311
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2708
+		} else {
2709
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2710
+		}
2312 2711
 		if ($error != '') {
2313 2712
 			return $error;
2314
-		} elseif ($globalDebug) echo "Done\n";
2315
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2713
+		} elseif ($globalDebug) {
2714
+			echo "Done\n";
2715
+		}
2716
+		if ($globalDebug) {
2717
+			echo "Owner Papua New Guinea: Download...";
2718
+		}
2316 2719
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2317 2720
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2318
-			if ($globalDebug) echo "Add to DB...";
2721
+			if ($globalDebug) {
2722
+				echo "Add to DB...";
2723
+			}
2319 2724
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2320
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2725
+		} else {
2726
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2727
+		}
2321 2728
 		if ($error != '') {
2322 2729
 			return $error;
2323
-		} elseif ($globalDebug) echo "Done\n";
2324
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2730
+		} elseif ($globalDebug) {
2731
+			echo "Done\n";
2732
+		}
2733
+		if ($globalDebug) {
2734
+			echo "Owner Slovakia: Download...";
2735
+		}
2325 2736
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2326 2737
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2327
-			if ($globalDebug) echo "Add to DB...";
2738
+			if ($globalDebug) {
2739
+				echo "Add to DB...";
2740
+			}
2328 2741
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2329
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2742
+		} else {
2743
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2744
+		}
2330 2745
 		if ($error != '') {
2331 2746
 			return $error;
2332
-		} elseif ($globalDebug) echo "Done\n";
2333
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2747
+		} elseif ($globalDebug) {
2748
+			echo "Done\n";
2749
+		}
2750
+		if ($globalDebug) {
2751
+			echo "Owner Ecuador: Download...";
2752
+		}
2334 2753
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2335 2754
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2336
-			if ($globalDebug) echo "Add to DB...";
2755
+			if ($globalDebug) {
2756
+				echo "Add to DB...";
2757
+			}
2337 2758
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2338
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2759
+		} else {
2760
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2761
+		}
2339 2762
 		if ($error != '') {
2340 2763
 			return $error;
2341
-		} elseif ($globalDebug) echo "Done\n";
2342
-		if ($globalDebug) echo "Owner Iceland: Download...";
2764
+		} elseif ($globalDebug) {
2765
+			echo "Done\n";
2766
+		}
2767
+		if ($globalDebug) {
2768
+			echo "Owner Iceland: Download...";
2769
+		}
2343 2770
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2344 2771
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2345
-			if ($globalDebug) echo "Add to DB...";
2772
+			if ($globalDebug) {
2773
+				echo "Add to DB...";
2774
+			}
2346 2775
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2347
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2776
+		} else {
2777
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2778
+		}
2348 2779
 		if ($error != '') {
2349 2780
 			return $error;
2350
-		} elseif ($globalDebug) echo "Done\n";
2351
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2781
+		} elseif ($globalDebug) {
2782
+			echo "Done\n";
2783
+		}
2784
+		if ($globalDebug) {
2785
+			echo "Owner Isle of Man: Download...";
2786
+		}
2352 2787
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2353 2788
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2354
-			if ($globalDebug) echo "Add to DB...";
2789
+			if ($globalDebug) {
2790
+				echo "Add to DB...";
2791
+			}
2355 2792
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2356
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2793
+		} else {
2794
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2795
+		}
2357 2796
 		if ($error != '') {
2358 2797
 			return $error;
2359
-		} elseif ($globalDebug) echo "Done\n";
2798
+		} elseif ($globalDebug) {
2799
+			echo "Done\n";
2800
+		}
2360 2801
 		if ($globalMasterSource) {
2361
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2802
+			if ($globalDebug) {
2803
+				echo "ModeS Netherlands: Download...";
2804
+			}
2362 2805
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2363 2806
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2364
-				if ($globalDebug) echo "Add to DB...";
2807
+				if ($globalDebug) {
2808
+					echo "Add to DB...";
2809
+				}
2365 2810
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2366
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2811
+			} else {
2812
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2813
+			}
2367 2814
 			if ($error != '') {
2368 2815
 				return $error;
2369
-			} elseif ($globalDebug) echo "Done\n";
2370
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2816
+			} elseif ($globalDebug) {
2817
+				echo "Done\n";
2818
+			}
2819
+			if ($globalDebug) {
2820
+				echo "ModeS Denmark: Download...";
2821
+			}
2371 2822
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2372 2823
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2373
-				if ($globalDebug) echo "Add to DB...";
2824
+				if ($globalDebug) {
2825
+					echo "Add to DB...";
2826
+				}
2374 2827
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2375
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2828
+			} else {
2829
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2830
+			}
2376 2831
 			if ($error != '') {
2377 2832
 				return $error;
2378
-			} elseif ($globalDebug) echo "Done\n";
2379
-		} elseif ($globalDebug) echo "Done\n";
2833
+			} elseif ($globalDebug) {
2834
+				echo "Done\n";
2835
+			}
2836
+		} elseif ($globalDebug) {
2837
+			echo "Done\n";
2838
+		}
2380 2839
 		return '';
2381 2840
 	}
2382 2841
 
2383 2842
 	public static function update_translation() {
2384 2843
 		global $tmp_dir, $globalDebug;
2385 2844
 		$error = '';
2386
-		if ($globalDebug) echo "Translation : Download...";
2845
+		if ($globalDebug) {
2846
+			echo "Translation : Download...";
2847
+		}
2387 2848
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2388 2849
 		if (file_exists($tmp_dir.'translation.zip')) {
2389
-			if ($globalDebug) echo "Unzip...";
2850
+			if ($globalDebug) {
2851
+				echo "Unzip...";
2852
+			}
2390 2853
 			update_db::unzip($tmp_dir.'translation.zip');
2391
-			if ($globalDebug) echo "Add to DB...";
2854
+			if ($globalDebug) {
2855
+				echo "Add to DB...";
2856
+			}
2392 2857
 			$error = update_db::translation();
2393
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2858
+		} else {
2859
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2860
+		}
2394 2861
 		if ($error != '') {
2395 2862
 			return $error;
2396
-		} elseif ($globalDebug) echo "Done\n";
2863
+		} elseif ($globalDebug) {
2864
+			echo "Done\n";
2865
+		}
2397 2866
 		return '';
2398 2867
 	}
2399 2868
 
2400 2869
 	public static function update_translation_fam() {
2401 2870
 		global $tmp_dir, $globalDebug;
2402 2871
 		$error = '';
2403
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2872
+		if ($globalDebug) {
2873
+			echo "Translation from FlightAirMap website : Download...";
2874
+		}
2404 2875
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2405 2876
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2406 2877
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2407 2878
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2408 2879
 			$translation_md5 = $translation_md5_file[0];
2409 2880
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2410
-				if ($globalDebug) echo "Gunzip...";
2881
+				if ($globalDebug) {
2882
+					echo "Gunzip...";
2883
+				}
2411 2884
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2412
-				if ($globalDebug) echo "Add to DB...";
2885
+				if ($globalDebug) {
2886
+					echo "Add to DB...";
2887
+				}
2413 2888
 				$error = update_db::translation_fam();
2414
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2415
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2889
+			} else {
2890
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2891
+			}
2892
+		} else {
2893
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2894
+		}
2416 2895
 		if ($error != '') {
2417 2896
 			return $error;
2418
-		} elseif ($globalDebug) echo "Done\n";
2897
+		} elseif ($globalDebug) {
2898
+			echo "Done\n";
2899
+		}
2419 2900
 		return '';
2420 2901
 	}
2421 2902
 	public static function update_ModeS_fam() {
2422 2903
 		global $tmp_dir, $globalDebug;
2423 2904
 		$error = '';
2424
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2905
+		if ($globalDebug) {
2906
+			echo "ModeS from FlightAirMap website : Download...";
2907
+		}
2425 2908
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2426 2909
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2427 2910
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2428 2911
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2429 2912
 			$modes_md5 = $modes_md5_file[0];
2430 2913
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2431
-				if ($globalDebug) echo "Gunzip...";
2914
+				if ($globalDebug) {
2915
+					echo "Gunzip...";
2916
+				}
2432 2917
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2433
-				if ($globalDebug) echo "Add to DB...";
2918
+				if ($globalDebug) {
2919
+					echo "Add to DB...";
2920
+				}
2434 2921
 				$error = update_db::modes_fam();
2435
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2436
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2922
+			} else {
2923
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2924
+			}
2925
+		} else {
2926
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2927
+		}
2437 2928
 		if ($error != '') {
2438 2929
 			return $error;
2439
-		} elseif ($globalDebug) echo "Done\n";
2930
+		} elseif ($globalDebug) {
2931
+			echo "Done\n";
2932
+		}
2440 2933
 		return '';
2441 2934
 	}
2442 2935
 
2443 2936
 	public static function update_airlines_fam() {
2444 2937
 		global $tmp_dir, $globalDebug;
2445 2938
 		$error = '';
2446
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2939
+		if ($globalDebug) {
2940
+			echo "Airlines from FlightAirMap website : Download...";
2941
+		}
2447 2942
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2448 2943
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2449 2944
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2452,26 +2947,42 @@  discard block
 block discarded – undo
2452 2947
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2453 2948
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2454 2949
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2455
-						if ($globalDebug) echo "Gunzip...";
2950
+						if ($globalDebug) {
2951
+							echo "Gunzip...";
2952
+						}
2456 2953
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2457
-						if ($globalDebug) echo "Add to DB...";
2954
+						if ($globalDebug) {
2955
+							echo "Add to DB...";
2956
+						}
2458 2957
 						$error = update_db::airlines_fam();
2459 2958
 						update_db::insert_airlines_version($airlines_md5);
2460
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2461
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2462
-			} elseif ($globalDebug) echo "No update.";
2463
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2959
+					} else {
2960
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2961
+					}
2962
+			    } else {
2963
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2964
+			    }
2965
+			} elseif ($globalDebug) {
2966
+				echo "No update.";
2967
+			}
2968
+		} else {
2969
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2970
+		}
2464 2971
 		if ($error != '') {
2465 2972
 			return $error;
2466 2973
 		} else {
2467
-			if ($globalDebug) echo "Done\n";
2974
+			if ($globalDebug) {
2975
+				echo "Done\n";
2976
+			}
2468 2977
 		}
2469 2978
 		return '';
2470 2979
 	}
2471 2980
 
2472 2981
 	public static function update_owner_fam() {
2473 2982
 		global $tmp_dir, $globalDebug, $globalOwner;
2474
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2983
+		if ($globalDebug) {
2984
+			echo "owner from FlightAirMap website : Download...";
2985
+		}
2475 2986
 		$error = '';
2476 2987
 		if ($globalOwner === TRUE) {
2477 2988
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2484,35 +2995,57 @@  discard block
 block discarded – undo
2484 2995
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2485 2996
 			$owners_md5 = $owners_md5_file[0];
2486 2997
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2487
-				if ($globalDebug) echo "Gunzip...";
2998
+				if ($globalDebug) {
2999
+					echo "Gunzip...";
3000
+				}
2488 3001
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2489
-				if ($globalDebug) echo "Add to DB...";
3002
+				if ($globalDebug) {
3003
+					echo "Add to DB...";
3004
+				}
2490 3005
 				$error = update_db::owner_fam();
2491
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2492
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3006
+			} else {
3007
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3008
+			}
3009
+		} else {
3010
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3011
+		}
2493 3012
 		if ($error != '') {
2494 3013
 			return $error;
2495
-		} elseif ($globalDebug) echo "Done\n";
3014
+		} elseif ($globalDebug) {
3015
+			echo "Done\n";
3016
+		}
2496 3017
 		return '';
2497 3018
 	}
2498 3019
 	public static function update_routes_fam() {
2499 3020
 		global $tmp_dir, $globalDebug;
2500
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3021
+		if ($globalDebug) {
3022
+			echo "Routes from FlightAirMap website : Download...";
3023
+		}
2501 3024
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2502 3025
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2503 3026
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2504 3027
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2505 3028
 			$routes_md5 = $routes_md5_file[0];
2506 3029
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2507
-				if ($globalDebug) echo "Gunzip...";
3030
+				if ($globalDebug) {
3031
+					echo "Gunzip...";
3032
+				}
2508 3033
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2509
-				if ($globalDebug) echo "Add to DB...";
3034
+				if ($globalDebug) {
3035
+					echo "Add to DB...";
3036
+				}
2510 3037
 				$error = update_db::routes_fam();
2511
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2512
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3038
+			} else {
3039
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3040
+			}
3041
+		} else {
3042
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3043
+		}
2513 3044
 		if ($error != '') {
2514 3045
 			return $error;
2515
-		} elseif ($globalDebug) echo "Done\n";
3046
+		} elseif ($globalDebug) {
3047
+			echo "Done\n";
3048
+		}
2516 3049
 		return '';
2517 3050
 	}
2518 3051
 	public static function update_marine_identity_fam() {
@@ -2522,21 +3055,33 @@  discard block
 block discarded – undo
2522 3055
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2523 3056
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2524 3057
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2525
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3058
+				if ($globalDebug) {
3059
+					echo "Marine identity from FlightAirMap website : Download...";
3060
+				}
2526 3061
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2527 3062
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2528 3063
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2529
-						if ($globalDebug) echo "Gunzip...";
3064
+						if ($globalDebug) {
3065
+							echo "Gunzip...";
3066
+						}
2530 3067
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2531
-						if ($globalDebug) echo "Add to DB...";
3068
+						if ($globalDebug) {
3069
+							echo "Add to DB...";
3070
+						}
2532 3071
 						$error = update_db::marine_identity_fam();
2533
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2534
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3072
+					} else {
3073
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3074
+					}
3075
+				} else {
3076
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3077
+				}
2535 3078
 				if ($error != '') {
2536 3079
 					return $error;
2537 3080
 				} else {
2538 3081
 					update_db::insert_marine_identity_version($marine_identity_md5);
2539
-					if ($globalDebug) echo "Done\n";
3082
+					if ($globalDebug) {
3083
+						echo "Done\n";
3084
+					}
2540 3085
 				}
2541 3086
 			}
2542 3087
 		}
@@ -2550,21 +3095,33 @@  discard block
 block discarded – undo
2550 3095
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2551 3096
 			$satellite_md5 = $satellite_md5_file[0];
2552 3097
 			if (!update_db::check_satellite_version($satellite_md5)) {
2553
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3098
+				if ($globalDebug) {
3099
+					echo "Satellite from FlightAirMap website : Download...";
3100
+				}
2554 3101
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2555 3102
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2556 3103
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2557
-						if ($globalDebug) echo "Gunzip...";
3104
+						if ($globalDebug) {
3105
+							echo "Gunzip...";
3106
+						}
2558 3107
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2559
-						if ($globalDebug) echo "Add to DB...";
3108
+						if ($globalDebug) {
3109
+							echo "Add to DB...";
3110
+						}
2560 3111
 						$error = update_db::satellite_fam();
2561
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2562
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3112
+					} else {
3113
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3114
+					}
3115
+				} else {
3116
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3117
+				}
2563 3118
 				if ($error != '') {
2564 3119
 					return $error;
2565 3120
 				} else {
2566 3121
 					update_db::insert_satellite_version($satellite_md5);
2567
-					if ($globalDebug) echo "Done\n";
3122
+					if ($globalDebug) {
3123
+						echo "Done\n";
3124
+					}
2568 3125
 				}
2569 3126
 			}
2570 3127
 		}
@@ -2572,17 +3129,25 @@  discard block
 block discarded – undo
2572 3129
 	}
2573 3130
 	public static function update_banned_fam() {
2574 3131
 		global $tmp_dir, $globalDebug;
2575
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3132
+		if ($globalDebug) {
3133
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3134
+		}
2576 3135
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2577 3136
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2578 3137
 			//if ($globalDebug) echo "Gunzip...";
2579 3138
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2580
-			if ($globalDebug) echo "Add to DB...";
3139
+			if ($globalDebug) {
3140
+				echo "Add to DB...";
3141
+			}
2581 3142
 			$error = update_db::banned_fam();
2582
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3143
+		} else {
3144
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3145
+		}
2583 3146
 		if ($error != '') {
2584 3147
 			return $error;
2585
-		} elseif ($globalDebug) echo "Done\n";
3148
+		} elseif ($globalDebug) {
3149
+			echo "Done\n";
3150
+		}
2586 3151
 		return '';
2587 3152
 	}
2588 3153
 
@@ -2590,7 +3155,9 @@  discard block
 block discarded – undo
2590 3155
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2591 3156
 		include_once('class.create_db.php');
2592 3157
 		$error = '';
2593
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3158
+		if ($globalDebug) {
3159
+			echo "Airspace from FlightAirMap website : Download...";
3160
+		}
2594 3161
 		if ($globalDBdriver == 'mysql') {
2595 3162
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2596 3163
 		} else {
@@ -2607,9 +3174,13 @@  discard block
 block discarded – undo
2607 3174
 				}
2608 3175
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2609 3176
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2610
-						if ($globalDebug) echo "Gunzip...";
3177
+						if ($globalDebug) {
3178
+							echo "Gunzip...";
3179
+						}
2611 3180
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2612
-						if ($globalDebug) echo "Add to DB...";
3181
+						if ($globalDebug) {
3182
+							echo "Add to DB...";
3183
+						}
2613 3184
 						$Connection = new Connection();
2614 3185
 						if ($Connection->tableExists('airspace')) {
2615 3186
 							$query = 'DROP TABLE airspace';
@@ -2622,20 +3193,30 @@  discard block
 block discarded – undo
2622 3193
 						}
2623 3194
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2624 3195
 						update_db::insert_airspace_version($airspace_md5);
2625
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2626
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3196
+					} else {
3197
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3198
+					}
3199
+				} else {
3200
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3201
+				}
2627 3202
 			}
2628
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3203
+		} else {
3204
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3205
+		}
2629 3206
 		if ($error != '') {
2630 3207
 			return $error;
2631
-		} elseif ($globalDebug) echo "Done\n";
3208
+		} elseif ($globalDebug) {
3209
+			echo "Done\n";
3210
+		}
2632 3211
 		return '';
2633 3212
 	}
2634 3213
 
2635 3214
 	public static function update_geoid_fam() {
2636 3215
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2637 3216
 		$error = '';
2638
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3217
+		if ($globalDebug) {
3218
+			echo "Geoid from FlightAirMap website : Download...";
3219
+		}
2639 3220
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2640 3221
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2641 3222
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2644,76 +3225,116 @@  discard block
 block discarded – undo
2644 3225
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2645 3226
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2646 3227
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2647
-						if ($globalDebug) echo "Gunzip...";
3228
+						if ($globalDebug) {
3229
+							echo "Gunzip...";
3230
+						}
2648 3231
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2649 3232
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2650 3233
 							update_db::insert_geoid_version($geoid_md5);
2651 3234
 						}
2652
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2653
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3235
+					} else {
3236
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3237
+					}
3238
+				} else {
3239
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3240
+				}
2654 3241
 			}
2655
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3242
+		} else {
3243
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3244
+		}
2656 3245
 		if ($error != '') {
2657 3246
 			return $error;
2658
-		} elseif ($globalDebug) echo "Done\n";
3247
+		} elseif ($globalDebug) {
3248
+			echo "Done\n";
3249
+		}
2659 3250
 		return '';
2660 3251
 	}
2661 3252
 
2662 3253
 	public static function update_tle() {
2663 3254
 		global $tmp_dir, $globalDebug;
2664
-		if ($globalDebug) echo "Download TLE : Download...";
3255
+		if ($globalDebug) {
3256
+			echo "Download TLE : Download...";
3257
+		}
2665 3258
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2666 3259
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2667 3260
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2668 3261
 		foreach ($alltle as $filename) {
2669
-			if ($globalDebug) echo "downloading ".$filename.'...';
3262
+			if ($globalDebug) {
3263
+				echo "downloading ".$filename.'...';
3264
+			}
2670 3265
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2671 3266
 			if (file_exists($tmp_dir.$filename)) {
2672
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3267
+				if ($globalDebug) {
3268
+					echo "Add to DB ".$filename."...";
3269
+				}
2673 3270
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2674
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3271
+			} else {
3272
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3273
+			}
2675 3274
 			if ($error != '') {
2676 3275
 				echo $error."\n";
2677
-			} elseif ($globalDebug) echo "Done\n";
3276
+			} elseif ($globalDebug) {
3277
+				echo "Done\n";
3278
+			}
2678 3279
 		}
2679 3280
 		return '';
2680 3281
 	}
2681 3282
 
2682 3283
 	public static function update_ucsdb() {
2683 3284
 		global $tmp_dir, $globalDebug;
2684
-		if ($globalDebug) echo "Download UCS DB : Download...";
3285
+		if ($globalDebug) {
3286
+			echo "Download UCS DB : Download...";
3287
+		}
2685 3288
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2686 3289
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2687
-			if ($globalDebug) echo "Add to DB...";
3290
+			if ($globalDebug) {
3291
+				echo "Add to DB...";
3292
+			}
2688 3293
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2689
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3294
+		} else {
3295
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3296
+		}
2690 3297
 		if ($error != '') {
2691 3298
 			echo $error."\n";
2692
-		} elseif ($globalDebug) echo "Done\n";
3299
+		} elseif ($globalDebug) {
3300
+			echo "Done\n";
3301
+		}
2693 3302
 		return '';
2694 3303
 	}
2695 3304
 
2696 3305
 	public static function update_celestrak() {
2697 3306
 		global $tmp_dir, $globalDebug;
2698
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3307
+		if ($globalDebug) {
3308
+			echo "Download Celestrak DB : Download...";
3309
+		}
2699 3310
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2700 3311
 		if (file_exists($tmp_dir.'satcat.txt')) {
2701
-			if ($globalDebug) echo "Add to DB...";
3312
+			if ($globalDebug) {
3313
+				echo "Add to DB...";
3314
+			}
2702 3315
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2703
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3316
+		} else {
3317
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3318
+		}
2704 3319
 		if ($error != '') {
2705 3320
 			echo $error."\n";
2706
-		} elseif ($globalDebug) echo "Done\n";
3321
+		} elseif ($globalDebug) {
3322
+			echo "Done\n";
3323
+		}
2707 3324
 		return '';
2708 3325
 	}
2709 3326
 
2710 3327
 	public static function update_models() {
2711 3328
 		global $tmp_dir, $globalDebug;
2712 3329
 		$error = '';
2713
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3330
+		if ($globalDebug) {
3331
+			echo "Models from FlightAirMap website : Download...";
3332
+		}
2714 3333
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2715 3334
 		if (file_exists($tmp_dir.'models.md5sum')) {
2716
-			if ($globalDebug) echo "Check files...\n";
3335
+			if ($globalDebug) {
3336
+				echo "Check files...\n";
3337
+			}
2717 3338
 			$newmodelsdb = array();
2718 3339
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2719 3340
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2732,19 +3353,29 @@  discard block
 block discarded – undo
2732 3353
 			}
2733 3354
 			$diff = array_diff($newmodelsdb,$modelsdb);
2734 3355
 			foreach ($diff as $key => $value) {
2735
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3356
+				if ($globalDebug) {
3357
+					echo 'Downloading model '.$key.' ...'."\n";
3358
+				}
2736 3359
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2737 3360
 				
2738 3361
 			}
2739 3362
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2740
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3363
+		} else {
3364
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3365
+		}
2741 3366
 		if ($error != '') {
2742 3367
 			return $error;
2743
-		} elseif ($globalDebug) echo "Done\n";
2744
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3368
+		} elseif ($globalDebug) {
3369
+			echo "Done\n";
3370
+		}
3371
+		if ($globalDebug) {
3372
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3373
+		}
2745 3374
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2746 3375
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2747
-			if ($globalDebug) echo "Check files...\n";
3376
+			if ($globalDebug) {
3377
+				echo "Check files...\n";
3378
+			}
2748 3379
 			$newmodelsdb = array();
2749 3380
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2750 3381
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2763,25 +3394,35 @@  discard block
 block discarded – undo
2763 3394
 			}
2764 3395
 			$diff = array_diff($newmodelsdb,$modelsdb);
2765 3396
 			foreach ($diff as $key => $value) {
2766
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3397
+				if ($globalDebug) {
3398
+					echo 'Downloading model '.$key.' ...'."\n";
3399
+				}
2767 3400
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2768 3401
 				
2769 3402
 			}
2770 3403
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2771
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3404
+		} else {
3405
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3406
+		}
2772 3407
 		if ($error != '') {
2773 3408
 			return $error;
2774
-		} elseif ($globalDebug) echo "Done\n";
3409
+		} elseif ($globalDebug) {
3410
+			echo "Done\n";
3411
+		}
2775 3412
 		return '';
2776 3413
 	}
2777 3414
 
2778 3415
 	public static function update_liveries() {
2779 3416
 		global $tmp_dir, $globalDebug;
2780 3417
 		$error = '';
2781
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3418
+		if ($globalDebug) {
3419
+			echo "Liveries from FlightAirMap website : Download...";
3420
+		}
2782 3421
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2783 3422
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2784
-			if ($globalDebug) echo "Check files...\n";
3423
+			if ($globalDebug) {
3424
+				echo "Check files...\n";
3425
+			}
2785 3426
 			$newmodelsdb = array();
2786 3427
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2787 3428
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2800,25 +3441,35 @@  discard block
 block discarded – undo
2800 3441
 			}
2801 3442
 			$diff = array_diff($newmodelsdb,$modelsdb);
2802 3443
 			foreach ($diff as $key => $value) {
2803
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3444
+				if ($globalDebug) {
3445
+					echo 'Downloading liveries '.$key.' ...'."\n";
3446
+				}
2804 3447
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2805 3448
 				
2806 3449
 			}
2807 3450
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2808
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3451
+		} else {
3452
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3453
+		}
2809 3454
 		if ($error != '') {
2810 3455
 			return $error;
2811
-		} elseif ($globalDebug) echo "Done\n";
3456
+		} elseif ($globalDebug) {
3457
+			echo "Done\n";
3458
+		}
2812 3459
 		return '';
2813 3460
 	}
2814 3461
 
2815 3462
 	public static function update_space_models() {
2816 3463
 		global $tmp_dir, $globalDebug;
2817 3464
 		$error = '';
2818
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3465
+		if ($globalDebug) {
3466
+			echo "Space models from FlightAirMap website : Download...";
3467
+		}
2819 3468
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2820 3469
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2821
-			if ($globalDebug) echo "Check files...\n";
3470
+			if ($globalDebug) {
3471
+				echo "Check files...\n";
3472
+			}
2822 3473
 			$newmodelsdb = array();
2823 3474
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2824 3475
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2837,25 +3488,35 @@  discard block
 block discarded – undo
2837 3488
 			}
2838 3489
 			$diff = array_diff($newmodelsdb,$modelsdb);
2839 3490
 			foreach ($diff as $key => $value) {
2840
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3491
+				if ($globalDebug) {
3492
+					echo 'Downloading space model '.$key.' ...'."\n";
3493
+				}
2841 3494
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2842 3495
 				
2843 3496
 			}
2844 3497
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2845
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3498
+		} else {
3499
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3500
+		}
2846 3501
 		if ($error != '') {
2847 3502
 			return $error;
2848
-		} elseif ($globalDebug) echo "Done\n";
3503
+		} elseif ($globalDebug) {
3504
+			echo "Done\n";
3505
+		}
2849 3506
 		return '';
2850 3507
 	}
2851 3508
 
2852 3509
 	public static function update_vehicules_models() {
2853 3510
 		global $tmp_dir, $globalDebug;
2854 3511
 		$error = '';
2855
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3512
+		if ($globalDebug) {
3513
+			echo "Vehicules models from FlightAirMap website : Download...";
3514
+		}
2856 3515
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2857 3516
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2858
-			if ($globalDebug) echo "Check files...\n";
3517
+			if ($globalDebug) {
3518
+				echo "Check files...\n";
3519
+			}
2859 3520
 			$newmodelsdb = array();
2860 3521
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2861 3522
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2874,15 +3535,21 @@  discard block
 block discarded – undo
2874 3535
 			}
2875 3536
 			$diff = array_diff($newmodelsdb,$modelsdb);
2876 3537
 			foreach ($diff as $key => $value) {
2877
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3538
+				if ($globalDebug) {
3539
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3540
+				}
2878 3541
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2879 3542
 				
2880 3543
 			}
2881 3544
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2882
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3545
+		} else {
3546
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3547
+		}
2883 3548
 		if ($error != '') {
2884 3549
 			return $error;
2885
-		} elseif ($globalDebug) echo "Done\n";
3550
+		} elseif ($globalDebug) {
3551
+			echo "Done\n";
3552
+		}
2886 3553
 		return '';
2887 3554
 	}
2888 3555
 
@@ -2925,7 +3592,9 @@  discard block
 block discarded – undo
2925 3592
                 }
2926 3593
 
2927 3594
 		$error = '';
2928
-		if ($globalDebug) echo "Notam : Download...";
3595
+		if ($globalDebug) {
3596
+			echo "Notam : Download...";
3597
+		}
2929 3598
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2930 3599
 		if (file_exists($tmp_dir.'notam.rss')) {
2931 3600
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2940,14 +3609,30 @@  discard block
 block discarded – undo
2940 3609
 				$data['fir'] = $q[0];
2941 3610
 				$data['code'] = $q[1];
2942 3611
 				$ifrvfr = $q[2];
2943
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2944
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2945
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2946
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2947
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2948
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2949
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2950
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3612
+				if ($ifrvfr == 'IV') {
3613
+					$data['rules'] = 'IFR/VFR';
3614
+				}
3615
+				if ($ifrvfr == 'I') {
3616
+					$data['rules'] = 'IFR';
3617
+				}
3618
+				if ($ifrvfr == 'V') {
3619
+					$data['rules'] = 'VFR';
3620
+				}
3621
+				if ($q[4] == 'A') {
3622
+					$data['scope'] = 'Airport warning';
3623
+				}
3624
+				if ($q[4] == 'E') {
3625
+					$data['scope'] = 'Enroute warning';
3626
+				}
3627
+				if ($q[4] == 'W') {
3628
+					$data['scope'] = 'Navigation warning';
3629
+				}
3630
+				if ($q[4] == 'AE') {
3631
+					$data['scope'] = 'Airport/Enroute warning';
3632
+				}
3633
+				if ($q[4] == 'AW') {
3634
+					$data['scope'] = 'Airport/Navigation warning';
3635
+				}
2951 3636
 				//$data['scope'] = $q[4];
2952 3637
 				$data['lower_limit'] = $q[5];
2953 3638
 				$data['upper_limit'] = $q[6];
@@ -2955,8 +3640,12 @@  discard block
 block discarded – undo
2955 3640
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2956 3641
 				$latitude = $Common->convertDec($las,'latitude');
2957 3642
 				$longitude = $Common->convertDec($lns,'longitude');
2958
-				if ($lac == 'S') $latitude = '-'.$latitude;
2959
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3643
+				if ($lac == 'S') {
3644
+					$latitude = '-'.$latitude;
3645
+				}
3646
+				if ($lnc == 'W') {
3647
+					$longitude = '-'.$longitude;
3648
+				}
2960 3649
 				$data['center_latitude'] = $latitude;
2961 3650
 				$data['center_longitude'] = $longitude;
2962 3651
 				$data['radius'] = intval($radius);
@@ -2986,10 +3675,14 @@  discard block
 block discarded – undo
2986 3675
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2987 3676
 				unset($data);
2988 3677
 			} 
2989
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3678
+		} else {
3679
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3680
+		}
2990 3681
 		if ($error != '') {
2991 3682
 			return $error;
2992
-		} elseif ($globalDebug) echo "Done\n";
3683
+		} elseif ($globalDebug) {
3684
+			echo "Done\n";
3685
+		}
2993 3686
 		return '';
2994 3687
 	}
2995 3688
 	
@@ -3014,7 +3707,9 @@  discard block
 block discarded – undo
3014 3707
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3015 3708
 		$airspace_json = json_decode($airspace_lst,true);
3016 3709
 		foreach ($airspace_json['records'] as $airspace) {
3017
-			if ($globalDebug) echo $airspace['name']."...\n";
3710
+			if ($globalDebug) {
3711
+				echo $airspace['name']."...\n";
3712
+			}
3018 3713
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3019 3714
 			if (file_exists($tmp_dir.$airspace['name'])) {
3020 3715
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3058,8 +3753,11 @@  discard block
 block discarded – undo
3058 3753
                         return "error : ".$e->getMessage();
3059 3754
                 }
3060 3755
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3061
-                if ($row['nb'] > 0) return false;
3062
-                else return true;
3756
+                if ($row['nb'] > 0) {
3757
+                	return false;
3758
+                } else {
3759
+                	return true;
3760
+                }
3063 3761
 	}
3064 3762
 
3065 3763
 	public static function insert_last_update() {
@@ -3084,8 +3782,11 @@  discard block
 block discarded – undo
3084 3782
                         return "error : ".$e->getMessage();
3085 3783
                 }
3086 3784
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3087
-                if ($row['nb'] > 0) return true;
3088
-                else return false;
3785
+                if ($row['nb'] > 0) {
3786
+                	return true;
3787
+                } else {
3788
+                	return false;
3789
+                }
3089 3790
 	}
3090 3791
 
3091 3792
 	public static function check_geoid_version($version) {
@@ -3098,8 +3799,11 @@  discard block
 block discarded – undo
3098 3799
                         return "error : ".$e->getMessage();
3099 3800
                 }
3100 3801
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3101
-                if ($row['nb'] > 0) return true;
3102
-                else return false;
3802
+                if ($row['nb'] > 0) {
3803
+                	return true;
3804
+                } else {
3805
+                	return false;
3806
+                }
3103 3807
 	}
3104 3808
 
3105 3809
 	public static function check_marine_identity_version($version) {
@@ -3112,8 +3816,11 @@  discard block
 block discarded – undo
3112 3816
 			return "error : ".$e->getMessage();
3113 3817
 		}
3114 3818
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3115
-		if ($row['nb'] > 0) return true;
3116
-		else return false;
3819
+		if ($row['nb'] > 0) {
3820
+			return true;
3821
+		} else {
3822
+			return false;
3823
+		}
3117 3824
 	}
3118 3825
 
3119 3826
 	public static function check_satellite_version($version) {
@@ -3126,8 +3833,11 @@  discard block
 block discarded – undo
3126 3833
 			return "error : ".$e->getMessage();
3127 3834
 		}
3128 3835
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3129
-		if ($row['nb'] > 0) return true;
3130
-		else return false;
3836
+		if ($row['nb'] > 0) {
3837
+			return true;
3838
+		} else {
3839
+			return false;
3840
+		}
3131 3841
 	}
3132 3842
 
3133 3843
 	public static function check_airlines_version($version) {
@@ -3140,8 +3850,11 @@  discard block
 block discarded – undo
3140 3850
 			return "error : ".$e->getMessage();
3141 3851
 		}
3142 3852
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3143
-		if ($row['nb'] > 0) return true;
3144
-		else return false;
3853
+		if ($row['nb'] > 0) {
3854
+			return true;
3855
+		} else {
3856
+			return false;
3857
+		}
3145 3858
 	}
3146 3859
 
3147 3860
 	public static function check_notam_version($version) {
@@ -3154,8 +3867,11 @@  discard block
 block discarded – undo
3154 3867
 			return "error : ".$e->getMessage();
3155 3868
 		}
3156 3869
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3157
-		if ($row['nb'] > 0) return true;
3158
-		else return false;
3870
+		if ($row['nb'] > 0) {
3871
+			return true;
3872
+		} else {
3873
+			return false;
3874
+		}
3159 3875
 	}
3160 3876
 
3161 3877
 	public static function insert_airlines_version($version) {
@@ -3245,8 +3961,11 @@  discard block
 block discarded – undo
3245 3961
                         return "error : ".$e->getMessage();
3246 3962
                 }
3247 3963
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3248
-                if ($row['nb'] > 0) return false;
3249
-                else return true;
3964
+                if ($row['nb'] > 0) {
3965
+                	return false;
3966
+                } else {
3967
+                	return true;
3968
+                }
3250 3969
 	}
3251 3970
 
3252 3971
 	public static function insert_last_notam_update() {
@@ -3276,8 +3995,11 @@  discard block
 block discarded – undo
3276 3995
                         return "error : ".$e->getMessage();
3277 3996
                 }
3278 3997
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3279
-                if ($row['nb'] > 0) return false;
3280
-                else return true;
3998
+                if ($row['nb'] > 0) {
3999
+                	return false;
4000
+                } else {
4001
+                	return true;
4002
+                }
3281 4003
 	}
3282 4004
 
3283 4005
 	public static function insert_last_airspace_update() {
@@ -3307,8 +4029,11 @@  discard block
 block discarded – undo
3307 4029
                         return "error : ".$e->getMessage();
3308 4030
                 }
3309 4031
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3310
-                if ($row['nb'] > 0) return false;
3311
-                else return true;
4032
+                if ($row['nb'] > 0) {
4033
+                	return false;
4034
+                } else {
4035
+                	return true;
4036
+                }
3312 4037
 	}
3313 4038
 
3314 4039
 	public static function insert_last_geoid_update() {
@@ -3338,8 +4063,11 @@  discard block
 block discarded – undo
3338 4063
 			return "error : ".$e->getMessage();
3339 4064
 		}
3340 4065
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3341
-		if ($row['nb'] > 0) return false;
3342
-		else return true;
4066
+		if ($row['nb'] > 0) {
4067
+			return false;
4068
+		} else {
4069
+			return true;
4070
+		}
3343 4071
 	}
3344 4072
 
3345 4073
 	public static function insert_last_owner_update() {
@@ -3369,8 +4097,11 @@  discard block
 block discarded – undo
3369 4097
 			return "error : ".$e->getMessage();
3370 4098
 		}
3371 4099
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3372
-		if ($row['nb'] > 0) return false;
3373
-		else return true;
4100
+		if ($row['nb'] > 0) {
4101
+			return false;
4102
+		} else {
4103
+			return true;
4104
+		}
3374 4105
 	}
3375 4106
 
3376 4107
 	public static function insert_last_fires_update() {
@@ -3400,8 +4131,11 @@  discard block
 block discarded – undo
3400 4131
 			return "error : ".$e->getMessage();
3401 4132
 		}
3402 4133
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3403
-		if ($row['nb'] > 0) return false;
3404
-		else return true;
4134
+		if ($row['nb'] > 0) {
4135
+			return false;
4136
+		} else {
4137
+			return true;
4138
+		}
3405 4139
 	}
3406 4140
 
3407 4141
 	public static function insert_last_airlines_update() {
@@ -3431,8 +4165,11 @@  discard block
 block discarded – undo
3431 4165
                         return "error : ".$e->getMessage();
3432 4166
                 }
3433 4167
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3434
-                if ($row['nb'] > 0) return false;
3435
-                else return true;
4168
+                if ($row['nb'] > 0) {
4169
+                	return false;
4170
+                } else {
4171
+                	return true;
4172
+                }
3436 4173
 	}
3437 4174
 
3438 4175
 	public static function insert_last_schedules_update() {
@@ -3462,8 +4199,11 @@  discard block
 block discarded – undo
3462 4199
 			return "error : ".$e->getMessage();
3463 4200
 		}
3464 4201
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3465
-		if ($row['nb'] > 0) return false;
3466
-		else return true;
4202
+		if ($row['nb'] > 0) {
4203
+			return false;
4204
+		} else {
4205
+			return true;
4206
+		}
3467 4207
 	}
3468 4208
 
3469 4209
 	public static function insert_last_tle_update() {
@@ -3493,8 +4233,11 @@  discard block
 block discarded – undo
3493 4233
 			return "error : ".$e->getMessage();
3494 4234
 		}
3495 4235
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3496
-		if ($row['nb'] > 0) return false;
3497
-		else return true;
4236
+		if ($row['nb'] > 0) {
4237
+			return false;
4238
+		} else {
4239
+			return true;
4240
+		}
3498 4241
 	}
3499 4242
 
3500 4243
 	public static function insert_last_ucsdb_update() {
@@ -3524,8 +4267,11 @@  discard block
 block discarded – undo
3524 4267
 			return "error : ".$e->getMessage();
3525 4268
 		}
3526 4269
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3527
-		if ($row['nb'] > 0) return false;
3528
-		else return true;
4270
+		if ($row['nb'] > 0) {
4271
+			return false;
4272
+		} else {
4273
+			return true;
4274
+		}
3529 4275
 	}
3530 4276
 
3531 4277
 	public static function insert_last_celestrak_update() {
@@ -3555,8 +4301,11 @@  discard block
 block discarded – undo
3555 4301
 			return "error : ".$e->getMessage();
3556 4302
 		}
3557 4303
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3558
-		if ($row['nb'] > 0) return false;
3559
-		else return true;
4304
+		if ($row['nb'] > 0) {
4305
+			return false;
4306
+		} else {
4307
+			return true;
4308
+		}
3560 4309
 	}
3561 4310
 
3562 4311
 	public static function check_last_satellite_update() {
@@ -3574,8 +4323,11 @@  discard block
 block discarded – undo
3574 4323
 			return "error : ".$e->getMessage();
3575 4324
 		}
3576 4325
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3577
-		if ($row['nb'] > 0) return false;
3578
-		else return true;
4326
+		if ($row['nb'] > 0) {
4327
+			return false;
4328
+		} else {
4329
+			return true;
4330
+		}
3579 4331
 	}
3580 4332
 
3581 4333
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +401 added lines, -143 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,17 +108,25 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116 132
        }
@@ -132,14 +148,18 @@  discard block
 block discarded – undo
132 148
 
133 149
     public function checkAll() {
134 150
 	global $globalDebug, $globalNoImport;
135
-	if ($globalDebug) echo "Update last seen flights data...\n";
151
+	if ($globalDebug) {
152
+		echo "Update last seen flights data...\n";
153
+	}
136 154
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137 155
 	    foreach ($this->all_flights as $key => $flight) {
138 156
 		if (isset($this->all_flights[$key]['id'])) {
139 157
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 158
     		    $Spotter = new Spotter($this->db);
141 159
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
160
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
161
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
162
+        	    }
143 163
         	}
144 164
 	    }
145 165
 	}
@@ -147,24 +167,32 @@  discard block
 block discarded – undo
147 167
 
148 168
     public function arrival($key) {
149 169
 	global $globalClosestMinDist, $globalDebug;
150
-	if ($globalDebug) echo 'Update arrival...'."\n";
170
+	if ($globalDebug) {
171
+		echo 'Update arrival...'."\n";
172
+	}
151 173
 	$Spotter = new Spotter($this->db);
152 174
         $airport_icao = '';
153 175
         $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
176
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
177
+        	$globalClosestMinDist = 50;
178
+        }
155 179
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156 180
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157 181
     	    if (isset($closestAirports[0])) {
158 182
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 183
         	    $airport_icao = $closestAirports[0]['icao'];
160 184
         	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        	    if ($globalDebug) {
186
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
187
+        	    }
162 188
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163 189
         	    foreach ($closestAirports as $airport) {
164 190
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165 191
         		    $airport_icao = $airport['icao'];
166 192
         		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
193
+        		    if ($globalDebug) {
194
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        		    }
168 196
         		    break;
169 197
         		}
170 198
         	    }
@@ -172,14 +200,20 @@  discard block
 block discarded – undo
172 200
         		$airport_icao = $closestAirports[0]['icao'];
173 201
         		$airport_time = $this->all_flights[$key]['datetime'];
174 202
         	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
203
+        		if ($globalDebug) {
204
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
205
+        		}
176 206
         	}
177 207
     	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
208
+    		    if ($globalDebug) {
209
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
210
+    		    }
179 211
     	    }
180 212
 
181 213
         } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
214
+        	if ($globalDebug) {
215
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
216
+        	}
183 217
         }
184 218
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185 219
     }
@@ -189,7 +223,9 @@  discard block
 block discarded – undo
189 223
     public function del() {
190 224
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 225
 	// Delete old infos
192
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
226
+	if ($globalDebug) {
227
+		echo 'Delete old values and update latest data...'."\n";
228
+	}
193 229
 	foreach ($this->all_flights as $key => $flight) {
194 230
 	    if (isset($flight['lastupdate'])) {
195 231
 		if ($flight['lastupdate'] < (time()-1800)) {
@@ -203,13 +239,17 @@  discard block
 block discarded – undo
203 239
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 240
 	// Delete old infos
205 241
 	if (isset($this->all_flights[$key]['id'])) {
206
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
242
+		if ($globalDebug) {
243
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
244
+		}
207 245
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
208 246
 			$real_arrival = $this->arrival($key);
209 247
 			$Spotter = new Spotter($this->db);
210 248
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211 249
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
212
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250
+				if ($globalDebug && $result != 'success') {
251
+					echo '!!! ERROR : '.$result."\n";
252
+				}
213 253
 			}
214 254
 		}
215 255
 	}
@@ -219,9 +259,13 @@  discard block
 block discarded – undo
219 259
     public function add($line) {
220 260
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
221 261
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
223
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
224
-/*
262
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
263
+		$globalCoordMinChange = '0.01';
264
+	}
265
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
266
+		$globalAircraftMaxUpdate = 3000;
267
+	}
268
+	/*
225 269
 	$Spotter = new Spotter();
226 270
 	$dbc = $Spotter->db;
227 271
 	$SpotterLive = new SpotterLive($dbc);
@@ -243,19 +287,28 @@  discard block
 block discarded – undo
243 287
 	// SBS format is CSV format
244 288
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 289
 	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
290
+	    if (isset($line['hex'])) {
291
+	    	$line['hex'] = strtoupper($line['hex']);
292
+	    }
247 293
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 294
 
249 295
 		// Increment message number
250 296
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251 297
 		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
298
+		    if (isset($line['source_name'])) {
299
+		    	$source = $line['source_name'];
300
+		    } else {
301
+		    	$source = '';
302
+		    }
303
+		    if ($source == '' || $line['format_source'] == 'aprs') {
304
+		    	$source = $line['format_source'];
305
+		    }
255 306
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256 307
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257 308
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
309
+		    } else {
310
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
311
+		    }
259 312
 		}
260 313
 		
261 314
 		/*
@@ -271,23 +324,38 @@  discard block
 block discarded – undo
271 324
 		//$this->db = $dbc;
272 325
 
273 326
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
327
+	        if (!isset($line['id'])) {
328
+	        	$id = trim($line['hex']);
329
+	        } else {
330
+	        	$id = trim($line['id']);
331
+	        }
276 332
 		
277 333
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
334
+		    if ($globalDebug) {
335
+		    	echo 'New flight...'."\n";
336
+		    }
279 337
 		    $this->all_flights[$id] = array();
280 338
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
340
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
341
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
342
+		    }
283 343
 		    if (!isset($line['id'])) {
284
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
344
+			if (!isset($globalDaemon)) {
345
+				$globalDaemon = TRUE;
346
+			}
347
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
286 348
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
287
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
349
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
350
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
351
+			}
288 352
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
353
+		     } else {
354
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
355
+		     }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
291 359
 		}
292 360
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -309,12 +377,20 @@  discard block
 block discarded – undo
309 377
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 378
 			    }
311 379
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
380
+			    if ($globalDebugTimeElapsed) {
381
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+			    }
383
+			    if ($aircraft_icao != '') {
384
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
385
+			    }
314 386
 			}
315 387
 		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
388
+		    if ($globalAllFlights !== FALSE) {
389
+		    	$dataFound = true;
390
+		    }
391
+		    if ($globalDebug) {
392
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
393
+		    }
318 394
 		}
319 395
 	        if (isset($line['id']) && !isset($line['hex'])) {
320 396
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -323,7 +399,9 @@  discard block
 block discarded – undo
323 399
 			$icao = $line['aircraft_icao'];
324 400
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
325 401
 				$Spotter = new Spotter($this->db);
326
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
402
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
403
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
404
+				}
327 405
 				$Spotter->db = null;
328 406
 			}
329 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -333,15 +411,24 @@  discard block
 block discarded – undo
333 411
 				$Spotter = new Spotter($this->db);
334 412
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
335 413
 				$Spotter->db = null;
336
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
414
+				if ($aircraft_icao != '') {
415
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
416
+				}
337 417
 			}
338 418
 		}
339 419
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
340
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
341
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
342
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
343
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
344
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
420
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
421
+				$aircraft_icao = 'GLID';
422
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
423
+				$aircraft_icao = 'UHEL';
424
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
425
+				$aircraft_icao = 'TOWPLANE';
426
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
427
+				$aircraft_icao = 'POWAIRC';
428
+			}
429
+			if (isset($aircraft_icao)) {
430
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
431
+			}
345 432
 		}
346 433
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
347 434
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -351,8 +438,11 @@  discard block
 block discarded – undo
351 438
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
352 439
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
353 440
 		    } else {
354
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
355
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
441
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
442
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
443
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
444
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
445
+				}
356 446
 				/*
357 447
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
358 448
 				print_r($this->all_flights[$id]);
@@ -361,16 +451,22 @@  discard block
 block discarded – undo
361 451
 				return '';
362 452
 		    }
363 453
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
364
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
454
+			if ($globalDebug) {
455
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
456
+			}
365 457
 			return '';
366 458
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
367
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
459
+			if ($globalDebug) {
460
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
461
+			}
368 462
 			return '';
369 463
 		} elseif (!isset($line['datetime'])) {
370 464
 			date_default_timezone_set('UTC');
371 465
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
372 466
 		} else {
373
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
467
+			if ($globalDebug) {
468
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
469
+			}
374 470
 			return '';
375 471
 		}
376 472
 
@@ -391,30 +487,48 @@  discard block
 block discarded – undo
391 487
 
392 488
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
393 489
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
394
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
490
+				if ($globalDebug) {
491
+					echo '---!!!! New ident, reset aircraft data...'."\n";
492
+				}
395 493
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
396 494
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
397
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
398
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
399
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
495
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
496
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
497
+				} elseif (isset($line['id'])) {
498
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
499
+				} elseif (isset($this->all_flights[$id]['ident'])) {
500
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
501
+				}
400 502
 			} else {
401 503
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
402 504
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 505
 				$timeelapsed = microtime(true);
404 506
             			$Spotter = new Spotter($this->db);
405 507
             			$fromsource = NULL;
406
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
407
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
408
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
409
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
410
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
508
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
509
+            				$fromsource = $globalAirlinesSource;
510
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
511
+            				$fromsource = 'vatsim';
512
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
513
+					$fromsource = 'ivao';
514
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
515
+					$fromsource = 'vatsim';
516
+				} elseif (isset($globalIVAO) && $globalIVAO) {
517
+					$fromsource = 'ivao';
518
+				}
411 519
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
412
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
520
+				if ($globalDebug && $result != 'success') {
521
+					echo '!!! ERROR : '.$result."\n";
522
+				}
413 523
 				$Spotter->db = null;
414
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
524
+				if ($globalDebugTimeElapsed) {
525
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
526
+				}
415 527
 			    }
416 528
 			}
417
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
529
+		    } else {
530
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
531
+		    }
418 532
 		    
419 533
 /*
420 534
 		    if (!isset($line['id'])) {
@@ -424,7 +538,9 @@  discard block
 block discarded – undo
424 538
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
425 539
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
426 540
   */
427
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
541
+		    if (!isset($this->all_flights[$id]['id'])) {
542
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
543
+		    }
428 544
 
429 545
 		    //$putinarchive = true;
430 546
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -442,7 +558,9 @@  discard block
 block discarded – undo
442 558
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
443 559
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
444 560
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
445
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
561
+				if ($globalDebugTimeElapsed) {
562
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
563
+				}
446 564
                         }
447 565
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
448 566
 			$timeelapsed = microtime(true);
@@ -456,7 +574,9 @@  discard block
 block discarded – undo
456 574
 				$Translation->db = null;
457 575
 			    }
458 576
 			    $Spotter->db = null;
459
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
577
+			    if ($globalDebugTimeElapsed) {
578
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
579
+			    }
460 580
                     	}
461 581
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
462 582
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -465,9 +585,13 @@  discard block
 block discarded – undo
465 585
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
466 586
 		    	    }
467 587
 			}
468
-			if (!isset($globalFork)) $globalFork = TRUE;
588
+			if (!isset($globalFork)) {
589
+				$globalFork = TRUE;
590
+			}
469 591
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
470
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
592
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
593
+					$this->get_Schedule($id,trim($line['ident']));
594
+				}
471 595
 			}
472 596
 		    }
473 597
 		}
@@ -485,9 +609,13 @@  discard block
 block discarded – undo
485 609
 			$speed = $speed*3.6;
486 610
 			if ($speed < 1000) {
487 611
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
488
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
612
+	  			if ($globalDebug) {
613
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
614
+	  			}
489 615
 	  		} else {
490
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
616
+	  			if ($globalDebug) {
617
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
618
+	  			}
491 619
 	  		}
492 620
 		    }
493 621
 		}
@@ -496,13 +624,21 @@  discard block
 block discarded – undo
496 624
 
497 625
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
498 626
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
499
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
627
+	    	    	if ($globalDebug) {
628
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
629
+	    	    	}
500 630
 	    	    	return false;
501 631
 	    	    }
502
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
503
-	    	    else unset($timediff);
504
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
505
-	    	    else unset($timediff_archive);
632
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
633
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
634
+	    	    } else {
635
+	    	    	unset($timediff);
636
+	    	    }
637
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
638
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
639
+	    	    } else {
640
+	    	    	unset($timediff_archive);
641
+	    	    }
506 642
 	    	    if ($this->tmd > 5
507 643
 	    	        || (isset($line['format_source']) 
508 644
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -539,16 +675,25 @@  discard block
 block discarded – undo
539 675
 				$this->all_flights[$id]['putinarchive'] = true;
540 676
 				$this->tmd = 0;
541 677
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
542
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
678
+				    if ($globalDebug) {
679
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
680
+				    }
543 681
 				    $timeelapsed = microtime(true);
544 682
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
545 683
 					$Spotter = new Spotter($this->db);
546 684
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
547
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
548
-					else $this->all_flights[$id]['over_country'] = '';
685
+					if (!empty($all_country)) {
686
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
687
+					} else {
688
+						$this->all_flights[$id]['over_country'] = '';
689
+					}
549 690
 					$Spotter->db = null;
550
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
691
+					if ($globalDebugTimeElapsed) {
692
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
693
+					}
694
+					if ($globalDebug) {
695
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
696
+					}
552 697
 				    }
553 698
 				}
554 699
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -594,7 +739,9 @@  discard block
 block discarded – undo
594 739
 			    */
595 740
 			}
596 741
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
597
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
742
+			    if ($line['longitude'] > 180) {
743
+			    	$line['longitude'] = $line['longitude'] - 360;
744
+			    }
598 745
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
599 746
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
600 747
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -631,7 +778,9 @@  discard block
 block discarded – undo
631 778
 		    }
632 779
 		}
633 780
 		if (isset($line['last_update']) && $line['last_update'] != '') {
634
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
781
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
782
+		    	$dataFound = true;
783
+		    }
635 784
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
636 785
 		}
637 786
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -653,35 +802,53 @@  discard block
 block discarded – undo
653 802
 			// Here we force archive of flight because after ground it's a new one (or should be)
654 803
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
655 804
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
656
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
657
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
805
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
806
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
807
+			} elseif (isset($line['id'])) {
808
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
809
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
810
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
811
+			}
812
+		    }
813
+		    if ($line['ground'] != 1) {
814
+		    	$line['ground'] = 0;
659 815
 		    }
660
-		    if ($line['ground'] != 1) $line['ground'] = 0;
661 816
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
662 817
 		    //$dataFound = true;
663 818
 		}
664 819
 		if (isset($line['squawk']) && $line['squawk'] != '') {
665 820
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
666
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
821
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
822
+			    	$this->all_flights[$id]['putinarchive'] = true;
823
+			    }
667 824
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
668 825
 			    $highlight = '';
669
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
670
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
826
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
827
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
828
+			    }
829
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
830
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
831
+			    }
832
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
833
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
834
+			    }
672 835
 			    if ($highlight != '') {
673 836
 				$timeelapsed = microtime(true);
674 837
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
675 838
 				    $Spotter = new Spotter($this->db);
676 839
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
677 840
 				    $Spotter->db = null;
678
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
841
+				    if ($globalDebugTimeElapsed) {
842
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
843
+				    }
679 844
 				}
680 845
 				//$putinarchive = true;
681 846
 				//$highlight = '';
682 847
 			    }
683 848
 			    
684
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
849
+		    } else {
850
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
851
+		    }
685 852
 		    //$dataFound = true;
686 853
 		}
687 854
 
@@ -694,19 +861,27 @@  discard block
 block discarded – undo
694 861
 				}
695 862
 			}
696 863
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
864
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
865
+				$this->all_flights[$id]['putinarchive'] = true;
866
+			}
698 867
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
699 868
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
700 869
 			//$dataFound = true;
701 870
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
702 871
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
703 872
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
704
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
873
+				if ($globalDebug) {
874
+					echo '--- Reset because of altitude'."\n";
875
+				}
705 876
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
706 877
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
707
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
708
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
709
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
878
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
879
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
880
+				} elseif (isset($line['id'])) {
881
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
882
+				} elseif (isset($this->all_flights[$id]['ident'])) {
883
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
884
+				}
710 885
 			}
711 886
 		    }
712 887
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -717,22 +892,32 @@  discard block
 block discarded – undo
717 892
 		}
718 893
 		
719 894
 		if (isset($line['heading']) && $line['heading'] != '') {
720
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
895
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
896
+		    	$this->all_flights[$id]['putinarchive'] = true;
897
+		    }
721 898
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
722 899
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
723 900
 		    //$dataFound = true;
724 901
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
725 902
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
726 903
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
727
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
728
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
904
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
905
+		    	$this->all_flights[$id]['putinarchive'] = true;
906
+		    }
907
+  		    if ($globalDebug) {
908
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
909
+  		    }
729 910
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
730 911
   		    // If not enough messages and ACARS set heading to 0
731 912
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
732 913
   		}
733
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
914
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
915
+			$dataFound = false;
916
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
917
+			$dataFound = false;
918
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
919
+			$dataFound = false;
920
+		}
736 921
 
737 922
 //		print_r($this->all_flights[$id]);
738 923
 		//gets the callsign from the last hour
@@ -749,23 +934,38 @@  discard block
 block discarded – undo
749 934
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
750 935
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
751 936
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
752
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
937
+				    if ($globalDebug) {
938
+				    	echo "Check if aircraft is already in DB...";
939
+				    }
753 940
 				    $timeelapsed = microtime(true);
754 941
 				    $SpotterLive = new SpotterLive($this->db);
755 942
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
756 943
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
757
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
944
+					if ($globalDebugTimeElapsed) {
945
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
946
+					}
758 947
 				    } elseif (isset($line['id'])) {
759 948
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
760
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					if ($globalDebugTimeElapsed) {
950
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
951
+					}
761 952
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762 953
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
763
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
764
-				    } else $recent_ident = '';
954
+					if ($globalDebugTimeElapsed) {
955
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
956
+					}
957
+				    } else {
958
+				    	$recent_ident = '';
959
+				    }
765 960
 				    $SpotterLive->db=null;
766
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
767
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
768
-				} else $recent_ident = '';
961
+				    if ($globalDebug && $recent_ident == '') {
962
+				    	echo " Not in DB.\n";
963
+				    } elseif ($globalDebug && $recent_ident != '') {
964
+				    	echo " Already in DB.\n";
965
+				    }
966
+				} else {
967
+					$recent_ident = '';
968
+				}
769 969
 			    } else {
770 970
 				$recent_ident = '';
771 971
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -773,7 +973,9 @@  discard block
 block discarded – undo
773 973
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
774 974
 			    if($recent_ident == "")
775 975
 			    {
776
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
976
+				if ($globalDebug) {
977
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
978
+				}
777 979
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
778 980
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
779 981
 				//adds the spotter data for the archive
@@ -817,31 +1019,49 @@  discard block
 block discarded – undo
817 1019
 				
818 1020
 				if (!$ignoreImport) {
819 1021
 				    $highlight = '';
820
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
821
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
822
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
823
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1022
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1023
+				    	$highlight = 'Squawk 7500 : Hijack';
1024
+				    }
1025
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1026
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1027
+				    }
1028
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1029
+				    	$highlight = 'Squawk 7700 : Emergency';
1030
+				    }
1031
+				    if (!isset($this->all_flights[$id]['id'])) {
1032
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1033
+				    }
824 1034
 				    $timeelapsed = microtime(true);
825 1035
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826 1036
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
827 1037
 					    $Spotter = new Spotter($this->db);
828 1038
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
829 1039
 					    $Spotter->db = null;
830
-					    if ($globalDebug && isset($result)) echo $result."\n";
1040
+					    if ($globalDebug && isset($result)) {
1041
+					    	echo $result."\n";
1042
+					    }
831 1043
 					}
832 1044
 				    }
833
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1045
+				    if ($globalDebugTimeElapsed) {
1046
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1047
+				    }
834 1048
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
835 1049
 
836 1050
 				    // Add source stat in DB
837 1051
 				    $Stats = new Stats($this->db);
838 1052
 				    if (!empty($this->stats)) {
839
-					if ($globalDebug) echo 'Add source stats : ';
1053
+					if ($globalDebug) {
1054
+						echo 'Add source stats : ';
1055
+					}
840 1056
 				        foreach($this->stats as $date => $data) {
841 1057
 					    foreach($data as $source => $sourced) {
842 1058
 					        //print_r($sourced);
843
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
844
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1059
+				    	        if (isset($sourced['polar'])) {
1060
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1061
+				    	        }
1062
+				    	        if (isset($sourced['hist'])) {
1063
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1064
+				    	        }
845 1065
 				    		if (isset($sourced['msg'])) {
846 1066
 				    		    if (time() - $sourced['msg']['date'] > 10) {
847 1067
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -854,13 +1074,17 @@  discard block
 block discarded – undo
854 1074
 			    			unset($this->stats[$date]);
855 1075
 			    		    }
856 1076
 				    	}
857
-				    	if ($globalDebug) echo 'Done'."\n";
1077
+				    	if ($globalDebug) {
1078
+				    		echo 'Done'."\n";
1079
+				    	}
858 1080
 
859 1081
 				    }
860 1082
 				    $Stats->db = null;
861 1083
 				    }
862 1084
 				    $this->del();
863
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1085
+				} elseif ($globalDebug) {
1086
+					echo 'Ignore data'."\n";
1087
+				}
864 1088
 				//$ignoreImport = false;
865 1089
 				$this->all_flights[$id]['addedSpotter'] = 1;
866 1090
 				//print_r($this->all_flights[$id]);
@@ -877,7 +1101,9 @@  discard block
 block discarded – undo
877 1101
 			*/
878 1102
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
879 1103
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
880
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1104
+				    if ($globalDebug) {
1105
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1106
+				    }
881 1107
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
882 1108
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
883 1109
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -886,7 +1112,9 @@  discard block
 block discarded – undo
886 1112
 					    $SpotterLive->db=null;
887 1113
 					}
888 1114
 				    }
889
-				    if ($globalDebug) echo " Done\n";
1115
+				    if ($globalDebug) {
1116
+				    	echo " Done\n";
1117
+				    }
890 1118
 				    $this->last_delete = time();
891 1119
 				}
892 1120
 			    } else {
@@ -913,11 +1141,17 @@  discard block
 block discarded – undo
913 1141
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
914 1142
 		    if ($globalDebug) {
915 1143
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
916
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
917
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1144
+				if (isset($this->all_flights[$id]['source_name'])) {
1145
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1146
+				} else {
1147
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1148
+				}
918 1149
 			} else {
919
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
920
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1150
+				if (isset($this->all_flights[$id]['source_name'])) {
1151
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1152
+				} else {
1153
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1154
+				}
921 1155
 			}
922 1156
 		    }
923 1157
 		    $ignoreImport = false;
@@ -963,22 +1197,30 @@  discard block
 block discarded – undo
963 1197
 
964 1198
 		    if (!$ignoreImport) {
965 1199
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
966
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1200
+				if (!isset($this->all_flights[$id]['id'])) {
1201
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1202
+				}
967 1203
 				$timeelapsed = microtime(true);
968 1204
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
969 1205
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1206
+					if ($globalDebug) {
1207
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1208
+					}
971 1209
 					$SpotterLive = new SpotterLive($this->db);
972 1210
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
973 1211
 					$SpotterLive->db = null;
974
-					if ($globalDebug) echo $result."\n";
1212
+					if ($globalDebug) {
1213
+						echo $result."\n";
1214
+					}
975 1215
 				    }
976 1216
 				}
977 1217
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
978 1218
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
979 1219
 				}
980 1220
 				$this->all_flights[$id]['putinarchive'] = false;
981
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1221
+				if ($globalDebugTimeElapsed) {
1222
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1223
+				}
982 1224
 
983 1225
 				// Put statistics in $this->stats variable
984 1226
 				//if ($line['format_source'] != 'aprs') {
@@ -986,7 +1228,9 @@  discard block
 block discarded – undo
986 1228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 1229
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
988 1230
 					$source = $this->all_flights[$id]['source_name'];
989
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1231
+					if ($source == '') {
1232
+						$source = $this->all_flights[$id]['format_source'];
1233
+					}
990 1234
 					if (!isset($this->source_location[$source])) {
991 1235
 						$Location = new Source($this->db);
992 1236
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1007,7 +1251,9 @@  discard block
 block discarded – undo
1007 1251
 					$stats_heading = round($stats_heading/22.5);
1008 1252
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1009 1253
 					$current_date = date('Y-m-d');
1010
-					if ($stats_heading == 16) $stats_heading = 0;
1254
+					if ($stats_heading == 16) {
1255
+						$stats_heading = 0;
1256
+					}
1011 1257
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1012 1258
 						for ($i=0;$i<=15;$i++) {
1013 1259
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1025,7 +1271,9 @@  discard block
 block discarded – undo
1025 1271
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1026 1272
 						    end($this->stats[$current_date][$source]['hist']);
1027 1273
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1028
-						} else $mini = 0;
1274
+						} else {
1275
+							$mini = 0;
1276
+						}
1029 1277
 						for ($i=$mini;$i<=$distance;$i+=10) {
1030 1278
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031 1279
 						}
@@ -1037,19 +1285,27 @@  discard block
 block discarded – undo
1037 1285
 				}
1038 1286
 
1039 1287
 				$this->all_flights[$id]['lastupdate'] = time();
1040
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1288
+				if ($this->all_flights[$id]['putinarchive']) {
1289
+					$send = true;
1290
+				}
1041 1291
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1042
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1292
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1293
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1294
+			}
1043 1295
 			//$this->del();
1044 1296
 			
1045 1297
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1046 1298
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1047
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1299
+				if ($globalDebug) {
1300
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1301
+				}
1048 1302
 				$SpotterLive = new SpotterLive($this->db);
1049 1303
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1050 1304
 				$SpotterLive->db = null;
1051 1305
 				//SpotterLive->deleteLiveSpotterData();
1052
-				if ($globalDebug) echo " Done\n";
1306
+				if ($globalDebug) {
1307
+					echo " Done\n";
1308
+				}
1053 1309
 				$this->last_delete_hourly = time();
1054 1310
 			    } else {
1055 1311
 				$this->del();
@@ -1061,7 +1317,9 @@  discard block
 block discarded – undo
1061 1317
 		    //$ignoreImport = false;
1062 1318
 		}
1063 1319
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1064
-		if ($send) return $this->all_flights[$id];
1320
+		if ($send) {
1321
+			return $this->all_flights[$id];
1322
+		}
1065 1323
 	    }
1066 1324
 	}
1067 1325
     }
Please login to merge, or discard this patch.