Completed
Push — master ( 9adbe5...64358c )
by Yannick
33:16
created
require/class.SpotterLive.php 1 patch
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '') {
39 39
 					if (isset($flt['source'])) {
40
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41 41
 					} else {
42
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63 63
 				} else {
64
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['source']) && !empty($filter['source'])) {
88 88
 			if (count($filter['source']) == 1) {
89 89
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
90 90
 			} else {
91
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
91
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
92 92
 			}
93 93
 		}
94 94
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
119 119
 				}
120 120
 			}
121
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
121
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
122 122
 		}
123 123
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
124
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
124
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
125 125
 		}
126 126
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
127 127
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
128 128
 		if ($filter_query_where != '') {
129
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
129
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
130 130
 		}
131 131
 		$filter_query = $filter_query_join.$filter_query_where;
132 132
 		return $filter_query;
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 		if ($limit != '')
150 150
 		{
151 151
 			$limit_array = explode(',', $limit);
152
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
153
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
152
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
153
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
154 154
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
155 155
 			{
156 156
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		} else {
175 175
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
176 176
 		}
177
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
177
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
178 178
 
179 179
 		return $spotter_array;
180 180
 	}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	{
190 190
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
191 191
 		date_default_timezone_set('UTC');
192
-		$filter_query = $this->getFilter($filter,true,true);
192
+		$filter_query = $this->getFilter($filter, true, true);
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if ($globalDBdriver == 'mysql') {
195 195
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		try {
213 213
 			$sth = $this->db->prepare($query);
214 214
 			$sth->execute();
215
-		} catch(PDOException $e) {
215
+		} catch (PDOException $e) {
216 216
 			echo $e->getMessage();
217 217
 			die;
218 218
 		}
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 	* @return Array the spotter information
227 227
 	*
228 228
 	*/
229
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false)
229
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false)
230 230
 	{
231 231
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
232 232
 		date_default_timezone_set('UTC');
233 233
 		$usecoord = false;
234 234
 		if (is_array($coord) && !empty($coord)) {
235
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
236
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
237
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
238
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
235
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
236
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
237
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
238
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
239 239
 			$usecoord = true;
240 240
 		}
241
-		$filter_query = $this->getFilter($filter,true,true);
241
+		$filter_query = $this->getFilter($filter, true, true);
242 242
 
243 243
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
244 244
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		try {
300 300
 			$sth = $this->db->prepare($query);
301 301
 			$sth->execute();
302
-		} catch(PDOException $e) {
302
+		} catch (PDOException $e) {
303 303
 			echo $e->getMessage();
304 304
 			die;
305 305
 		}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	public function getLiveSpotterCount($filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
322 322
 		if ($globalDBdriver == 'mysql') {
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		try {
330 330
 			$sth = $this->db->prepare($query);
331 331
 			$sth->execute();
332
-		} catch(PDOException $e) {
332
+		} catch (PDOException $e) {
333 333
 			echo $e->getMessage();
334 334
 			die;
335 335
 		}
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		$filter_query = $this->getFilter($filter);
353 353
 
354 354
 		if (is_array($coord)) {
355
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
358
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
356
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
357
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
358
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
359 359
 		} else return array();
360 360
 		if ($globalDBdriver == 'mysql') {
361 361
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -378,23 +378,23 @@  discard block
 block discarded – undo
378 378
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
379 379
 		$Spotter = new Spotter($this->db);
380 380
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
381
-		$filter_query = $this->getFilter($filter,true,true);
381
+		$filter_query = $this->getFilter($filter, true, true);
382 382
 
383 383
 		if (is_array($coord)) {
384
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
385
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
386
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
387
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
384
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
385
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
386
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
387
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
388 388
 		} else return array();
389 389
 		if ($globalDBdriver == 'mysql') {
390 390
 			if (isset($globalArchive) && $globalArchive === TRUE) {
391
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
391
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
392 392
 				FROM spotter_live 
393 393
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
394 394
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
395 395
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
396 396
 			} else {
397
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
397
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
398 398
 				FROM spotter_live 
399 399
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
400 400
 				    FROM spotter_live l 
@@ -406,14 +406,14 @@  discard block
 block discarded – undo
406 406
 			}
407 407
 		} else {
408 408
 			if (isset($globalArchive) && $globalArchive === TRUE) {
409
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
409
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
410 410
 				FROM spotter_live 
411 411
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
412 412
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
413 413
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
414 414
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
415 415
 			} else {
416
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
416
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
417 417
 				FROM spotter_live 
418 418
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
419 419
 				    FROM spotter_live l 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		try {
429 429
 			$sth = $this->db->prepare($query);
430 430
 			$sth->execute();
431
-		} catch(PDOException $e) {
431
+		} catch (PDOException $e) {
432 432
 			echo $e->getMessage();
433 433
 			die;
434 434
 		}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 if ($interval == '1m')
478 478
                 {
479 479
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
-                } else if ($interval == '15m'){
480
+                } else if ($interval == '15m') {
481 481
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482 482
                 } 
483 483
             }
@@ -485,14 +485,14 @@  discard block
 block discarded – undo
485 485
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486 486
         }
487 487
 
488
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
488
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
489 489
                    WHERE spotter_live.latitude <> '' 
490 490
                                    AND spotter_live.longitude <> '' 
491 491
                    ".$additional_query."
492 492
                    HAVING distance < :radius  
493 493
                                    ORDER BY distance";
494 494
 
495
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
495
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
496 496
 
497 497
                 return $spotter_array;
498 498
         }
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 		date_default_timezone_set('UTC');
511 511
 
512 512
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
513
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
513
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
514 514
 
515
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
515
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
516 516
 
517 517
 		return $spotter_array;
518 518
 	}
@@ -523,16 +523,16 @@  discard block
 block discarded – undo
523 523
 	* @return Array the spotter information
524 524
 	*
525 525
 	*/
526
-	public function getDateLiveSpotterDataByIdent($ident,$date)
526
+	public function getDateLiveSpotterDataByIdent($ident, $date)
527 527
 	{
528 528
 		$Spotter = new Spotter($this->db);
529 529
 		date_default_timezone_set('UTC');
530 530
 
531 531
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
532
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
532
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
533 533
 
534
-                $date = date('c',$date);
535
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
534
+                $date = date('c', $date);
535
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 		$Spotter = new Spotter($this->db);
549 549
 		date_default_timezone_set('UTC');
550 550
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
551
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
552
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
551
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
552
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
553 553
 		return $spotter_array;
554 554
 	}
555 555
 
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
 	* @return Array the spotter information
560 560
 	*
561 561
 	*/
562
-	public function getDateLiveSpotterDataById($id,$date)
562
+	public function getDateLiveSpotterDataById($id, $date)
563 563
 	{
564 564
 		$Spotter = new Spotter($this->db);
565 565
 		date_default_timezone_set('UTC');
566 566
 
567 567
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
568
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
569
-		$date = date('c',$date);
570
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
568
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
569
+		$date = date('c', $date);
570
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
571 571
 		return $spotter_array;
572 572
 	}
573 573
 
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 		date_default_timezone_set('UTC');
584 584
 
585 585
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
586
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
586
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
587 587
 
588 588
     		try {
589 589
 			
590 590
 			$sth = $this->db->prepare($query);
591 591
 			$sth->execute(array(':ident' => $ident));
592
-		} catch(PDOException $e) {
592
+		} catch (PDOException $e) {
593 593
 			echo $e->getMessage();
594 594
 			die;
595 595
 		}
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	* @return Array the spotter information
605 605
 	*
606 606
 	*/
607
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
607
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
608 608
 	{
609 609
 		global $globalDBdriver, $globalLiveInterval;
610 610
 		date_default_timezone_set('UTC');
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 		try {
624 624
 			$sth = $this->db->prepare($query);
625 625
 			$sth->execute(array(':id' => $id));
626
-		} catch(PDOException $e) {
626
+		} catch (PDOException $e) {
627 627
 			echo $e->getMessage();
628 628
 			die;
629 629
 		}
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
 	{
642 642
 		date_default_timezone_set('UTC');
643 643
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
644
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
644
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
645 645
     		try {
646 646
 			
647 647
 			$sth = $this->db->prepare($query);
648 648
 			$sth->execute(array(':ident' => $ident));
649
-		} catch(PDOException $e) {
649
+		} catch (PDOException $e) {
650 650
 			echo $e->getMessage();
651 651
 			die;
652 652
 		}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			
677 677
 			$sth = $this->db->prepare($query);
678 678
 			$sth->execute();
679
-		} catch(PDOException $e) {
679
+		} catch (PDOException $e) {
680 680
 			return "error";
681 681
 		}
682 682
 
@@ -699,14 +699,14 @@  discard block
 block discarded – undo
699 699
 				
700 700
 				$sth = $this->db->prepare($query);
701 701
 				$sth->execute();
702
-			} catch(PDOException $e) {
702
+			} catch (PDOException $e) {
703 703
 				return "error";
704 704
 			}
705 705
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
706 706
                         $i = 0;
707
-                        $j =0;
707
+                        $j = 0;
708 708
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
709
-			foreach($all as $row)
709
+			foreach ($all as $row)
710 710
 			{
711 711
 				$i++;
712 712
 				$j++;
@@ -714,9 +714,9 @@  discard block
 block discarded – undo
714 714
 					if ($globalDebug) echo ".";
715 715
 				    	try {
716 716
 						
717
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
717
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
718 718
 						$sth->execute();
719
-					} catch(PDOException $e) {
719
+					} catch (PDOException $e) {
720 720
 						return "error";
721 721
 					}
722 722
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
 			if ($i > 0) {
728 728
     				try {
729 729
 					
730
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
730
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
731 731
 					$sth->execute();
732
-				} catch(PDOException $e) {
732
+				} catch (PDOException $e) {
733 733
 					return "error";
734 734
 				}
735 735
 			}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 				
743 743
 				$sth = $this->db->prepare($query);
744 744
 				$sth->execute();
745
-			} catch(PDOException $e) {
745
+			} catch (PDOException $e) {
746 746
 				return "error";
747 747
 			}
748 748
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function deleteLiveSpotterDataByIdent($ident)
791 791
 	{
792 792
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
793
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
793
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
794 794
         
795 795
     		try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':ident' => $ident));
799
-		} catch(PDOException $e) {
799
+		} catch (PDOException $e) {
800 800
 			return "error";
801 801
 		}
802 802
 
@@ -812,13 +812,13 @@  discard block
 block discarded – undo
812 812
 	public function deleteLiveSpotterDataById($id)
813 813
 	{
814 814
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
815
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
815
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
816 816
         
817 817
     		try {
818 818
 			
819 819
 			$sth = $this->db->prepare($query);
820 820
 			$sth->execute(array(':id' => $id));
821
-		} catch(PDOException $e) {
821
+		} catch (PDOException $e) {
822 822
 			return "error";
823 823
 		}
824 824
 
@@ -836,13 +836,13 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 		global $globalDBdriver, $globalTimezone;
838 838
 		if ($globalDBdriver == 'mysql') {
839
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
839
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
840 840
 				WHERE spotter_live.ident = :ident 
841 841
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
842 842
 				AND spotter_live.date < UTC_TIMESTAMP()';
843 843
 			$query_data = array(':ident' => $ident);
844 844
 		} else {
845
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
845
+			$query = "SELECT spotter_live.ident FROM spotter_live 
846 846
 				WHERE spotter_live.ident = :ident 
847 847
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
848 848
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 		
852 852
 		$sth = $this->db->prepare($query);
853 853
 		$sth->execute($query_data);
854
-		$ident_result='';
855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
854
+		$ident_result = '';
855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
856 856
 		{
857 857
 			$ident_result = $row['ident'];
858 858
 		}
@@ -869,13 +869,13 @@  discard block
 block discarded – undo
869 869
 	{
870 870
 		global $globalDBdriver, $globalTimezone;
871 871
 		if ($globalDBdriver == 'mysql') {
872
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
872
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
873 873
 				WHERE spotter_live.ident = :ident 
874 874
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
875 875
 //				AND spotter_live.date < UTC_TIMESTAMP()";
876 876
 			$query_data = array(':ident' => $ident);
877 877
 		} else {
878
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
878
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
879 879
 				WHERE spotter_live.ident = :ident 
880 880
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
881 881
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 		
885 885
 		$sth = $this->db->prepare($query);
886 886
 		$sth->execute($query_data);
887
-		$ident_result='';
888
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
887
+		$ident_result = '';
888
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
889 889
 		{
890 890
 			$ident_result = $row['flightaware_id'];
891 891
 		}
@@ -902,13 +902,13 @@  discard block
 block discarded – undo
902 902
 	{
903 903
 		global $globalDBdriver, $globalTimezone;
904 904
 		if ($globalDBdriver == 'mysql') {
905
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
905
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
906 906
 				WHERE spotter_live.flightaware_id = :id 
907 907
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
908 908
 //				AND spotter_live.date < UTC_TIMESTAMP()";
909 909
 			$query_data = array(':id' => $id);
910 910
 		} else {
911
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
911
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
912 912
 				WHERE spotter_live.flightaware_id = :id 
913 913
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
914 914
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 		
918 918
 		$sth = $this->db->prepare($query);
919 919
 		$sth->execute($query_data);
920
-		$ident_result='';
921
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
920
+		$ident_result = '';
921
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
922 922
 		{
923 923
 			$ident_result = $row['flightaware_id'];
924 924
 		}
@@ -935,13 +935,13 @@  discard block
 block discarded – undo
935 935
 	{
936 936
 		global $globalDBdriver, $globalTimezone;
937 937
 		if ($globalDBdriver == 'mysql') {
938
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
938
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
939 939
 				WHERE spotter_live.ModeS = :modes 
940 940
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
941 941
 //				AND spotter_live.date < UTC_TIMESTAMP()";
942 942
 			$query_data = array(':modes' => $modes);
943 943
 		} else {
944
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
944
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
945 945
 				WHERE spotter_live.ModeS = :modes 
946 946
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
947 947
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 		
951 951
 		$sth = $this->db->prepare($query);
952 952
 		$sth->execute($query_data);
953
-		$ident_result='';
954
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
953
+		$ident_result = '';
954
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
955 955
 		{
956 956
 			//$ident_result = $row['spotter_live_id'];
957 957
 			$ident_result = $row['flightaware_id'];
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 				return array();
977 977
 			} else {
978 978
 				$q_array = explode(" ", $q);
979
-				foreach ($q_array as $q_item){
980
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
979
+				foreach ($q_array as $q_item) {
980
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
981 981
 					$additional_query .= " AND (";
982 982
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
983 983
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -992,11 +992,11 @@  discard block
 block discarded – undo
992 992
 			}
993 993
 		}
994 994
 		if ($globalDBdriver == 'mysql') {
995
-			$query  = "SELECT spotter_live.* FROM spotter_live 
995
+			$query = "SELECT spotter_live.* FROM spotter_live 
996 996
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
997 997
 			    AND spotter_live.date < UTC_TIMESTAMP()";
998 998
 		} else {
999
-			$query  = "SELECT spotter_live.* FROM spotter_live 
999
+			$query = "SELECT spotter_live.* FROM spotter_live 
1000 1000
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1001 1001
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1002 1002
 		}
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 	* @return String success or false
1017 1017
 	*
1018 1018
 	*/
1019
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1019
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
1020 1020
 	{
1021 1021
 		global $globalURL, $globalArchive, $globalDebug;
1022 1022
 		$Common = new Common();
@@ -1116,27 +1116,27 @@  discard block
 block discarded – undo
1116 1116
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1117 1117
 
1118 1118
         
1119
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1120
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1121
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1122
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1123
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1124
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1125
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1126
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1127
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1128
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1129
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1130
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1131
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1132
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1133
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1134
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1135
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1136
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1137
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1138
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1139
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1119
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1120
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1121
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1122
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1123
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1124
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1125
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1126
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1127
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1128
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1129
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1130
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1131
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1132
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1133
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1134
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1135
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1136
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1137
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1138
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1139
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1140 1140
 
1141 1141
 		$airline_name = '';
1142 1142
 		$airline_icao = '';
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		$arrival_airport_country = '';
1159 1159
 		
1160 1160
             	
1161
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1162
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1163
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1164
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1161
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1162
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1163
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1164
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1165 1165
 		
1166 1166
 		$query = '';
1167 1167
 		if ($globalArchive) {
@@ -1172,19 +1172,19 @@  discard block
 block discarded – undo
1172 1172
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1173 1173
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1174 1174
 
1175
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1175
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1176 1176
 		try {
1177 1177
 			
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute($query_values);
1180 1180
 			$sth->closeCursor();
1181
-		} catch(PDOException $e) {
1181
+		} catch (PDOException $e) {
1182 1182
 			return "error : ".$e->getMessage();
1183 1183
 		}
1184 1184
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1185 1185
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1186 1186
 		    $SpotterArchive = new SpotterArchive($this->db);
1187
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1187
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1188 1188
 		    if ($globalDebug) echo $result.')';
1189 1189
 		} elseif ($globalDebug && $putinarchive !== true) {
1190 1190
 			echo '(Not adding to archive)';
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 
1198 1198
 	public function getOrderBy()
1199 1199
 	{
1200
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1200
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1201 1201
 		return $orderby;
1202 1202
 	}
1203 1203
 
Please login to merge, or discard this patch.
require/class.TSK.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 class TSK {
4 4
 	public function parse_xml($url) {
5 5
 		$Common = new Common();
6
-		$filedata = $Common->getData($url,'get','','','','','','',true);
6
+		$filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true);
7 7
 		if ($filedata != '' && $filedata !== false) {
8 8
 			$xml = simplexml_load_string($filedata);
9 9
 			if ($xml !== false) {
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//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');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 		$info = curl_getinfo($ch);
77 77
 		//var_dump($info);
78 78
 		curl_close($ch);
79
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
79
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
80 80
 			echo "Cloudflare Detected\n";
81 81
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
82 82
 			$useragent = UAgent::random();
83 83
 			cloudflare::useUserAgent($useragent);
84 84
 			if ($clearanceCookie = cloudflare::bypass($url)) {
85
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
85
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
86 86
 			}
87 87
 		} else {
88 88
 			return $result;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
107 107
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
108 108
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
109
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
109
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
110 110
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
111 111
 			}
112 112
 		}
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
 		fclose($fp);
122 122
 	}
123 123
 
124
-	public static function gunzip($in_file,$out_file_name = '') {
124
+	public static function gunzip($in_file, $out_file_name = '') {
125 125
 		//echo $in_file.' -> '.$out_file_name."\n";
126 126
 		$buffer_size = 4096; // read 4kb at a time
127 127
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
128 128
 		if ($in_file != '' && file_exists($in_file)) {
129 129
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
130
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
131
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
130
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
131
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
132 132
 			else {
133 133
 				echo 'gzopen not available';
134 134
 				die;
135 135
 			}
136 136
 			$out_file = fopen($out_file_name, 'wb'); 
137
-			while(!gzeof($file)) {
137
+			while (!gzeof($file)) {
138 138
 				fwrite($out_file, gzread($file, $buffer_size));
139 139
 			}  
140 140
 			fclose($out_file);
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 		}
143 143
 	}
144 144
 
145
-	public static function bunzip2($in_file,$out_file_name = '') {
145
+	public static function bunzip2($in_file, $out_file_name = '') {
146 146
 		//echo $in_file.' -> '.$out_file_name."\n";
147 147
 		$buffer_size = 4096; // read 4kb at a time
148 148
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
149 149
 		if ($in_file != '' && file_exists($in_file)) {
150 150
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
151
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
151
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
152 152
 			else {
153 153
 				echo 'bzopen not available';
154 154
 				die;
155 155
 			}
156 156
 			$out_file = fopen($out_file_name, 'wb'); 
157
-			while(!feof($file)) {
157
+			while (!feof($file)) {
158 158
 				fwrite($out_file, bzread($file, $buffer_size));
159 159
 			}  
160 160
 			fclose($out_file);
@@ -172,27 +172,27 @@  discard block
 block discarded – undo
172 172
 		if ($data == '') return array();
173 173
 		$html = str_get_html($data);
174 174
 		if ($html === false) return array();
175
-		$tabledata=array();
176
-		foreach($html->find('tr') as $element)
175
+		$tabledata = array();
176
+		foreach ($html->find('tr') as $element)
177 177
 		{
178 178
 			$td = array();
179
-			foreach( $element->find('th') as $row)
179
+			foreach ($element->find('th') as $row)
180 180
 			{
181 181
 				$td [] = trim($row->plaintext);
182 182
 			}
183
-			$td=array_filter($td);
183
+			$td = array_filter($td);
184 184
 			$tabledata[] = $td;
185 185
 
186 186
 			$td = array();
187 187
 			$tdi = array();
188
-			foreach( $element->find('td') as $row)
188
+			foreach ($element->find('td') as $row)
189 189
 			{
190 190
 				$td [] = trim($row->plaintext);
191 191
 				$tdi [] = trim($row->innertext);
192 192
 			}
193
-			$td=array_filter($td);
194
-			$tdi=array_filter($tdi);
195
-			$tabledata[]=array_merge($td,$tdi);
193
+			$td = array_filter($td);
194
+			$tdi = array_filter($tdi);
195
+			$tabledata[] = array_merge($td, $tdi);
196 196
 		}
197 197
 		$html->clear();
198 198
 		unset($html);
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	public function text2array($data) {
208 208
 		$html = str_get_html($data);
209 209
 		if ($html === false) return array();
210
-		$tabledata=array();
211
-		foreach($html->find('p') as $element)
210
+		$tabledata = array();
211
+		foreach ($html->find('p') as $element)
212 212
 		{
213 213
 			$tabledata [] = trim($element->plaintext);
214 214
 		}
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	*/
229 229
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
230 230
 		if ($lat == $latc && $lon == $lonc) return 0;
231
-		$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;
231
+		$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;
232 232
 		if ($unit == "km") {
233
-			return round($dist * 1.609344);
233
+			return round($dist*1.609344);
234 234
 		} elseif ($unit == "m") {
235
-			return round($dist * 1.609344 * 1000);
235
+			return round($dist*1.609344*1000);
236 236
 		} elseif ($unit == "mile" || $unit == "mi") {
237 237
 			return round($dist);
238 238
 		} elseif ($unit == "nm") {
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	* @param String $distance distance between two points in m
250 250
 	* @return Float plunge
251 251
 	*/
252
-	public function plunge($initial_altitude,$final_altitude,$distance) {
253
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
252
+	public function plunge($initial_altitude, $final_altitude, $distance) {
253
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
254 254
 		return $plunge;
255 255
 	}
256 256
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	*/
265 265
 	public function azimuth($lat, $lon, $latc, $lonc) {
266 266
 		$azimuth = rad2deg(atan(($latc - $lat)/($lonc - $lon)));
267
-		return 360+$azimuth;
267
+		return 360 + $azimuth;
268 268
 	}
269 269
 	
270 270
 	
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	* @param float $distance distance covered
275 275
 	* @return whether distance is realistic
276 276
 	*/
277
-	public function withinThreshold ($timeDifference, $distance) {
277
+	public function withinThreshold($timeDifference, $distance) {
278 278
 		$x = abs($timeDifference);
279 279
 		$d = abs($distance);
280 280
 		if ($x == 0 || $d == 0) return true;
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
 		return ($array !== array_values($array));
291 291
 	}
292 292
 
293
-	public function isInteger($input){
293
+	public function isInteger($input) {
294 294
 	    return(ctype_digit(strval($input)));
295 295
 	}
296 296
 
297 297
 
298
-	public function convertDec($dms,$latlong) {
298
+	public function convertDec($dms, $latlong) {
299 299
 		if ($latlong == 'latitude') {
300 300
 			$deg = substr($dms, 0, 2);
301 301
 			$min = substr($dms, 2, 4);
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 			$deg = substr($dms, 0, 3);
304 304
 			$min = substr($dms, 3, 5);
305 305
 		}
306
-		return $deg+(($min*60)/3600);
306
+		return $deg + (($min*60)/3600);
307 307
 	}
308 308
 	
309
-	public function convertDM($coord,$latlong) {
309
+	public function convertDM($coord, $latlong) {
310 310
 		if ($latlong == 'latitude') {
311 311
 			if ($coord < 0) $NSEW = 'S';
312 312
 			else $NSEW = 'N';
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 		}
317 317
 		$coord = abs($coord);
318 318
 		$deg = floor($coord);
319
-		$coord = ($coord-$deg)*60;
319
+		$coord = ($coord - $deg)*60;
320 320
 		$min = $coord;
321
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
321
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
322 322
 	}
323 323
 	
324 324
 	/**
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 	public function xcopy($source, $dest)
331 331
 	{
332 332
 		$files = glob($source.'*.*');
333
-		foreach($files as $file){
334
-			$file_to_go = str_replace($source,$dest,$file);
333
+		foreach ($files as $file) {
334
+			$file_to_go = str_replace($source, $dest, $file);
335 335
 			copy($file, $file_to_go);
336 336
 		}
337 337
 		return true;
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 	* @param	String $url url to check
343 343
 	* @return	bool Return true on succes false on failure
344 344
 	*/
345
-	public function urlexist($url){
346
-		$headers=get_headers($url);
347
-		return stripos($headers[0],"200 OK")?true:false;
345
+	public function urlexist($url) {
346
+		$headers = get_headers($url);
347
+		return stripos($headers[0], "200 OK") ?true:false;
348 348
 	}
349 349
 	
350 350
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	public function hex2str($hex) {
356 356
 		$str = '';
357 357
 		$hexln = strlen($hex);
358
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
358
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
359 359
 		return $str;
360 360
 	}
361 361
 	
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	* @return	String Return result
366 366
 	*/
367 367
 	public function hex2rgb($hex) {
368
-		$hex = str_replace('#','',$hex);
368
+		$hex = str_replace('#', '', $hex);
369 369
 		return sscanf($hex, "%02x%02x%02x"); 
370 370
 	}
371 371
 	
@@ -373,33 +373,33 @@  discard block
 block discarded – undo
373 373
 		//difference in longitudinal coordinates
374 374
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
375 375
 		//difference in the phi of latitudinal coordinates
376
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
376
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
377 377
 		//we need to recalculate $dLon if it is greater than pi
378
-		if(abs($dLon) > pi()) {
379
-			if($dLon > 0) {
380
-				$dLon = (2 * pi() - $dLon) * -1;
378
+		if (abs($dLon) > pi()) {
379
+			if ($dLon > 0) {
380
+				$dLon = (2*pi() - $dLon)*-1;
381 381
 			} else {
382
-				$dLon = 2 * pi() + $dLon;
382
+				$dLon = 2*pi() + $dLon;
383 383
 			}
384 384
 		}
385 385
 		//return the angle, normalized
386
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
386
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
387 387
 	}
388 388
 
389
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
389
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
390 390
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
391
-		$a = -($lon2-$lon1);
391
+		$a = -($lon2 - $lon1);
392 392
 		$b = $lat2 - $lat1;
393
-		$c = -($a*$lat1+$b*$lon1);
394
-		$d = $a*$lat3+$b*$lon3+$c;
393
+		$c = -($a*$lat1 + $b*$lon1);
394
+		$d = $a*$lat3 + $b*$lon3 + $c;
395 395
 		if ($d > -$approx && $d < $approx) return true;
396 396
 		else return false;
397 397
 	}
398 398
 	
399 399
 	public function array_merge_noappend() {
400 400
 		$output = array();
401
-		foreach(func_get_args() as $array) {
402
-			foreach($array as $key => $value) {
401
+		foreach (func_get_args() as $array) {
402
+			foreach ($array as $key => $value) {
403 403
 				$output[$key] = isset($output[$key]) ?
404 404
 				array_merge($output[$key], $value) : $value;
405 405
 			}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		return $result;
464 464
 	}
465 465
 
466
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
466
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
467 467
 		global $globalMapRefresh;
468 468
 		if ($seconds == '') {
469 469
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -474,27 +474,27 @@  discard block
 block discarded – undo
474 474
 		$latitude = deg2rad($latitude);
475 475
 		$longitude = deg2rad($longitude);
476 476
 		$bearing = deg2rad($heading); 
477
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
478
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
479
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
477
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
478
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
479
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
480 480
 	}
481 481
 	
482
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
482
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
483 483
 		// distance in meter
484 484
 		$R = 6378.14;
485
-		$latitude1 = $latitude * (M_PI/180);
486
-		$longitude1 = $longitude * (M_PI/180);
487
-		$brng = $bearing * (M_PI/180);
485
+		$latitude1 = $latitude*(M_PI/180);
486
+		$longitude1 = $longitude*(M_PI/180);
487
+		$brng = $bearing*(M_PI/180);
488 488
 		$d = $distance;
489 489
 
490 490
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
491
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
491
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
492 492
 
493
-		$latitude2 = $latitude2 * (180/M_PI);
494
-		$longitude2 = $longitude2 * (180/M_PI);
493
+		$latitude2 = $latitude2*(180/M_PI);
494
+		$longitude2 = $longitude2*(180/M_PI);
495 495
 
496
-		$flat = round ($latitude2,6);
497
-		$flong = round ($longitude2,6);
496
+		$flat = round($latitude2, 6);
497
+		$flong = round($longitude2, 6);
498 498
 /*
499 499
 		$dx = $distance*cos($bearing);
500 500
 		$dy = $distance*sin($bearing);
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		$flong = $longitude + $dlong;
504 504
 		$flat = $latitude + $dlat;
505 505
 */
506
-		return array('latitude' => $flat,'longitude' => $flong);
506
+		return array('latitude' => $flat, 'longitude' => $flong);
507 507
 	}
508 508
 
509 509
 	/**
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
 	 * @param integer $level GZIP compression level (default: 9)
518 518
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
519 519
 	 */
520
-	public function gzCompressFile($source, $level = 9){ 
521
-		$dest = $source . '.gz'; 
522
-		$mode = 'wb' . $level; 
520
+	public function gzCompressFile($source, $level = 9) { 
521
+		$dest = $source.'.gz'; 
522
+		$mode = 'wb'.$level; 
523 523
 		$error = false; 
524 524
 		if ($fp_out = gzopen($dest, $mode)) { 
525
-			if ($fp_in = fopen($source,'rb')) { 
525
+			if ($fp_in = fopen($source, 'rb')) { 
526 526
 				while (!feof($fp_in)) 
527
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
527
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
528 528
 				fclose($fp_in); 
529 529
 			} else {
530 530
 				$error = true; 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	} 
541 541
 	
542 542
 	public function remove_accents($string) {
543
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
543
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
544 544
 		$chars = array(
545 545
 		    // Decompositions for Latin-1 Supplement
546 546
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
598 598
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
599 599
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
600
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
600
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
601 601
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
602 602
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
603 603
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -613,13 +613,13 @@  discard block
 block discarded – undo
613 613
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
614 614
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
615 615
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
616
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
617
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
618
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
619
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
620
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
621
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
622
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
616
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
617
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
618
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
619
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
620
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
621
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
622
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
623 623
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
624 624
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
625 625
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
654 654
 			if (is_numeric($string[$i]) && $concat_flag) {
655 655
 				$int .= $string[$i];
656
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
656
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
657 657
 				$concat_flag = false;
658 658
 			}
659 659
 		}
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 			$slice = array_slice($arr, $offset + 1, $length);
700 700
 			return implode("", $slice);
701 701
 		} else {
702
-			return mb_substr($string,$offset,$length,'UTF-8');
702
+			return mb_substr($string, $offset, $length, 'UTF-8');
703 703
 		}
704 704
 	}
705 705
 
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 		//NOTE: use a trailing slash for folders!!!
710 710
 		//see http://bugs.php.net/bug.php?id=27609
711 711
 		//see http://bugs.php.net/bug.php?id=30931
712
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
712
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
713 713
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
714 714
 		else if (is_dir($path))
715 715
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
716 716
 		// check tmp file for read/write capabilities
717 717
 		$rm = file_exists($path);
718 718
 		$f = @fopen($path, 'a');
719
-		if ($f===false)
719
+		if ($f === false)
720 720
 			return false;
721 721
 		fclose($f);
722 722
 		if (!$rm)
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $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']);
107
+		    $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 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$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']));
115
+		$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 116
        }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 140
     		    $Spotter = new Spotter($this->db);
141 141
         	    $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']);
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']);
143 143
         	}
144 144
 	    }
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $airport_time = '';
154 154
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
156
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
157 157
     	    if (isset($closestAirports[0])) {
158 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 159
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         		    break;
169 169
         		}
170 170
         	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
171
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
172 172
         		$airport_icao = $closestAirports[0]['icao'];
173 173
         		$airport_time = $this->all_flights[$key]['datetime'];
174 174
         	} else {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         } else {
182 182
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183 183
         }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
184
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
185 185
     }
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194 194
 	    if (isset($flight['lastupdate'])) {
195
-		if ($flight['lastupdate'] < (time()-1800)) {
195
+		if ($flight['lastupdate'] < (time() - 1800)) {
196 196
 		    $this->delKey($key);
197 197
 		}
198 198
 	    }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$real_arrival = $this->arrival($key);
209 209
 			$Spotter = new Spotter($this->db);
210 210
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211
-				$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']);
211
+				$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 212
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213 213
 			}
214 214
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$send = false;
242 242
 	
243 243
 	// SBS format is CSV format
244
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
244
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 245
 	    //print_r($line);
246 246
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247 247
   	    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)) {
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
 		if (!isset($this->all_flights[$id])) {
278 278
 		    if ($globalDebug) echo 'New flight...'."\n";
279 279
 		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $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()));
280
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
281
+		    $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()));
283 283
 		    if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 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')));
286 286
 //			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'] === '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')));
287
+			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' || $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')));
288 288
 		        //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']));
289
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
290 290
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
298
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
299 299
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 301
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 			    $Spotter = new Spotter($this->db);
306 306
 			    if (isset($this->all_flights[$id]['source_type'])) {
307
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
307
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
308 308
 			    } else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 310
 			    }
311 311
 			    $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));
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));
314 314
 			}
315 315
 		    }
316 316
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
317 317
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319 319
 	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
321 321
 	        }
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
327 327
 				$Spotter->db = null;
328 328
 			}
329
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
329
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
330 330
 		}
331 331
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
332 332
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 				$Spotter = new Spotter($this->db);
335 335
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 336
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
337
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
338 338
 			}
339 339
 		}
340 340
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343 343
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344 344
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
345
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
346 346
 		}
347 347
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
349 349
 		}
350 350
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
351
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
351
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
352 352
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
353
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
354 354
 		    } else {
355 355
 				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";
356 356
 				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";
@@ -361,31 +361,31 @@  discard block
 block discarded – undo
361 361
 				*/
362 362
 				return '';
363 363
 		    }
364
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
364
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
365 365
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
366 366
 			return '';
367
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
367
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
368 368
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
369 369
 			return '';
370 370
 		} elseif (!isset($line['datetime'])) {
371 371
 			date_default_timezone_set('UTC');
372
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
372
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
373 373
 		} else {
374 374
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
375 375
 			return '';
376 376
 		}
377 377
 
378 378
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
379
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
379
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
380 380
 		}
381 381
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
382
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
382
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
383 383
 		}
384 384
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
385
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
385
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
386 386
 		}
387 387
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
388
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
389 389
 		}
390 390
  
391 391
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 394
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395 395
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
396
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				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' || $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')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				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']));
396
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
397
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
398
+				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' || $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')));
399
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
400
+				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']));
401 401
 			} else {
402
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
402
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
403 403
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 404
 				$timeelapsed = microtime(true);
405 405
             			$Spotter = new Spotter($this->db);
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410 410
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411 411
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
412
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
412
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
413 413
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
414 414
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
415
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
416 416
 			    }
417 417
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
419 419
 		    
420 420
 /*
421 421
 		    if (!isset($line['id'])) {
@@ -425,25 +425,25 @@  discard block
 block discarded – undo
425 425
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 426
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 427
   */
428
-		    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']));
428
+		    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']));
429 429
 
430 430
 		    //$putinarchive = true;
431 431
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
432
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
432
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
433 433
 		    }
434 434
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
435
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
435
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
436 436
 		    }
437 437
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
438
-		    		$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' => ''));
438
+		    		$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' => ''));
439 439
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
440 440
 			$timeelapsed = microtime(true);
441 441
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 442
 				$Spotter = new Spotter($this->db);
443 443
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 444
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445
-		    		$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' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
+		    		$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' => ''));
446
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
447 447
                         }
448 448
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 449
 			$timeelapsed = microtime(true);
@@ -457,35 +457,35 @@  discard block
 block discarded – undo
457 457
 				$Translation->db = null;
458 458
 			    }
459 459
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
460
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
461 461
                     	}
462 462
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 463
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
464 464
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
465 465
 				//    $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
-		    		$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
+		    		$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']));
467 467
 		    	    }
468 468
 			}
469 469
 			if (!isset($globalFork)) $globalFork = TRUE;
470 470
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
471
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
472 472
 			}
473 473
 		    }
474 474
 		}
475 475
 
476 476
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
477 477
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
478
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
479
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
479
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
480 480
 		    //$dataFound = true;
481 481
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
482
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
482
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
483 483
 		    if ($distance > 1000 && $distance < 10000) {
484 484
 		    // use datetime
485 485
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
486 486
 			$speed = $speed*3.6;
487 487
 			if ($speed < 1000) {
488
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
488
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
489 489
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
490 490
 	  		} else {
491 491
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
501 501
 	    	    	return false;
502 502
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
503
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
504 504
 	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
505
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
506 506
 	    	    else unset($timediff_archive);
507 507
 	    	    if ($this->tmd > 5
508 508
 	    	        || (isset($line['format_source']) 
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 	    	    	|| ($timediff > 30 
528 528
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
529 529
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
530
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
530
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
531 531
 	    	    	    )
532 532
 	    	    	) {
533 533
 
534 534
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
535 535
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
536 536
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
537
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
537
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
538 538
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
539 539
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
540 540
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 				    $timeelapsed = microtime(true);
545 545
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
546 546
 					$Spotter = new Spotter($this->db);
547
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
547
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
548 548
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
549 549
 					else $this->all_flights[$id]['over_country'] = '';
550 550
 					$Spotter->db = null;
551
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
552 552
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
553 553
 				    }
554 554
 				}
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 					$this->all_flights[$id]['time_last_coord'] = time();
575 575
 				}
576 576
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
577
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
577
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
578 578
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
579 579
 				    $dataFound = true;
580 580
 				    $this->all_flights[$id]['time_last_coord'] = time();
581 581
 				}
582 582
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
583
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
583
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
584 584
 				/*
585 585
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
586 586
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 					$this->all_flights[$id]['time_last_coord'] = time();
603 603
 				}
604 604
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
605
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
605
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
606 606
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
607 607
 				    $dataFound = true;
608 608
 				    $this->all_flights[$id]['time_last_coord'] = time();
609 609
 				}
610 610
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
611
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
611
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
612 612
 				/*
613 613
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
614 614
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -626,46 +626,46 @@  discard block
 block discarded – undo
626 626
 		    } else if ($globalDebug && $timediff > 30) {
627 627
 			$this->tmd = $this->tmd + 1;
628 628
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
629
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
630
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
629
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
630
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
631 631
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
632 632
 		    }
633 633
 		}
634 634
 		if (isset($line['last_update']) && $line['last_update'] != '') {
635 635
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
637 637
 		}
638 638
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
639
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
639
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
640 640
 		    //$dataFound = true;
641 641
 		}
642 642
 		if (isset($line['format_source']) && $line['format_source'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
643
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
644 644
 		}
645 645
 		if (isset($line['source_name']) && $line['source_name'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
646
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
647 647
 		}
648 648
 		if (isset($line['emergency']) && $line['emergency'] != '') {
649
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
649
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
650 650
 		    //$dataFound = true;
651 651
 		}
652 652
 		if (isset($line['ground']) && $line['ground'] != '') {
653 653
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
654 654
 			// Here we force archive of flight because after ground it's a new one (or should be)
655
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
656
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
657
-			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' || $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')));
658
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
659
-			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']));
655
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
656
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
657
+			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' || $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')));
658
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
659
+			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']));
660 660
 		    }
661 661
 		    if ($line['ground'] != 1) $line['ground'] = 0;
662
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
662
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
663 663
 		    //$dataFound = true;
664 664
 		}
665 665
 		if (isset($line['squawk']) && $line['squawk'] != '') {
666 666
 		    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'])) {
667 667
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
668
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
668
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
669 669
 			    $highlight = '';
670 670
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671 671
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -674,66 +674,66 @@  discard block
 block discarded – undo
674 674
 				$timeelapsed = microtime(true);
675 675
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
676 676
 				    $Spotter = new Spotter($this->db);
677
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
677
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
678 678
 				    $Spotter->db = null;
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
679
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
680 680
 				}
681 681
 				//$putinarchive = true;
682 682
 				//$highlight = '';
683 683
 			    }
684 684
 			    
685
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
685
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
686 686
 		    //$dataFound = true;
687 687
 		}
688 688
 
689 689
 		if (isset($line['altitude']) && $line['altitude'] != '') {
690 690
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
691 691
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
692
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
692
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
693 693
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
694 694
 					$line['altitude'] = $line['altitude'] - $geoid;
695 695
 				}
696 696
 			}
697 697
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
698
-			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;
699
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
700
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
698
+			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;
699
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
700
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
701 701
 			//$dataFound = true;
702 702
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703 703
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
704 704
 			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) {
705 705
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
706
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
707
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
708
-				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' || $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')));
709
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
710
-				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']));
706
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
707
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
708
+				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' || $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')));
709
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
710
+				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']));
711 711
 			}
712 712
 		    }
713
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
713
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
714 714
 		}
715 715
 
716 716
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
717
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
717
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
718 718
 		}
719 719
 		
720 720
 		if (isset($line['heading']) && $line['heading'] != '') {
721
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
723
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
724 724
 		    //$dataFound = true;
725 725
   		} 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']) {
726
-  		    $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']);
727
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
+  		    $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']);
727
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
728
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729 729
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
730 730
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
731 731
   		    // If not enough messages and ACARS set heading to 0
732
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
732
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
733 733
   		}
734
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
734
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
737 737
 
738 738
 //		print_r($this->all_flights[$id]);
739 739
 		//gets the callsign from the last hour
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
745 745
 		    $this->all_flights[$id]['lastupdate'] = time();
746 746
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
747
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
747
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
748 748
 			    //print_r($this->all_flights);
749 749
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
750 750
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -755,61 +755,61 @@  discard block
 block discarded – undo
755 755
 				    $SpotterLive = new SpotterLive($this->db);
756 756
 				    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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
757 757
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
758
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
759 759
 				    } elseif (isset($line['id'])) {
760 760
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
761
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
762 762
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
763 763
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
764
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
764
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
765 765
 				    } else $recent_ident = '';
766
-				    $SpotterLive->db=null;
766
+				    $SpotterLive->db = null;
767 767
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768 768
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
769 769
 				} else $recent_ident = '';
770 770
 			    } else {
771 771
 				$recent_ident = '';
772
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
772
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
773 773
 			    }
774 774
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
775
-			    if($recent_ident == "")
775
+			    if ($recent_ident == "")
776 776
 			    {
777 777
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
778 778
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
779 779
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
780 780
 				//adds the spotter data for the archive
781 781
 				$ignoreImport = false;
782
-				foreach($globalAirportIgnore as $airportIgnore) {
782
+				foreach ($globalAirportIgnore as $airportIgnore) {
783 783
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
784 784
 					$ignoreImport = true;
785 785
 				    }
786 786
 				}
787 787
 				if (count($globalAirportAccept) > 0) {
788 788
 				    $ignoreImport = true;
789
-				    foreach($globalAirportIgnore as $airportIgnore) {
789
+				    foreach ($globalAirportIgnore as $airportIgnore) {
790 790
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791 791
 					    $ignoreImport = false;
792 792
 					}
793 793
 				    }
794 794
 				}
795 795
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
796
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
797
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
796
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
797
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
798 798
 					    $ignoreImport = true;
799 799
 					}
800 800
 				    }
801 801
 				}
802 802
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
803 803
 				    $ignoreImport = true;
804
-				    foreach($globalAirlineAccept as $airlineAccept) {
805
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
804
+				    foreach ($globalAirlineAccept as $airlineAccept) {
805
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
806 806
 					    $ignoreImport = false;
807 807
 					}
808 808
 				    }
809 809
 				}
810 810
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
811 811
 				    $ignoreImport = true;
812
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
812
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
813 813
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
814 814
 					    $ignoreImport = false;
815 815
 					}
@@ -821,32 +821,32 @@  discard block
 block discarded – undo
821 821
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822 822
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823 823
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
-				    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')));
824
+				    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')));
825 825
 				    $timeelapsed = microtime(true);
826 826
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
827 827
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
828 828
 					    $Spotter = new Spotter($this->db);
829
-					    $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
+					    $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']);
830 830
 					    $Spotter->db = null;
831 831
 					    if ($globalDebug && isset($result)) echo $result."\n";
832 832
 					}
833 833
 				    }
834
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
834
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
835 835
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 
837 837
 				    // Add source stat in DB
838 838
 				    $Stats = new Stats($this->db);
839 839
 				    if (!empty($this->stats)) {
840 840
 					if ($globalDebug) echo 'Add source stats : ';
841
-				        foreach($this->stats as $date => $data) {
842
-					    foreach($data as $source => $sourced) {
841
+				        foreach ($this->stats as $date => $data) {
842
+					    foreach ($data as $source => $sourced) {
843 843
 					        //print_r($sourced);
844
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
844
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
845
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
846 846
 				    		if (isset($sourced['msg'])) {
847 847
 				    		    if (time() - $sourced['msg']['date'] > 10) {
848 848
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
849
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
849
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
850 850
 			    			        unset($this->stats[$date][$source]['msg']);
851 851
 			    			    }
852 852
 			    			}
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
885 885
 					    $SpotterLive = new SpotterLive($this->db);
886 886
 					    $SpotterLive->deleteLiveSpotterData();
887
-					    $SpotterLive->db=null;
887
+					    $SpotterLive->db = null;
888 888
 					}
889 889
 				    }
890 890
 				    if ($globalDebug) echo " Done\n";
891 891
 				    $this->last_delete = time();
892 892
 				}
893 893
 			    } else {
894
-				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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
894
+				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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
895 895
 				    $this->all_flights[$id]['id'] = $recent_ident;
896 896
 				    $this->all_flights[$id]['addedSpotter'] = 1;
897 897
 				}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901 901
 					    $Spotter = new Spotter($this->db);
902
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
902
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
903 903
 					    $Spotter->db = null;
904 904
 					}
905 905
 				    }
@@ -925,37 +925,37 @@  discard block
 block discarded – undo
925 925
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
926 926
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
927 927
 
928
-		    foreach($globalAirportIgnore as $airportIgnore) {
928
+		    foreach ($globalAirportIgnore as $airportIgnore) {
929 929
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930 930
 			    $ignoreImport = true;
931 931
 			}
932 932
 		    }
933 933
 		    if (count($globalAirportAccept) > 0) {
934 934
 		        $ignoreImport = true;
935
-		        foreach($globalAirportIgnore as $airportIgnore) {
935
+		        foreach ($globalAirportIgnore as $airportIgnore) {
936 936
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
937 937
 				$ignoreImport = false;
938 938
 			    }
939 939
 			}
940 940
 		    }
941 941
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
942
-			foreach($globalAirlineIgnore as $airlineIgnore) {
943
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
942
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
943
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
944 944
 				$ignoreImport = true;
945 945
 			    }
946 946
 			}
947 947
 		    }
948 948
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
949 949
 			$ignoreImport = true;
950
-			foreach($globalAirlineAccept as $airlineAccept) {
951
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
950
+			foreach ($globalAirlineAccept as $airlineAccept) {
951
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
952 952
 				$ignoreImport = false;
953 953
 			    }
954 954
 			}
955 955
 		    }
956 956
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
957 957
 			$ignoreImport = true;
958
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
958
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
959 959
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
960 960
 			        $ignoreImport = false;
961 961
 			    }
@@ -963,23 +963,23 @@  discard block
 block discarded – undo
963 963
 		    }
964 964
 
965 965
 		    if (!$ignoreImport) {
966
-			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'])) {
967
-				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')));
966
+			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'])) {
967
+				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')));
968 968
 				$timeelapsed = microtime(true);
969 969
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
970 970
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971 971
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
972 972
 					$SpotterLive = new SpotterLive($this->db);
973
-					$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
+					$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']);
974 974
 					$SpotterLive->db = null;
975 975
 					if ($globalDebug) echo $result."\n";
976 976
 				    }
977 977
 				}
978 978
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
979
-					$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
+					$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']);
980 980
 				}
981 981
 				$this->all_flights[$id]['putinarchive'] = false;
982
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
982
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
983 983
 
984 984
 				// Put statistics in $this->stats variable
985 985
 				//if ($line['format_source'] != 'aprs') {
@@ -998,19 +998,19 @@  discard block
 block discarded – undo
998 998
 							$latitude = $globalCenterLatitude;
999 999
 							$longitude = $globalCenterLongitude;
1000 1000
 						}
1001
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1001
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1002 1002
 					} else {
1003 1003
 						$latitude = $this->source_location[$source]['latitude'];
1004 1004
 						$longitude = $this->source_location[$source]['longitude'];
1005 1005
 					}
1006
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1006
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1007 1007
 					//$stats_heading = $stats_heading%22.5;
1008 1008
 					$stats_heading = round($stats_heading/22.5);
1009
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1009
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1010 1010
 					$current_date = date('Y-m-d');
1011 1011
 					if ($stats_heading == 16) $stats_heading = 0;
1012 1012
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1013
-						for ($i=0;$i<=15;$i++) {
1013
+						for ($i = 0; $i <= 15; $i++) {
1014 1014
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1015 1015
 						}
1016 1016
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1026 1026
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1027 1027
 						    end($this->stats[$current_date][$source]['hist']);
1028
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1028
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1029 1029
 						} else $mini = 0;
1030
-						for ($i=$mini;$i<=$distance;$i+=10) {
1030
+						for ($i = $mini; $i <= $distance; $i += 10) {
1031 1031
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1032 1032
 						}
1033 1033
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 				$this->all_flights[$id]['lastupdate'] = time();
1041 1041
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1042 1042
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1043
-			} 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";
1043
+			} 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";
1044 1044
 			//$this->del();
1045 1045
 			
1046 1046
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
header.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,35 +13,35 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 if (isset($_GET['3d'])) {
16
-	setcookie('MapFormat','3d');
16
+	setcookie('MapFormat', '3d');
17 17
 } else if (isset($_GET['2d'])) {
18
-	setcookie('MapFormat','2d');
18
+	setcookie('MapFormat', '2d');
19 19
 }
20 20
 
21 21
 if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
22
-	$tsk = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
22
+	$tsk = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
23 23
 }
24 24
 
25 25
 if (isset($_POST['archive'])) {
26
-	setcookie('archive','true');
27
-	setcookie('archive_begin',strtotime($_POST['start_date']));
28
-	setcookie('archive_end',strtotime($_POST['end_date']));
29
-	setcookie('archive_speed',$_POST['archivespeed']);
26
+	setcookie('archive', 'true');
27
+	setcookie('archive_begin', strtotime($_POST['start_date']));
28
+	setcookie('archive_end', strtotime($_POST['end_date']));
29
+	setcookie('archive_speed', $_POST['archivespeed']);
30 30
 }
31 31
 if (isset($_POST['noarchive'])) {
32
-	setcookie('archive','false',-1);
33
-	setcookie('archive_begin','',-1);
34
-	setcookie('archive_end','',-1);
35
-	setcookie('archive_speed','',-1);
32
+	setcookie('archive', 'false', -1);
33
+	setcookie('archive_begin', '', -1);
34
+	setcookie('archive_end', '', -1);
35
+	setcookie('archive_speed', '', -1);
36 36
 }
37 37
 // When button "Remove all filters" is clicked
38 38
 if (isset($_POST['removefilters'])) {
39
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
40
-	    return strpos($key,'filter_') === 0;
39
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
40
+	    return strpos($key, 'filter_') === 0;
41 41
 	});
42 42
 	foreach ($allfilters as $filt) {
43 43
 		unset($_COOKIE[$filt]);
44
-		setcookie($filt,null,-1);
44
+		setcookie($filt, null, -1);
45 45
 	}
46 46
 }
47 47
 ?>
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
247 247
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
248 248
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
249
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
249
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
250 250
 <?php
251 251
 		if (!isset($type) || $type == 'aircraft') {
252 252
 ?>
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
320 320
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
321 321
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
322
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
322
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
323 323
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
324 324
 <?php
325 325
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
 ?>
725 725
       <div class="search">
726 726
       <form action="<?php print $globalURL; ?>/search" method="get">
727
-		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
728
-		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != ""){ print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
727
+		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
728
+		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != "") { print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
729 729
 	</form>
730 730
 	</div>
731 731
   	<div class="social">
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	print '</div>';
744 744
 }
745 745
 
746
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
746
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
747 747
 ?>
748 748
     <div class="top-header clear" role="main">
749 749
 <?php
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     </div>
757 757
 <?php
758 758
 }
759
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
759
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
760 760
 {
761 761
     ?>
762 762
     <div class="top-header clear" role="main">
@@ -769,15 +769,15 @@  discard block
 block discarded – undo
769 769
         var zoom = 13;
770 770
 //create the map
771 771
 <?php
772
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
772
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
773 773
 ?>
774 774
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
775 775
 <?php
776
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
776
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
777 777
 ?>
778 778
   map = L.map('map', { zoomControl:true });
779 779
 <?php
780
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
780
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
781 781
 ?>
782 782
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
783 783
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
786 786
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
787 787
 <?php
788
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
788
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
789 789
 ?>
790 790
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
791 791
 <?php
Please login to merge, or discard this patch.
install/index.php 1 patch
Spacing   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 require_once(dirname(__FILE__).'/class.create_db.php');
23 23
 require_once(dirname(__FILE__).'/class.update_schema.php');
24 24
 require_once(dirname(__FILE__).'/class.settings.php');
25
-$title="Install";
25
+$title = "Install";
26 26
 require(dirname(__FILE__).'/../require/settings.php');
27 27
 require_once(dirname(__FILE__).'/../require/class.Common.php');
28 28
 require(dirname(__FILE__).'/header.php');
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	if (!extension_loaded('curl')) {
96 96
 		$error[] = "Curl is not loaded.";
97 97
 	}
98
-	if(function_exists('apache_get_modules') ){
99
-		if(!in_array('mod_rewrite',apache_get_modules())) {
98
+	if (function_exists('apache_get_modules')) {
99
+		if (!in_array('mod_rewrite', apache_get_modules())) {
100 100
 			$error[] = "mod_rewrite is not available.";
101 101
 		}
102 102
 	/*
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
113 113
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
114 114
 		if (function_exists('get_headers')) {
115
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
116
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
115
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
116
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
117 117
 				print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
118 118
 			}
119 119
 		}
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 ?>
485 485
 							<tr>
486 486
 								<?php
487
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
487
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
488 488
 								?>
489 489
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
490 490
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
491 491
 								<?php
492 492
 								    } else {
493
-									$hostport = explode(':',$source['host']);
493
+									$hostport = explode(':', $source['host']);
494 494
 									if (isset($hostport[1])) {
495 495
 										$host = $hostport[0];
496 496
 										$port = $hostport[1];
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 									<select name="timezones[]" id="timezones">
539 539
 								<?php
540 540
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
541
-									foreach($timezonelist as $timezones){
541
+									foreach ($timezonelist as $timezones) {
542 542
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
543 543
 											print '<option selected>'.$timezones.'</option>';
544 544
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 									<select name="timezones[]" id="timezones">
592 592
 								<?php
593 593
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
594
-									foreach($timezonelist as $timezones){
594
+									foreach ($timezonelist as $timezones) {
595 595
 										if ($timezones == 'UTC') {
596 596
 											print '<option selected>'.$timezones.'</option>';
597 597
 										} else print '<option>'.$timezones.'</option>';
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 			<br />
1001 1001
 			<p>
1002 1002
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1003
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1003
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1004 1004
 			</p>
1005 1005
 			<br />
1006 1006
 			<p>
@@ -1062,14 +1062,14 @@  discard block
 block discarded – undo
1062 1062
 $error = '';
1063 1063
 
1064 1064
 if (isset($_POST['dbtype'])) {
1065
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1066
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1067
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1068
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1069
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1070
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1071
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1072
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1065
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1066
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1067
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1068
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1069
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1070
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1071
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1072
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1073 1073
 
1074 1074
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1075 1075
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1089,49 +1089,49 @@  discard block
 block discarded – undo
1089 1089
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1090 1090
 	*/
1091 1091
 	
1092
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1092
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1093 1093
 
1094
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1095
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1096
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1097
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1098
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1094
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1095
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1096
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1097
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1098
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1099 1099
 
1100
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1101
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1102
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1103
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1104
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1105
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1106
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1107
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1108
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1109
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1100
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1101
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1102
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1103
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1104
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1105
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1106
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1107
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1108
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1109
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1110 1110
 	
1111
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1112
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1113
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1114
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1115
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1116
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1111
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1112
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1113
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1114
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1115
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1116
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1117 1117
 
1118
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1119
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1118
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1119
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1120 1120
 
1121
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1122
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1123
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1121
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1122
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1123
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1124 1124
 
1125
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1125
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1126 1126
 	if ($acars == 'acars') {
1127
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1127
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1128 1128
 	} else {
1129
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1129
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1130 1130
 	}
1131 1131
 
1132
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1133
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1134
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1132
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1133
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1134
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1135 1135
 	
1136 1136
 	$source_name = $_POST['source_name'];
1137 1137
 	$source_latitude = $_POST['source_latitude'];
@@ -1145,8 +1145,8 @@  discard block
 block discarded – undo
1145 1145
 	
1146 1146
 	$sources = array();
1147 1147
 	foreach ($source_name as $keys => $name) {
1148
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1149
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1148
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1149
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1150 1150
 	}
1151 1151
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1152 1152
 
@@ -1155,16 +1155,16 @@  discard block
 block discarded – undo
1155 1155
 	$newstype = $_POST['newstype'];
1156 1156
 	
1157 1157
 	$newsfeeds = array();
1158
-	foreach($newsurl as $newskey => $url) {
1158
+	foreach ($newsurl as $newskey => $url) {
1159 1159
 	    if ($url != '') {
1160 1160
 		$type = $newstype[$newskey];
1161 1161
 		$lng = $newslng[$newskey];
1162 1162
 		if (isset($newsfeeds[$type][$lng])) {
1163
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1163
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1164 1164
 		} else $newsfeeds[$type][$lng] = array($url);
1165 1165
 	    }
1166 1166
 	}
1167
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1167
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1168 1168
 
1169 1169
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1170 1170
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1175,27 +1175,27 @@  discard block
 block discarded – undo
1175 1175
 	$sbsurl = $_POST['sbsurl'];
1176 1176
 	*/
1177 1177
 
1178
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1179
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1180
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1181
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1182
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1183
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1184
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1185
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1178
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1179
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1180
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1181
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1182
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1183
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1184
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1185
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1186 1186
 
1187
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1188
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1189
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1190
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1191
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1192
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1193
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1194
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1196
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1197
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1198
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1187
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1188
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1189
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1190
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1191
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1192
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1193
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1194
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1195
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1196
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1197
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1198
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1199 1199
 
1200 1200
 /*	
1201 1201
 	$globalSBS1Hosts = array();
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 	}
1212 1212
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1213 1213
 */
1214
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1214
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1215 1215
 	$host = $_POST['host'];
1216 1216
 	$port = $_POST['port'];
1217 1217
 	$name = $_POST['name'];
@@ -1228,113 +1228,113 @@  discard block
 block discarded – undo
1228 1228
 		else $cov = 'FALSE';
1229 1229
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1230 1230
 		else $arch = 'FALSE';
1231
-		if (strpos($format[$key],'_callback')) {
1232
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1231
+		if (strpos($format[$key], '_callback')) {
1232
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1233 1233
 		} elseif ($h != '' || $name[$key] != '') {
1234
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1234
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1235 1235
 		}
1236 1236
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1237 1237
 	}
1238
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1238
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1239 1239
 
1240 1240
 /*
1241 1241
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1242 1242
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1243 1243
 */
1244
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1245
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1246
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1244
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1245
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1246
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1247 1247
 
1248
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1249
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1248
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1249
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1250 1250
 
1251
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1252
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1251
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1252
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1253 1253
 
1254
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1255
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1254
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1255
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1256 1256
 
1257
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1258
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1259
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1260
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1257
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1258
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1259
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1260
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1261 1261
 
1262
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1263
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1264
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1262
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1263
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1264
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1265 1265
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1266
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1267
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1266
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1267
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1268 1268
 
1269
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1270
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1271
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1272
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1273
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1274
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1275
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1276
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1269
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1270
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1271
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1272
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1273
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1274
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1275
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1276
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1277 1277
 
1278
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1279
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1278
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1279
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1280 1280
 
1281
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1282
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1281
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1282
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1283 1283
 	
1284
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1284
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1285 1285
 	if ($archiveyear == "archiveyear") {
1286
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1286
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1287 1287
 	} else {
1288
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1288
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1289 1289
 	}
1290
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1291
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1292
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1293
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1290
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1291
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1292
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1293
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1294 1294
 
1295
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1296
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1297
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1298
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1295
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1296
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1297
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1298
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1299 1299
 
1300
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1301
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1302
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1300
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1301
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1302
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1303 1303
 
1304 1304
 	// Create in settings.php keys not yet configurable if not already here
1305 1305
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1306
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1306
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1307 1307
 
1308
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1308
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1309 1309
 	if ($resetyearstats == 'resetyearstats') {
1310
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1310
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1311 1311
 	} else {
1312
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1312
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1313 1313
 	}
1314 1314
 
1315
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1315
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1316 1316
 	if ($archive == 'archive') {
1317
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1317
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1318 1318
 	} else {
1319
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1319
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1320 1320
 	}
1321
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1321
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1322 1322
 	if ($archiveresults == 'archiveresults') {
1323
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1323
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1324 1324
 	} else {
1325
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1325
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1326 1326
 	}
1327
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1327
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1328 1328
 	if ($daemon == 'daemon') {
1329
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1329
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1330 1330
 	} else {
1331
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1331
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1332 1332
 	}
1333
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1333
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1334 1334
 	if ($schedules == 'schedules') {
1335
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1335
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1336 1336
 	} else {
1337
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1337
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1338 1338
 	}
1339 1339
 
1340 1340
 /*
@@ -1345,252 +1345,252 @@  discard block
 block discarded – undo
1345 1345
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1346 1346
 	}
1347 1347
 */
1348
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1349
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1350
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1351
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1352
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1348
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1349
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1350
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1351
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1352
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1353 1353
 	$va = false;
1354 1354
 	if ($globalivao == 'ivao') {
1355
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1355
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1356 1356
 		$va = true;
1357
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1357
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1358 1358
 	if ($globalvatsim == 'vatsim') {
1359
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1359
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1360 1360
 		$va = true;
1361
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1361
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1362 1362
 	if ($globalphpvms == 'phpvms') {
1363
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1363
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1364 1364
 		$va = true;
1365
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1365
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1366 1366
 	if ($globalvam == 'vam') {
1367
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1367
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1368 1368
 		$va = true;
1369
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1369
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1370 1370
 	if ($va) {
1371
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1372
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1371
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1372
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1373 1373
 	if ($globalva == 'va' || $va) {
1374
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1375
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1374
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1375
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1376 1376
 	} else {
1377
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1378
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1379
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1377
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1378
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1379
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1380 1380
 	}
1381 1381
 	
1382 1382
 	
1383 1383
 
1384
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1384
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1385 1385
 	if ($notam == 'notam') {
1386
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1386
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1387 1387
 	} else {
1388
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1388
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1389 1389
 	}
1390
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1390
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1391 1391
 	if ($owner == 'owner') {
1392
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1392
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1393 1393
 	} else {
1394
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1394
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1395 1395
 	}
1396
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1396
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1397 1397
 	if ($map3d == 'map3d') {
1398
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1398
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1399 1399
 	} else {
1400
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1400
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1401 1401
 	}
1402
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1402
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1403 1403
 	if ($crash == 'crash') {
1404
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1404
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1405 1405
 	} else {
1406
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1406
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1407 1407
 	}
1408
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1408
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1409 1409
 	if ($fires == 'fires') {
1410
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1410
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1411 1411
 	} else {
1412
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1412
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1413 1413
 	}
1414
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1414
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1415 1415
 	if ($firessupport == 'firessupport') {
1416
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1416
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1417 1417
 	} else {
1418
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1418
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1419 1419
 	}
1420
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1420
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1421 1421
 	if ($mapsatellites == 'mapsatellites') {
1422
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1422
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1423 1423
 	} else {
1424
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1424
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1425 1425
 	}
1426
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1426
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1427 1427
 	if ($map3ddefault == 'map3ddefault') {
1428
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1428
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1429 1429
 	} else {
1430
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1430
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1431 1431
 	}
1432
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1432
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1433 1433
 	if ($map3dliveries == 'map3dliveries') {
1434
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1434
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1435 1435
 	} else {
1436
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1436
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1437 1437
 	}
1438
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1438
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1439 1439
 	if ($translate == 'translate') {
1440
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1440
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1441 1441
 	} else {
1442
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1442
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1443 1443
 	}
1444
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1444
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1445 1445
 	if ($realairlines == 'realairlines') {
1446
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1446
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1447 1447
 	} else {
1448
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1448
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1449 1449
 	}
1450
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1450
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1451 1451
 	if ($estimation == 'estimation') {
1452
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1452
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1453 1453
 	} else {
1454
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1454
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1455 1455
 	}
1456
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1456
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1457 1457
 	if ($metar == 'metar') {
1458
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1458
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1459 1459
 	} else {
1460
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1460
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1461 1461
 	}
1462
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1462
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1463 1463
 	if ($metarcycle == 'metarcycle') {
1464
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1464
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1465 1465
 	} else {
1466
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1466
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1467 1467
 	}
1468
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1468
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1469 1469
 	if ($fork == 'fork') {
1470
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1470
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1471 1471
 	} else {
1472
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1472
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1473 1473
 	}
1474 1474
 
1475
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1475
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1476 1476
 	if ($colormap == 'colormap') {
1477
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1477
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1478 1478
 	} else {
1479
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1479
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1480 1480
 	}
1481 1481
 	
1482 1482
 	if (isset($_POST['aircrafticoncolor'])) {
1483
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1484
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1483
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1484
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1485 1485
 	}
1486 1486
 
1487
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1488
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1487
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1488
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1489 1489
 
1490
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1491
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1492
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1493
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1494
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1495
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1490
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1491
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1492
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1493
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1494
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1495
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1496 1496
 
1497
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1497
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1498 1498
 	if ($mappopup == 'mappopup') {
1499
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1499
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1500 1500
 	} else {
1501
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1501
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1502 1502
 	}
1503
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1503
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1504 1504
 	if ($airportpopup == 'airportpopup') {
1505
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1505
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1506 1506
 	} else {
1507
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1507
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1508 1508
 	}
1509
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1509
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1510 1510
 	if ($maphistory == 'maphistory') {
1511
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1511
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1512 1512
 	} else {
1513
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1513
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1514 1514
 	}
1515
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1515
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1516 1516
 	if ($maptooltip == 'maptooltip') {
1517
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1517
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1518 1518
 	} else {
1519
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1519
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1520 1520
 	}
1521
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1521
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1522 1522
 	if ($flightroute == 'flightroute') {
1523
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1523
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1524 1524
 	} else {
1525
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1525
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1526 1526
 	}
1527
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1527
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1528 1528
 	if ($flightremainingroute == 'flightremainingroute') {
1529
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1529
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1530 1530
 	} else {
1531
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1531
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1532 1532
 	}
1533
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1533
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1534 1534
 	if ($allflights == 'allflights') {
1535
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1535
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1536 1536
 	} else {
1537
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1537
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1538 1538
 	}
1539
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1539
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1540 1540
 	if ($bbox == 'bbox') {
1541
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1541
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1542 1542
 	} else {
1543
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1543
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1544 1544
 	}
1545
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1545
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1546 1546
 	if ($groundaltitude == 'groundaltitude') {
1547
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1547
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1548 1548
 	} else {
1549
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1549
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1550 1550
 	}
1551
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1551
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1552 1552
 	if ($waypoints == 'waypoints') {
1553
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1553
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1554 1554
 	} else {
1555
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1555
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1556 1556
 	}
1557
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1557
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1558 1558
 	if ($geoid == 'geoid') {
1559
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1559
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1560 1560
 	} else {
1561
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1561
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1562 1562
 	}
1563
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1564
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1563
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1564
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1565 1565
 
1566
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1566
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1567 1567
 	if ($noairlines == 'noairlines') {
1568
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1568
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1569 1569
 	} else {
1570
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1570
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1571 1571
 	}
1572 1572
 
1573
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1573
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1574 1574
 	if ($tsk == 'tsk') {
1575
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1575
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1576 1576
 	} else {
1577
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1577
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1578 1578
 	}
1579 1579
 
1580
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1580
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1581 1581
 
1582 1582
 	// Set some defaults values...
1583 1583
 	if (!isset($globalAircraftImageSources)) {
1584
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1585
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1584
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1585
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1586 1586
 	}
1587 1587
 
1588 1588
 	if (!isset($globalSchedulesSources)) {
1589
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1590
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1589
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1590
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1591 1591
     	}
1592 1592
 
1593
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1593
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1594 1594
 
1595 1595
 	if ($error == '') settings::modify_settings($settings);
1596 1596
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.