Completed
Push — master ( c0278b...990a68 )
by Yannick
09:48
created
require/class.SpotterLive.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$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";
39
+						$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 40
 					} else {
41
-						$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";
41
+						$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 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$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";
47
+					$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 48
 				} else {
49
-					$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";
49
+					$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 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$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";
54
+					$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 55
 				} else {
56
-					$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";
56
+					$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 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$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";
61
+					$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 62
 				} else {
63
-					$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";
63
+					$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 64
 				}
65 65
 			}
66 66
 			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']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$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";
68
+					$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 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$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";
74
+				$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 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$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 ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$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";
84
+			$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 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$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";
116
+			$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";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		} else {
170 170
 			$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;
171 171
 		}
172
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
172
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
173 173
 
174 174
 		return $spotter_array;
175 175
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	{
185 185
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 186
 		date_default_timezone_set('UTC');
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			$sth = $this->db->prepare($query);
209 209
 			$sth->execute();
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			echo $e->getMessage();
212 212
 			die;
213 213
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
227 227
 		date_default_timezone_set('UTC');
228 228
 
229
-		$filter_query = $this->getFilter($filter,true,true);
229
+		$filter_query = $this->getFilter($filter, true, true);
230 230
 
231 231
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
232 232
 		if ($globalDBdriver == 'mysql') {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
238 238
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
239 239
 				*/
240
-				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
240
+				$query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
241 241
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
242 242
 				UNION
243 243
 				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 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				WHERE latitude <> '0' AND longitude <> '0' 
246 246
 				ORDER BY flightaware_id, date";
247 247
 			} else {
248
-				$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 
248
+				$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 
249 249
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date 
250 250
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
251 251
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
259 259
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
260 260
                                */
261
-				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
261
+				$query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
262 262
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
263 263
 				UNION
264 264
 				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 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				ORDER BY flightaware_id, date";
269 269
 				//AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".round($globalLiveInterval*1000)." SECONDS' <= spotter_archive.date
270 270
 			} else {
271
-				$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 
271
+				$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 
272 272
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date
273 273
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
274 274
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     		try {
278 278
 			$sth = $this->db->prepare($query);
279 279
 			$sth->execute();
280
-		} catch(PDOException $e) {
280
+		} catch (PDOException $e) {
281 281
 			echo $e->getMessage();
282 282
 			die;
283 283
 		}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	public function getLiveSpotterCount($filter = array())
295 295
 	{
296 296
 		global $globalDBdriver, $globalLiveInterval;
297
-		$filter_query = $this->getFilter($filter,true,true);
297
+		$filter_query = $this->getFilter($filter, true, true);
298 298
 
299 299
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
300 300
 		if ($globalDBdriver == 'mysql') {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		try {
308 308
 			$sth = $this->db->prepare($query);
309 309
 			$sth->execute();
310
-		} catch(PDOException $e) {
310
+		} catch (PDOException $e) {
311 311
 			echo $e->getMessage();
312 312
 			die;
313 313
 		}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		$filter_query = $this->getFilter($filter);
331 331
 
332 332
 		if (is_array($coord)) {
333
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
334
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
335
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
333
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
334
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
335
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
336
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
337 337
 		} else return array();
338 338
 		if ($globalDBdriver == 'mysql') {
339 339
 			$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;
@@ -356,23 +356,23 @@  discard block
 block discarded – undo
356 356
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
357 357
 		$Spotter = new Spotter($this->db);
358 358
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
-		$filter_query = $this->getFilter($filter,true,true);
359
+		$filter_query = $this->getFilter($filter, true, true);
360 360
 
361 361
 		if (is_array($coord)) {
362
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
363
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
364
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
365
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
362
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
363
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
364
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
365
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
366 366
 		} else return array();
367 367
 		if ($globalDBdriver == 'mysql') {
368 368
 			if (isset($globalArchive) && $globalArchive === TRUE) {
369
-				$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 
369
+				$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 
370 370
 				FROM spotter_live 
371 371
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
372 372
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
373 373
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
374 374
 			} else {
375
-				$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 
375
+				$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 
376 376
 				FROM spotter_live 
377 377
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
378 378
 				    FROM spotter_live l 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 			}
385 385
 		} else {
386 386
 			if (isset($globalArchive) && $globalArchive === TRUE) {
387
-				$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 
387
+				$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 
388 388
 				FROM spotter_live 
389 389
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
390 390
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
391 391
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
392 392
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
393 393
 			} else {
394
-				$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 
394
+				$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 
395 395
 				FROM spotter_live 
396 396
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
397 397
 				    FROM spotter_live l 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$sth = $this->db->prepare($query);
408 408
 			$sth->execute();
409
-		} catch(PDOException $e) {
409
+		} catch (PDOException $e) {
410 410
 			echo $e->getMessage();
411 411
 			die;
412 412
 		}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 if ($interval == '1m')
456 456
                 {
457 457
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
458
-                } else if ($interval == '15m'){
458
+                } else if ($interval == '15m') {
459 459
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
460 460
                 } 
461 461
             }
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
464 464
         }
465 465
 
466
-                $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 
466
+                $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 
467 467
                    WHERE spotter_live.latitude <> '' 
468 468
                                    AND spotter_live.longitude <> '' 
469 469
                    ".$additional_query."
470 470
                    HAVING distance < :radius  
471 471
                                    ORDER BY distance";
472 472
 
473
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
473
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
474 474
 
475 475
                 return $spotter_array;
476 476
         }
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 		date_default_timezone_set('UTC');
489 489
 
490 490
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
491
-                $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';
491
+                $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';
492 492
 
493
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
493
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
494 494
 
495 495
 		return $spotter_array;
496 496
 	}
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 	* @return Array the spotter information
502 502
 	*
503 503
 	*/
504
-	public function getDateLiveSpotterDataByIdent($ident,$date)
504
+	public function getDateLiveSpotterDataByIdent($ident, $date)
505 505
 	{
506 506
 		$Spotter = new Spotter($this->db);
507 507
 		date_default_timezone_set('UTC');
508 508
 
509 509
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
510
-                $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';
510
+                $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';
511 511
 
512
-                $date = date('c',$date);
513
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
512
+                $date = date('c', $date);
513
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
514 514
 
515 515
 		return $spotter_array;
516 516
 	}
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 		$Spotter = new Spotter($this->db);
527 527
 		date_default_timezone_set('UTC');
528 528
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
529
-		$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';
530
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
529
+		$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';
530
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
531 531
 		return $spotter_array;
532 532
 	}
533 533
 
@@ -537,15 +537,15 @@  discard block
 block discarded – undo
537 537
 	* @return Array the spotter information
538 538
 	*
539 539
 	*/
540
-	public function getDateLiveSpotterDataById($id,$date)
540
+	public function getDateLiveSpotterDataById($id, $date)
541 541
 	{
542 542
 		$Spotter = new Spotter($this->db);
543 543
 		date_default_timezone_set('UTC');
544 544
 
545 545
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
546
-		$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';
547
-		$date = date('c',$date);
548
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
546
+		$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';
547
+		$date = date('c', $date);
548
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
549 549
 		return $spotter_array;
550 550
 	}
551 551
 
@@ -561,13 +561,13 @@  discard block
 block discarded – undo
561 561
 		date_default_timezone_set('UTC');
562 562
 
563 563
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
564
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
564
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
565 565
 
566 566
     		try {
567 567
 			
568 568
 			$sth = $this->db->prepare($query);
569 569
 			$sth->execute(array(':ident' => $ident));
570
-		} catch(PDOException $e) {
570
+		} catch (PDOException $e) {
571 571
 			echo $e->getMessage();
572 572
 			die;
573 573
 		}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	* @return Array the spotter information
583 583
 	*
584 584
 	*/
585
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
585
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
586 586
 	{
587 587
 		global $globalDBdriver, $globalLiveInterval;
588 588
 		date_default_timezone_set('UTC');
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		try {
602 602
 			$sth = $this->db->prepare($query);
603 603
 			$sth->execute(array(':id' => $id));
604
-		} catch(PDOException $e) {
604
+		} catch (PDOException $e) {
605 605
 			echo $e->getMessage();
606 606
 			die;
607 607
 		}
@@ -619,12 +619,12 @@  discard block
 block discarded – undo
619 619
 	{
620 620
 		date_default_timezone_set('UTC');
621 621
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
622
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
622
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
623 623
     		try {
624 624
 			
625 625
 			$sth = $this->db->prepare($query);
626 626
 			$sth->execute(array(':ident' => $ident));
627
-		} catch(PDOException $e) {
627
+		} catch (PDOException $e) {
628 628
 			echo $e->getMessage();
629 629
 			die;
630 630
 		}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			
655 655
 			$sth = $this->db->prepare($query);
656 656
 			$sth->execute();
657
-		} catch(PDOException $e) {
657
+		} catch (PDOException $e) {
658 658
 			return "error";
659 659
 		}
660 660
 
@@ -677,14 +677,14 @@  discard block
 block discarded – undo
677 677
 				
678 678
 				$sth = $this->db->prepare($query);
679 679
 				$sth->execute();
680
-			} catch(PDOException $e) {
680
+			} catch (PDOException $e) {
681 681
 				return "error";
682 682
 			}
683 683
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
684 684
                         $i = 0;
685
-                        $j =0;
685
+                        $j = 0;
686 686
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
687
-			foreach($all as $row)
687
+			foreach ($all as $row)
688 688
 			{
689 689
 				$i++;
690 690
 				$j++;
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 					if ($globalDebug) echo ".";
693 693
 				    	try {
694 694
 						
695
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
695
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
696 696
 						$sth->execute();
697
-					} catch(PDOException $e) {
697
+					} catch (PDOException $e) {
698 698
 						return "error";
699 699
 					}
700 700
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
 			if ($i > 0) {
706 706
     				try {
707 707
 					
708
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
708
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
709 709
 					$sth->execute();
710
-				} catch(PDOException $e) {
710
+				} catch (PDOException $e) {
711 711
 					return "error";
712 712
 				}
713 713
 			}
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				
721 721
 				$sth = $this->db->prepare($query);
722 722
 				$sth->execute();
723
-			} catch(PDOException $e) {
723
+			} catch (PDOException $e) {
724 724
 				return "error";
725 725
 			}
726 726
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	public function deleteLiveSpotterDataByIdent($ident)
769 769
 	{
770 770
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
771
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
771
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
772 772
         
773 773
     		try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':ident' => $ident));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			return "error";
779 779
 		}
780 780
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function deleteLiveSpotterDataById($id)
791 791
 	{
792 792
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
793
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
793
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
794 794
         
795 795
     		try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':id' => $id));
799
-		} catch(PDOException $e) {
799
+		} catch (PDOException $e) {
800 800
 			return "error";
801 801
 		}
802 802
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
816 816
 		if ($globalDBdriver == 'mysql') {
817
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
817
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
818 818
 				WHERE spotter_live.ident = :ident 
819 819
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
820 820
 				AND spotter_live.date < UTC_TIMESTAMP()';
821 821
 			$query_data = array(':ident' => $ident);
822 822
 		} else {
823
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
823
+			$query = "SELECT spotter_live.ident FROM spotter_live 
824 824
 				WHERE spotter_live.ident = :ident 
825 825
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
826 826
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		$sth = $this->db->prepare($query);
831 831
 		$sth->execute($query_data);
832
-		$ident_result='';
833
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
832
+		$ident_result = '';
833
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
834 834
 		{
835 835
 			$ident_result = $row['ident'];
836 836
 		}
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
849 849
 		if ($globalDBdriver == 'mysql') {
850
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
850
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
851 851
 				WHERE spotter_live.ident = :ident 
852 852
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
853 853
 //				AND spotter_live.date < UTC_TIMESTAMP()";
854 854
 			$query_data = array(':ident' => $ident);
855 855
 		} else {
856
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
856
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
857 857
 				WHERE spotter_live.ident = :ident 
858 858
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
859 859
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		
863 863
 		$sth = $this->db->prepare($query);
864 864
 		$sth->execute($query_data);
865
-		$ident_result='';
866
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
865
+		$ident_result = '';
866
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
867 867
 		{
868 868
 			$ident_result = $row['flightaware_id'];
869 869
 		}
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
 	{
881 881
 		global $globalDBdriver, $globalTimezone;
882 882
 		if ($globalDBdriver == 'mysql') {
883
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
883
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
884 884
 				WHERE spotter_live.flightaware_id = :id 
885 885
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
886 886
 //				AND spotter_live.date < UTC_TIMESTAMP()";
887 887
 			$query_data = array(':id' => $id);
888 888
 		} else {
889
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
889
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
890 890
 				WHERE spotter_live.flightaware_id = :id 
891 891
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
892 892
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 		
896 896
 		$sth = $this->db->prepare($query);
897 897
 		$sth->execute($query_data);
898
-		$ident_result='';
899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
898
+		$ident_result = '';
899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
900 900
 		{
901 901
 			$ident_result = $row['flightaware_id'];
902 902
 		}
@@ -913,13 +913,13 @@  discard block
 block discarded – undo
913 913
 	{
914 914
 		global $globalDBdriver, $globalTimezone;
915 915
 		if ($globalDBdriver == 'mysql') {
916
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
916
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
917 917
 				WHERE spotter_live.ModeS = :modes 
918 918
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
919 919
 //				AND spotter_live.date < UTC_TIMESTAMP()";
920 920
 			$query_data = array(':modes' => $modes);
921 921
 		} else {
922
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
922
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
923 923
 				WHERE spotter_live.ModeS = :modes 
924 924
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
925 925
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 		
929 929
 		$sth = $this->db->prepare($query);
930 930
 		$sth->execute($query_data);
931
-		$ident_result='';
932
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
931
+		$ident_result = '';
932
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
933 933
 		{
934 934
 			//$ident_result = $row['spotter_live_id'];
935 935
 			$ident_result = $row['flightaware_id'];
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 	* @return String success or false
949 949
 	*
950 950
 	*/
951
-	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 = '')
951
+	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 = '')
952 952
 	{
953 953
 		global $globalURL, $globalArchive, $globalDebug;
954 954
 		$Common = new Common();
@@ -1048,27 +1048,27 @@  discard block
 block discarded – undo
1048 1048
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1049 1049
 
1050 1050
         
1051
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1052
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1053
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1054
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1055
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1056
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1057
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1058
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1059
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1060
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1061
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1062
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1064
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1065
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1066
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1067
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1068
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1069
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1070
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1071
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1051
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1052
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1053
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1054
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1055
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1056
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1057
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1058
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1059
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1060
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1061
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1062
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1064
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1065
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1066
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1067
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1068
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1069
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1070
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1071
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1072 1072
 
1073 1073
 		$airline_name = '';
1074 1074
 		$airline_icao = '';
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 		$arrival_airport_country = '';
1091 1091
 		
1092 1092
             	
1093
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1094
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1095
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1096
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1093
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1094
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1095
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1096
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1097 1097
 		
1098 1098
 		$query = '';
1099 1099
 		if ($globalArchive) {
@@ -1104,19 +1104,19 @@  discard block
 block discarded – undo
1104 1104
 		$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) 
1105 1105
 		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)';
1106 1106
 
1107
-		$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);
1107
+		$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);
1108 1108
 		try {
1109 1109
 			
1110 1110
 			$sth = $this->db->prepare($query);
1111 1111
 			$sth->execute($query_values);
1112 1112
 			$sth->closeCursor();
1113
-		} catch(PDOException $e) {
1113
+		} catch (PDOException $e) {
1114 1114
 			return "error : ".$e->getMessage();
1115 1115
 		}
1116 1116
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1117 1117
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1118 1118
 		    $SpotterArchive = new SpotterArchive($this->db);
1119
-		    $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);
1119
+		    $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);
1120 1120
 		    if ($globalDebug) echo $result.')';
1121 1121
 		} elseif ($globalDebug && $putinarchive !== true) {
1122 1122
 			echo '(Not adding to archive)';
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 	public function getOrderBy()
1131 1131
 	{
1132
-		$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"));
1132
+		$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"));
1133 1133
 		return $orderby;
1134 1134
 	}
1135 1135
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 2 patches
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $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']);
99
+		    $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']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$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']));
107
+		$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']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} 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))) {
163
+        	} 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))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
 	    if (isset($flight['lastupdate'])) {
187
-		if ($flight['lastupdate'] < (time()-5900)) {
187
+		if ($flight['lastupdate'] < (time() - 5900)) {
188 188
 		    $this->delKey($key);
189 189
 		}
190 190
 	    }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$real_arrival = $this->arrival($key);
201 201
 			$Spotter = new Spotter($this->db);
202 202
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203
-				$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']);
203
+				$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']);
204 204
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205 205
 			}
206 206
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
239 239
   	    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)) {
@@ -269,25 +269,25 @@  discard block
 block discarded – undo
269 269
 		if (!isset($this->all_flights[$id])) {
270 270
 		    if ($globalDebug) echo 'New flight...'."\n";
271 271
 		    $this->all_flights[$id] = array();
272
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
273
-		    $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' => ''));
274
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
273
+		    $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' => ''));
274
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
275 275
 		    if (!isset($line['id'])) {
276 276
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
277 277
 //			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')));
278 278
 //			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')));
279
-			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')));
279
+			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')));
280 280
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
281
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
281
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
282 282
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
283 283
 		}
284 284
 		if (isset($line['source_type']) && $line['source_type'] != '') {
285
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
285
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
286 286
 		}
287 287
 		
288 288
 		//print_r($this->all_flights);
289 289
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
290
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
291 291
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
292 292
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
293 293
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
297 297
 			    $Spotter = new Spotter($this->db);
298 298
 			    if (isset($this->all_flights[$id]['source_type'])) {
299
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
299
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
300 300
 			    } else {
301 301
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
302 302
 			    }
303 303
 			    $Spotter->db = null;
304
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
304
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
305
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
306 306
 			}
307 307
 		    }
308 308
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
309 309
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
310 310
 		}
311 311
 	        if (isset($line['id']) && !isset($line['hex'])) {
312
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
312
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
313 313
 	        }
314 314
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
315 315
 			$icao = $line['aircraft_icao'];
316 316
 			$Spotter = new Spotter($this->db);
317 317
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
318 318
 			$Spotter->db = null;
319
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
319
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
320 320
 		}
321 321
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
322 322
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				$Spotter = new Spotter($this->db);
325 325
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
326 326
 				$Spotter->db = null;
327
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
327
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
328 328
 			}
329 329
 		}
330 330
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -332,15 +332,15 @@  discard block
 block discarded – undo
332 332
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
333 333
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
334 334
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
335
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
335
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
336 336
 		}
337 337
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
339 339
 		}
340 340
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
341
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
341
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
342 342
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
343
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
343
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
344 344
 		    } else {
345 345
 				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";
346 346
 				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";
@@ -351,32 +351,32 @@  discard block
 block discarded – undo
351 351
 				*/
352 352
 				return '';
353 353
 		    }
354
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
354
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
355 355
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
356 356
 			return '';
357
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
357
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
358 358
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
359 359
 			";
360 360
 			return '';
361 361
 		} elseif (!isset($line['datetime'])) {
362 362
 			date_default_timezone_set('UTC');
363
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
364 364
 		} else {
365 365
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
366 366
 			return '';
367 367
 		}
368 368
 
369 369
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
370
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
370
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
371 371
 		}
372 372
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
373
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
373
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
374 374
 		}
375 375
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
376
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
376
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
377 377
 		}
378 378
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
379
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
379
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
380 380
 		}
381 381
  
382 382
 		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'])) {
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
385 385
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
386 386
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
387
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
388
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
389
-				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')));
390
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
391
-				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']));
387
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
388
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
389
+				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')));
390
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
391
+				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']));
392 392
 			} else {
393
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
393
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
394 394
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395 395
 				$timeelapsed = microtime(true);
396 396
             			$Spotter = new Spotter($this->db);
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
401 401
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
402 402
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
403
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
403
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
404 404
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
405 405
 				$Spotter->db = null;
406
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
406
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
407 407
 			    }
408 408
 			}
409
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
409
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
410 410
 		    
411 411
 /*
412 412
 		    if (!isset($line['id'])) {
@@ -416,25 +416,25 @@  discard block
 block discarded – undo
416 416
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
417 417
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
418 418
   */
419
-		    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']));
419
+		    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']));
420 420
 
421 421
 		    //$putinarchive = true;
422 422
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
423
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
423
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
424 424
 		    }
425 425
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
426
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
426
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
427 427
 		    }
428 428
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
429
-		    		$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' => ''));
429
+		    		$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' => ''));
430 430
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
431 431
 			$timeelapsed = microtime(true);
432 432
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433 433
 				$Spotter = new Spotter($this->db);
434 434
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
435 435
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
436
-		    		$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' => ''));
437
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
436
+		    		$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' => ''));
437
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
438 438
                         }
439 439
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
440 440
 			$timeelapsed = microtime(true);
@@ -448,35 +448,35 @@  discard block
 block discarded – undo
448 448
 				$Translation->db = null;
449 449
 			    }
450 450
 			    $Spotter->db = null;
451
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
452 452
                     	}
453 453
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
454 454
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
455 455
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
456 456
 				//    $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']));
457
-		    		$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']));
457
+		    		$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']));
458 458
 		    	    }
459 459
 			}
460 460
 			if (!isset($globalFork)) $globalFork = TRUE;
461 461
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
462
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
462
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
463 463
 			}
464 464
 		    }
465 465
 		}
466 466
 
467 467
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
468 468
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
469
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
470
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
469
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
470
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
471 471
 		    //$dataFound = true;
472 472
 		} 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'])) {
473
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
473
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
474 474
 		    if ($distance > 1000 && $distance < 10000) {
475 475
 		    // use datetime
476 476
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
477 477
 			$speed = $speed*3.6;
478 478
 			if ($speed < 1000) {
479
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
479
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
480 480
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
481 481
 	  		} else {
482 482
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
492 492
 	    	    	return false;
493 493
 	    	    }
494
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
494
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
495 495
 	    	    else unset($timediff);
496
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
496
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
497 497
 	    	    else unset($timediff_archive);
498 498
 	    	    if ($this->tmd > 5
499 499
 	    	        || (isset($line['format_source']) 
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
 	    	    	|| ($timediff > 30 
518 518
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
519 519
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
520
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
520
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
521 521
 	    	    	    )
522 522
 	    	    	) {
523 523
 
524 524
 			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']))) {
525 525
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
526 526
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
527
-				|| !$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'])) {
527
+				|| !$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'])) {
528 528
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
529 529
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
530 530
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 				    $timeelapsed = microtime(true);
535 535
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
536 536
 					$Spotter = new Spotter($this->db);
537
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
537
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
538 538
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
539 539
 					else $this->all_flights[$id]['over_country'] = '';
540 540
 					$Spotter->db = null;
541
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
542 542
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
543 543
 				    }
544 544
 				}
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 					$this->all_flights[$id]['time_last_coord'] = time();
565 565
 				}
566 566
 				//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)) {
567
-				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)) {
567
+				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)) {
568 568
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
569 569
 				    $dataFound = true;
570 570
 				    $this->all_flights[$id]['time_last_coord'] = time();
571 571
 				}
572 572
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
573
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
573
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
574 574
 				/*
575 575
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
576 576
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 					$this->all_flights[$id]['time_last_coord'] = time();
593 593
 				}
594 594
 				//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)) {
595
-				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)) {
595
+				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)) {
596 596
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
597 597
 				    $dataFound = true;
598 598
 				    $this->all_flights[$id]['time_last_coord'] = time();
599 599
 				}
600 600
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
601
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
601
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
602 602
 				/*
603 603
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
604 604
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -616,46 +616,46 @@  discard block
 block discarded – undo
616 616
 		    } else if ($globalDebug && $timediff > 30) {
617 617
 			$this->tmd = $this->tmd + 1;
618 618
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
619
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
620
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
619
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
620
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
621 621
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
622 622
 		    }
623 623
 		}
624 624
 		if (isset($line['last_update']) && $line['last_update'] != '') {
625 625
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
626
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
626
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
627 627
 		}
628 628
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
629
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
629
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
630 630
 		    //$dataFound = true;
631 631
 		}
632 632
 		if (isset($line['format_source']) && $line['format_source'] != '') {
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
633
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
634 634
 		}
635 635
 		if (isset($line['source_name']) && $line['source_name'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
637 637
 		}
638 638
 		if (isset($line['emergency']) && $line['emergency'] != '') {
639
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
639
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
640 640
 		    //$dataFound = true;
641 641
 		}
642 642
 		if (isset($line['ground']) && $line['ground'] != '') {
643 643
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
644 644
 			// Here we force archive of flight because after ground it's a new one (or should be)
645
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
646
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
647
-			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')));
648
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
649
-			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']));
645
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
646
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
647
+			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')));
648
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
649
+			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']));
650 650
 		    }
651 651
 		    if ($line['ground'] != 1) $line['ground'] = 0;
652
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
652
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
653 653
 		    //$dataFound = true;
654 654
 		}
655 655
 		if (isset($line['squawk']) && $line['squawk'] != '') {
656 656
 		    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'])) {
657 657
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
658
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
658
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
659 659
 			    $highlight = '';
660 660
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
661 661
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -664,59 +664,59 @@  discard block
 block discarded – undo
664 664
 				$timeelapsed = microtime(true);
665 665
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
666 666
 				    $Spotter = new Spotter($this->db);
667
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
667
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
668 668
 				    $Spotter->db = null;
669
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
669
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
670 670
 				}
671 671
 				//$putinarchive = true;
672 672
 				//$highlight = '';
673 673
 			    }
674 674
 			    
675
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
676 676
 		    //$dataFound = true;
677 677
 		}
678 678
 
679 679
 		if (isset($line['altitude']) && $line['altitude'] != '') {
680 680
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
681
-			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;
682
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
683
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
681
+			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;
682
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
683
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
684 684
 			//$dataFound = true;
685 685
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
686 686
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
687 687
 			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) {
688 688
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
689
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
690
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
691
-				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')));
692
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
693
-				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']));
689
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
690
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
691
+				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')));
692
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
693
+				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']));
694 694
 			}
695 695
 		    }
696
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
696
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
697 697
 		}
698 698
 
699 699
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
700
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
700
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
701 701
 		}
702 702
 		
703 703
 		if (isset($line['heading']) && $line['heading'] != '') {
704
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
705
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
706
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
704
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
705
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
706
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
707 707
 		    //$dataFound = true;
708 708
   		} 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']) {
709
-  		    $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']);
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
711
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
709
+  		    $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']);
710
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
711
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
712 712
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
713 713
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
714 714
   		    // If not enough messages and ACARS set heading to 0
715
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
715
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
716 716
   		}
717
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
717
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
720 720
 
721 721
 //		print_r($this->all_flights[$id]);
722 722
 		//gets the callsign from the last hour
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
728 728
 		    $this->all_flights[$id]['lastupdate'] = time();
729 729
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
730
-		        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'])) {
730
+		        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'])) {
731 731
 			    //print_r($this->all_flights);
732 732
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
733 733
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -738,61 +738,61 @@  discard block
 block discarded – undo
738 738
 				    $SpotterLive = new SpotterLive($this->db);
739 739
 				    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')) {
740 740
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
741
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
741
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
742 742
 				    } elseif (isset($line['id'])) {
743 743
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
744
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
744
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
745 745
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
746 746
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
747
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
747
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
748 748
 				    } else $recent_ident = '';
749
-				    $SpotterLive->db=null;
749
+				    $SpotterLive->db = null;
750 750
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
751 751
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
752 752
 				} else $recent_ident = '';
753 753
 			    } else {
754 754
 				$recent_ident = '';
755
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
755
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
756 756
 			    }
757 757
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
758
-			    if($recent_ident == "")
758
+			    if ($recent_ident == "")
759 759
 			    {
760 760
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
761 761
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762 762
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 763
 				//adds the spotter data for the archive
764 764
 				$ignoreImport = false;
765
-				foreach($globalAirportIgnore as $airportIgnore) {
765
+				foreach ($globalAirportIgnore as $airportIgnore) {
766 766
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
767 767
 					$ignoreImport = true;
768 768
 				    }
769 769
 				}
770 770
 				if (count($globalAirportAccept) > 0) {
771 771
 				    $ignoreImport = true;
772
-				    foreach($globalAirportIgnore as $airportIgnore) {
772
+				    foreach ($globalAirportIgnore as $airportIgnore) {
773 773
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
774 774
 					    $ignoreImport = false;
775 775
 					}
776 776
 				    }
777 777
 				}
778 778
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
779
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
780
-					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)) {
779
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
780
+					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)) {
781 781
 					    $ignoreImport = true;
782 782
 					}
783 783
 				    }
784 784
 				}
785 785
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
786 786
 				    $ignoreImport = true;
787
-				    foreach($globalAirlineAccept as $airlineAccept) {
788
-					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)) {
787
+				    foreach ($globalAirlineAccept as $airlineAccept) {
788
+					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)) {
789 789
 					    $ignoreImport = false;
790 790
 					}
791 791
 				    }
792 792
 				}
793 793
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
794 794
 				    $ignoreImport = true;
795
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
795
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
796 796
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
797 797
 					    $ignoreImport = false;
798 798
 					}
@@ -804,32 +804,32 @@  discard block
 block discarded – undo
804 804
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
805 805
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
806 806
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
807
-				    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')));
807
+				    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')));
808 808
 				    $timeelapsed = microtime(true);
809 809
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
810 810
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
811 811
 					    $Spotter = new Spotter($this->db);
812
-					    $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']);
812
+					    $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']);
813 813
 					    $Spotter->db = null;
814 814
 					    if ($globalDebug && isset($result)) echo $result."\n";
815 815
 					}
816 816
 				    }
817
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
817
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
818 818
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
819 819
 
820 820
 				    // Add source stat in DB
821 821
 				    $Stats = new Stats($this->db);
822 822
 				    if (!empty($this->stats)) {
823 823
 					if ($globalDebug) echo 'Add source stats : ';
824
-				        foreach($this->stats as $date => $data) {
825
-					    foreach($data as $source => $sourced) {
824
+				        foreach ($this->stats as $date => $data) {
825
+					    foreach ($data as $source => $sourced) {
826 826
 					        //print_r($sourced);
827
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
828
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
827
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
828
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
829 829
 				    		if (isset($sourced['msg'])) {
830 830
 				    		    if (time() - $sourced['msg']['date'] > 10) {
831 831
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
832
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
832
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
833 833
 			    			        unset($this->stats[$date][$source]['msg']);
834 834
 			    			    }
835 835
 			    			}
@@ -867,14 +867,14 @@  discard block
 block discarded – undo
867 867
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
868 868
 					    $SpotterLive = new SpotterLive($this->db);
869 869
 					    $SpotterLive->deleteLiveSpotterData();
870
-					    $SpotterLive->db=null;
870
+					    $SpotterLive->db = null;
871 871
 					}
872 872
 				    }
873 873
 				    if ($globalDebug) echo " Done\n";
874 874
 				    $this->last_delete = time();
875 875
 				}
876 876
 			    } else {
877
-				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')) {
877
+				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')) {
878 878
 				    $this->all_flights[$id]['id'] = $recent_ident;
879 879
 				    $this->all_flights[$id]['addedSpotter'] = 1;
880 880
 				}
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
883 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
884 884
 					    $Spotter = new Spotter($this->db);
885
-					    $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']);
885
+					    $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']);
886 886
 					    $Spotter->db = null;
887 887
 					}
888 888
 				    }
@@ -908,37 +908,37 @@  discard block
 block discarded – undo
908 908
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
909 909
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
910 910
 
911
-		    foreach($globalAirportIgnore as $airportIgnore) {
911
+		    foreach ($globalAirportIgnore as $airportIgnore) {
912 912
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
913 913
 			    $ignoreImport = true;
914 914
 			}
915 915
 		    }
916 916
 		    if (count($globalAirportAccept) > 0) {
917 917
 		        $ignoreImport = true;
918
-		        foreach($globalAirportIgnore as $airportIgnore) {
918
+		        foreach ($globalAirportIgnore as $airportIgnore) {
919 919
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
920 920
 				$ignoreImport = false;
921 921
 			    }
922 922
 			}
923 923
 		    }
924 924
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
925
-			foreach($globalAirlineIgnore as $airlineIgnore) {
926
-			    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)) {
925
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
926
+			    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)) {
927 927
 				$ignoreImport = true;
928 928
 			    }
929 929
 			}
930 930
 		    }
931 931
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
932 932
 			$ignoreImport = true;
933
-			foreach($globalAirlineAccept as $airlineAccept) {
934
-			    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)) {
933
+			foreach ($globalAirlineAccept as $airlineAccept) {
934
+			    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)) {
935 935
 				$ignoreImport = false;
936 936
 			    }
937 937
 			}
938 938
 		    }
939 939
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
940 940
 			$ignoreImport = true;
941
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
941
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
942 942
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
943 943
 			        $ignoreImport = false;
944 944
 			    }
@@ -946,23 +946,23 @@  discard block
 block discarded – undo
946 946
 		    }
947 947
 
948 948
 		    if (!$ignoreImport) {
949
-			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'])) {
950
-				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')));
949
+			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'])) {
950
+				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')));
951 951
 				$timeelapsed = microtime(true);
952 952
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
953 953
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
954 954
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
955 955
 					$SpotterLive = new SpotterLive($this->db);
956
-					$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']);
956
+					$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']);
957 957
 					$SpotterLive->db = null;
958 958
 					if ($globalDebug) echo $result."\n";
959 959
 				    }
960 960
 				}
961 961
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
962
-					$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']);
962
+					$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']);
963 963
 				}
964 964
 				$this->all_flights[$id]['putinarchive'] = false;
965
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
965
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
966 966
 
967 967
 				// Put statistics in $this->stats variable
968 968
 				//if ($line['format_source'] != 'aprs') {
@@ -981,19 +981,19 @@  discard block
 block discarded – undo
981 981
 							$latitude = $globalCenterLatitude;
982 982
 							$longitude = $globalCenterLongitude;
983 983
 						}
984
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
984
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
985 985
 					} else {
986 986
 						$latitude = $this->source_location[$source]['latitude'];
987 987
 						$longitude = $this->source_location[$source]['longitude'];
988 988
 					}
989
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
989
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
990 990
 					//$stats_heading = $stats_heading%22.5;
991 991
 					$stats_heading = round($stats_heading/22.5);
992
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
992
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
993 993
 					$current_date = date('Y-m-d');
994 994
 					if ($stats_heading == 16) $stats_heading = 0;
995 995
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
996
-						for ($i=0;$i<=15;$i++) {
996
+						for ($i = 0; $i <= 15; $i++) {
997 997
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
998 998
 						}
999 999
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1009 1009
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1010 1010
 						    end($this->stats[$current_date][$source]['hist']);
1011
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1011
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1012 1012
 						} else $mini = 0;
1013
-						for ($i=$mini;$i<=$distance;$i+=10) {
1013
+						for ($i = $mini; $i <= $distance; $i += 10) {
1014 1014
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1015 1015
 						}
1016 1016
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 				$this->all_flights[$id]['lastupdate'] = time();
1024 1024
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1025 1025
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1026
-			} 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";
1026
+			} 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";
1027 1027
 			//$this->del();
1028 1028
 			
1029 1029
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +398 added lines, -142 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 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']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$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']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$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']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,7 +213,9 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
 	    if (isset($flight['lastupdate'])) {
187 221
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -195,13 +229,17 @@  discard block
 block discarded – undo
195 229
 	global $globalDebug, $globalNoImport, $globalNoDB;
196 230
 	// Delete old infos
197 231
 	if (isset($this->all_flights[$key]['id'])) {
198
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
232
+		if ($globalDebug) {
233
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
234
+		}
199 235
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
200 236
 			$real_arrival = $this->arrival($key);
201 237
 			$Spotter = new Spotter($this->db);
202 238
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203 239
 				$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']);
204
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
240
+				if ($globalDebug && $result != 'success') {
241
+					echo '!!! ERROR : '.$result."\n";
242
+				}
205 243
 			}
206 244
 		}
207 245
 	}
@@ -211,9 +249,13 @@  discard block
 block discarded – undo
211 249
     public function add($line) {
212 250
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval;
213 251
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
214
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
215
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
216
-/*
252
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
253
+		$globalCoordMinChange = '0.02';
254
+	}
255
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
256
+		$globalAircraftMaxUpdate = 3000;
257
+	}
258
+	/*
217 259
 	$Spotter = new Spotter();
218 260
 	$dbc = $Spotter->db;
219 261
 	$SpotterLive = new SpotterLive($dbc);
@@ -235,19 +277,28 @@  discard block
 block discarded – undo
235 277
 	// SBS format is CSV format
236 278
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 279
 	    //print_r($line);
238
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
280
+	    if (isset($line['hex'])) {
281
+	    	$line['hex'] = strtoupper($line['hex']);
282
+	    }
239 283
   	    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)) {
240 284
 
241 285
 		// Increment message number
242 286
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
243 287
 		    $current_date = date('Y-m-d');
244
-		    if (isset($line['source_name'])) $source = $line['source_name'];
245
-		    else $source = '';
246
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
288
+		    if (isset($line['source_name'])) {
289
+		    	$source = $line['source_name'];
290
+		    } else {
291
+		    	$source = '';
292
+		    }
293
+		    if ($source == '' || $line['format_source'] == 'aprs') {
294
+		    	$source = $line['format_source'];
295
+		    }
247 296
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
248 297
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
249 298
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
250
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
299
+		    } else {
300
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
301
+		    }
251 302
 		}
252 303
 		
253 304
 		/*
@@ -263,23 +314,38 @@  discard block
 block discarded – undo
263 314
 		//$this->db = $dbc;
264 315
 
265 316
 		//$hex = trim($line['hex']);
266
-	        if (!isset($line['id'])) $id = trim($line['hex']);
267
-	        else $id = trim($line['id']);
317
+	        if (!isset($line['id'])) {
318
+	        	$id = trim($line['hex']);
319
+	        } else {
320
+	        	$id = trim($line['id']);
321
+	        }
268 322
 		
269 323
 		if (!isset($this->all_flights[$id])) {
270
-		    if ($globalDebug) echo 'New flight...'."\n";
324
+		    if ($globalDebug) {
325
+		    	echo 'New flight...'."\n";
326
+		    }
271 327
 		    $this->all_flights[$id] = array();
272 328
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
273 329
 		    $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' => ''));
274
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
330
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
331
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
332
+		    }
275 333
 		    if (!isset($line['id'])) {
276
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
277
-//			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')));
334
+			if (!isset($globalDaemon)) {
335
+				$globalDaemon = TRUE;
336
+			}
337
+			//			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')));
278 338
 //			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')));
279
-			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')));
339
+			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')) {
340
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
341
+			}
280 342
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
281
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
282
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
343
+		     } else {
344
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
345
+		     }
346
+		    if ($globalAllFlights !== FALSE) {
347
+		    	$dataFound = true;
348
+		    }
283 349
 		}
284 350
 		if (isset($line['source_type']) && $line['source_type'] != '') {
285 351
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -301,12 +367,20 @@  discard block
 block discarded – undo
301 367
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
302 368
 			    }
303 369
 			    $Spotter->db = null;
304
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
370
+			    if ($globalDebugTimeElapsed) {
371
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372
+			    }
373
+			    if ($aircraft_icao != '') {
374
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
375
+			    }
306 376
 			}
307 377
 		    }
308
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
309
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
378
+		    if ($globalAllFlights !== FALSE) {
379
+		    	$dataFound = true;
380
+		    }
381
+		    if ($globalDebug) {
382
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
383
+		    }
310 384
 		}
311 385
 	        if (isset($line['id']) && !isset($line['hex'])) {
312 386
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -314,7 +388,9 @@  discard block
 block discarded – undo
314 388
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
315 389
 			$icao = $line['aircraft_icao'];
316 390
 			$Spotter = new Spotter($this->db);
317
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
391
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
392
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
393
+			}
318 394
 			$Spotter->db = null;
319 395
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
320 396
 		}
@@ -324,15 +400,24 @@  discard block
 block discarded – undo
324 400
 				$Spotter = new Spotter($this->db);
325 401
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
326 402
 				$Spotter->db = null;
327
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
403
+				if ($aircraft_icao != '') {
404
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+				}
328 406
 			}
329 407
 		}
330 408
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
331
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
332
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
333
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
334
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
335
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
409
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
410
+				$aircraft_icao = 'GLID';
411
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
412
+				$aircraft_icao = 'UHEL';
413
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
414
+				$aircraft_icao = 'TOWPLANE';
415
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
416
+				$aircraft_icao = 'POWAIRC';
417
+			}
418
+			if (isset($aircraft_icao)) {
419
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
420
+			}
336 421
 		}
337 422
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
338 423
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -342,8 +427,11 @@  discard block
 block discarded – undo
342 427
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
343 428
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
344 429
 		    } else {
345
-				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";
346
-				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";
430
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
431
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
432
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
433
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
434
+				}
347 435
 				/*
348 436
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
349 437
 				print_r($this->all_flights[$id]);
@@ -352,17 +440,23 @@  discard block
 block discarded – undo
352 440
 				return '';
353 441
 		    }
354 442
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
355
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
443
+			if ($globalDebug) {
444
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
445
+			}
356 446
 			return '';
357 447
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
358
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
448
+			if ($globalDebug) {
449
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
359 450
 			";
451
+			}
360 452
 			return '';
361 453
 		} elseif (!isset($line['datetime'])) {
362 454
 			date_default_timezone_set('UTC');
363 455
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
364 456
 		} else {
365
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
457
+			if ($globalDebug) {
458
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
459
+			}
366 460
 			return '';
367 461
 		}
368 462
 
@@ -383,30 +477,48 @@  discard block
 block discarded – undo
383 477
 
384 478
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
385 479
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
386
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
480
+				if ($globalDebug) {
481
+					echo '---!!!! New ident, reset aircraft data...'."\n";
482
+				}
387 483
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
388 484
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
389
-				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')));
390
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
391
-				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']));
485
+				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')) {
486
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
487
+				} elseif (isset($line['id'])) {
488
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
489
+				} elseif (isset($this->all_flights[$id]['ident'])) {
490
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
491
+				}
392 492
 			} else {
393 493
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
394 494
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395 495
 				$timeelapsed = microtime(true);
396 496
             			$Spotter = new Spotter($this->db);
397 497
             			$fromsource = NULL;
398
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
399
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
400
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
401
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
402
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
498
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
499
+            				$fromsource = $globalAirlinesSource;
500
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
501
+            				$fromsource = 'vatsim';
502
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
503
+					$fromsource = 'ivao';
504
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
505
+					$fromsource = 'vatsim';
506
+				} elseif (isset($globalIVAO) && $globalIVAO) {
507
+					$fromsource = 'ivao';
508
+				}
403 509
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
404
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
510
+				if ($globalDebug && $result != 'success') {
511
+					echo '!!! ERROR : '.$result."\n";
512
+				}
405 513
 				$Spotter->db = null;
406
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
514
+				if ($globalDebugTimeElapsed) {
515
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
516
+				}
407 517
 			    }
408 518
 			}
409
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
519
+		    } else {
520
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
521
+		    }
410 522
 		    
411 523
 /*
412 524
 		    if (!isset($line['id'])) {
@@ -416,7 +528,9 @@  discard block
 block discarded – undo
416 528
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
417 529
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
418 530
   */
419
-		    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']));
531
+		    if (!isset($this->all_flights[$id]['id'])) {
532
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
533
+		    }
420 534
 
421 535
 		    //$putinarchive = true;
422 536
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -434,7 +548,9 @@  discard block
 block discarded – undo
434 548
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
435 549
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
436 550
 		    		$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' => ''));
437
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
+				if ($globalDebugTimeElapsed) {
552
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
553
+				}
438 554
                         }
439 555
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
440 556
 			$timeelapsed = microtime(true);
@@ -448,7 +564,9 @@  discard block
 block discarded – undo
448 564
 				$Translation->db = null;
449 565
 			    }
450 566
 			    $Spotter->db = null;
451
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
567
+			    if ($globalDebugTimeElapsed) {
568
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
569
+			    }
452 570
                     	}
453 571
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
454 572
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -457,9 +575,13 @@  discard block
 block discarded – undo
457 575
 		    		$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']));
458 576
 		    	    }
459 577
 			}
460
-			if (!isset($globalFork)) $globalFork = TRUE;
578
+			if (!isset($globalFork)) {
579
+				$globalFork = TRUE;
580
+			}
461 581
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
462
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
582
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
583
+					$this->get_Schedule($id,trim($line['ident']));
584
+				}
463 585
 			}
464 586
 		    }
465 587
 		}
@@ -477,9 +599,13 @@  discard block
 block discarded – undo
477 599
 			$speed = $speed*3.6;
478 600
 			if ($speed < 1000) {
479 601
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
480
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
602
+	  			if ($globalDebug) {
603
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
604
+	  			}
481 605
 	  		} else {
482
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
606
+	  			if ($globalDebug) {
607
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
608
+	  			}
483 609
 	  		}
484 610
 		    }
485 611
 		}
@@ -488,13 +614,21 @@  discard block
 block discarded – undo
488 614
 
489 615
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
490 616
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
491
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
617
+	    	    	if ($globalDebug) {
618
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
619
+	    	    	}
492 620
 	    	    	return false;
493 621
 	    	    }
494
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
495
-	    	    else unset($timediff);
496
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
497
-	    	    else unset($timediff_archive);
622
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
623
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
624
+	    	    } else {
625
+	    	    	unset($timediff);
626
+	    	    }
627
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
628
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
629
+	    	    } else {
630
+	    	    	unset($timediff_archive);
631
+	    	    }
498 632
 	    	    if ($this->tmd > 5
499 633
 	    	        || (isset($line['format_source']) 
500 634
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -530,16 +664,25 @@  discard block
 block discarded – undo
530 664
 				$this->all_flights[$id]['putinarchive'] = true;
531 665
 				$this->tmd = 0;
532 666
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
533
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
667
+				    if ($globalDebug) {
668
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
669
+				    }
534 670
 				    $timeelapsed = microtime(true);
535 671
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
536 672
 					$Spotter = new Spotter($this->db);
537 673
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
538
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
539
-					else $this->all_flights[$id]['over_country'] = '';
674
+					if (!empty($all_country)) {
675
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
676
+					} else {
677
+						$this->all_flights[$id]['over_country'] = '';
678
+					}
540 679
 					$Spotter->db = null;
541
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
542
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
680
+					if ($globalDebugTimeElapsed) {
681
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
682
+					}
683
+					if ($globalDebug) {
684
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
685
+					}
543 686
 				    }
544 687
 				}
545 688
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -585,7 +728,9 @@  discard block
 block discarded – undo
585 728
 			    */
586 729
 			}
587 730
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
588
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
731
+			    if ($line['longitude'] > 180) {
732
+			    	$line['longitude'] = $line['longitude'] - 360;
733
+			    }
589 734
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
590 735
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
591 736
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -622,7 +767,9 @@  discard block
 block discarded – undo
622 767
 		    }
623 768
 		}
624 769
 		if (isset($line['last_update']) && $line['last_update'] != '') {
625
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
770
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
771
+		    	$dataFound = true;
772
+		    }
626 773
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
627 774
 		}
628 775
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -644,53 +791,79 @@  discard block
 block discarded – undo
644 791
 			// Here we force archive of flight because after ground it's a new one (or should be)
645 792
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
646 793
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
647
-			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')));
648
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
649
-			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']));
794
+			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')) {
795
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
796
+			} elseif (isset($line['id'])) {
797
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
798
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
799
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
800
+			}
801
+		    }
802
+		    if ($line['ground'] != 1) {
803
+		    	$line['ground'] = 0;
650 804
 		    }
651
-		    if ($line['ground'] != 1) $line['ground'] = 0;
652 805
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
653 806
 		    //$dataFound = true;
654 807
 		}
655 808
 		if (isset($line['squawk']) && $line['squawk'] != '') {
656 809
 		    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'])) {
657
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
810
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
811
+			    	$this->all_flights[$id]['putinarchive'] = true;
812
+			    }
658 813
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
659 814
 			    $highlight = '';
660
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
661
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
662
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
815
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
816
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
817
+			    }
818
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
819
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
820
+			    }
821
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
822
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
823
+			    }
663 824
 			    if ($highlight != '') {
664 825
 				$timeelapsed = microtime(true);
665 826
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
666 827
 				    $Spotter = new Spotter($this->db);
667 828
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
668 829
 				    $Spotter->db = null;
669
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
830
+				    if ($globalDebugTimeElapsed) {
831
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+				    }
670 833
 				}
671 834
 				//$putinarchive = true;
672 835
 				//$highlight = '';
673 836
 			    }
674 837
 			    
675
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
838
+		    } else {
839
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
840
+		    }
676 841
 		    //$dataFound = true;
677 842
 		}
678 843
 
679 844
 		if (isset($line['altitude']) && $line['altitude'] != '') {
680 845
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
681
-			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;
846
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
847
+				$this->all_flights[$id]['putinarchive'] = true;
848
+			}
682 849
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
683 850
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
684 851
 			//$dataFound = true;
685 852
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
686 853
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
687 854
 			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) {
688
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
855
+				if ($globalDebug) {
856
+					echo '--- Reset because of altitude'."\n";
857
+				}
689 858
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
690 859
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
691
-				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')));
692
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
693
-				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']));
860
+				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')) {
861
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
862
+				} elseif (isset($line['id'])) {
863
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
864
+				} elseif (isset($this->all_flights[$id]['ident'])) {
865
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
866
+				}
694 867
 			}
695 868
 		    }
696 869
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -701,22 +874,32 @@  discard block
 block discarded – undo
701 874
 		}
702 875
 		
703 876
 		if (isset($line['heading']) && $line['heading'] != '') {
704
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
877
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
878
+		    	$this->all_flights[$id]['putinarchive'] = true;
879
+		    }
705 880
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
706 881
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
707 882
 		    //$dataFound = true;
708 883
   		} 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']) {
709 884
   		    $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']);
710 885
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
711
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
712
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
886
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
887
+		    	$this->all_flights[$id]['putinarchive'] = true;
888
+		    }
889
+  		    if ($globalDebug) {
890
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
891
+  		    }
713 892
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
714 893
   		    // If not enough messages and ACARS set heading to 0
715 894
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
716 895
   		}
717
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
896
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
897
+			$dataFound = false;
898
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
899
+			$dataFound = false;
900
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) {
901
+			$dataFound = false;
902
+		}
720 903
 
721 904
 //		print_r($this->all_flights[$id]);
722 905
 		//gets the callsign from the last hour
@@ -733,23 +916,38 @@  discard block
 block discarded – undo
733 916
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
734 917
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
735 918
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
736
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
919
+				    if ($globalDebug) {
920
+				    	echo "Check if aircraft is already in DB...";
921
+				    }
737 922
 				    $timeelapsed = microtime(true);
738 923
 				    $SpotterLive = new SpotterLive($this->db);
739 924
 				    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')) {
740 925
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
741
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
926
+					if ($globalDebugTimeElapsed) {
927
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
928
+					}
742 929
 				    } elseif (isset($line['id'])) {
743 930
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
744
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
931
+					if ($globalDebugTimeElapsed) {
932
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
933
+					}
745 934
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
746 935
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
747
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
748
-				    } else $recent_ident = '';
936
+					if ($globalDebugTimeElapsed) {
937
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
938
+					}
939
+				    } else {
940
+				    	$recent_ident = '';
941
+				    }
749 942
 				    $SpotterLive->db=null;
750
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
751
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
752
-				} else $recent_ident = '';
943
+				    if ($globalDebug && $recent_ident == '') {
944
+				    	echo " Not in DB.\n";
945
+				    } elseif ($globalDebug && $recent_ident != '') {
946
+				    	echo " Already in DB.\n";
947
+				    }
948
+				} else {
949
+					$recent_ident = '';
950
+				}
753 951
 			    } else {
754 952
 				$recent_ident = '';
755 953
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -757,7 +955,9 @@  discard block
 block discarded – undo
757 955
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
758 956
 			    if($recent_ident == "")
759 957
 			    {
760
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
958
+				if ($globalDebug) {
959
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
960
+				}
761 961
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762 962
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 963
 				//adds the spotter data for the archive
@@ -801,31 +1001,49 @@  discard block
 block discarded – undo
801 1001
 				
802 1002
 				if (!$ignoreImport) {
803 1003
 				    $highlight = '';
804
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
805
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
806
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
807
-				    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')));
1004
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1005
+				    	$highlight = 'Squawk 7500 : Hijack';
1006
+				    }
1007
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1008
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1009
+				    }
1010
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1011
+				    	$highlight = 'Squawk 7700 : Emergency';
1012
+				    }
1013
+				    if (!isset($this->all_flights[$id]['id'])) {
1014
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1015
+				    }
808 1016
 				    $timeelapsed = microtime(true);
809 1017
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
810 1018
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
811 1019
 					    $Spotter = new Spotter($this->db);
812 1020
 					    $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']);
813 1021
 					    $Spotter->db = null;
814
-					    if ($globalDebug && isset($result)) echo $result."\n";
1022
+					    if ($globalDebug && isset($result)) {
1023
+					    	echo $result."\n";
1024
+					    }
815 1025
 					}
816 1026
 				    }
817
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1027
+				    if ($globalDebugTimeElapsed) {
1028
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1029
+				    }
818 1030
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
819 1031
 
820 1032
 				    // Add source stat in DB
821 1033
 				    $Stats = new Stats($this->db);
822 1034
 				    if (!empty($this->stats)) {
823
-					if ($globalDebug) echo 'Add source stats : ';
1035
+					if ($globalDebug) {
1036
+						echo 'Add source stats : ';
1037
+					}
824 1038
 				        foreach($this->stats as $date => $data) {
825 1039
 					    foreach($data as $source => $sourced) {
826 1040
 					        //print_r($sourced);
827
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
828
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1041
+				    	        if (isset($sourced['polar'])) {
1042
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1043
+				    	        }
1044
+				    	        if (isset($sourced['hist'])) {
1045
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1046
+				    	        }
829 1047
 				    		if (isset($sourced['msg'])) {
830 1048
 				    		    if (time() - $sourced['msg']['date'] > 10) {
831 1049
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -838,13 +1056,17 @@  discard block
 block discarded – undo
838 1056
 			    			unset($this->stats[$date]);
839 1057
 			    		    }
840 1058
 				    	}
841
-				    	if ($globalDebug) echo 'Done'."\n";
1059
+				    	if ($globalDebug) {
1060
+				    		echo 'Done'."\n";
1061
+				    	}
842 1062
 
843 1063
 				    }
844 1064
 				    $Stats->db = null;
845 1065
 				    }
846 1066
 				    $this->del();
847
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1067
+				} elseif ($globalDebug) {
1068
+					echo 'Ignore data'."\n";
1069
+				}
848 1070
 				//$ignoreImport = false;
849 1071
 				$this->all_flights[$id]['addedSpotter'] = 1;
850 1072
 				//print_r($this->all_flights[$id]);
@@ -861,7 +1083,9 @@  discard block
 block discarded – undo
861 1083
 			*/
862 1084
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
863 1085
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
864
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1086
+				    if ($globalDebug) {
1087
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1088
+				    }
865 1089
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
866 1090
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
867 1091
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -870,7 +1094,9 @@  discard block
 block discarded – undo
870 1094
 					    $SpotterLive->db=null;
871 1095
 					}
872 1096
 				    }
873
-				    if ($globalDebug) echo " Done\n";
1097
+				    if ($globalDebug) {
1098
+				    	echo " Done\n";
1099
+				    }
874 1100
 				    $this->last_delete = time();
875 1101
 				}
876 1102
 			    } else {
@@ -897,11 +1123,17 @@  discard block
 block discarded – undo
897 1123
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
898 1124
 		    if ($globalDebug) {
899 1125
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
900
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
901
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1126
+				if (isset($this->all_flights[$id]['source_name'])) {
1127
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1128
+				} else {
1129
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1130
+				}
902 1131
 			} else {
903
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
904
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1132
+				if (isset($this->all_flights[$id]['source_name'])) {
1133
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1134
+				} else {
1135
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1136
+				}
905 1137
 			}
906 1138
 		    }
907 1139
 		    $ignoreImport = false;
@@ -947,22 +1179,30 @@  discard block
 block discarded – undo
947 1179
 
948 1180
 		    if (!$ignoreImport) {
949 1181
 			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'])) {
950
-				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')));
1182
+				if (!isset($this->all_flights[$id]['id'])) {
1183
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1184
+				}
951 1185
 				$timeelapsed = microtime(true);
952 1186
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
953 1187
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
954
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1188
+					if ($globalDebug) {
1189
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1190
+					}
955 1191
 					$SpotterLive = new SpotterLive($this->db);
956 1192
 					$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']);
957 1193
 					$SpotterLive->db = null;
958
-					if ($globalDebug) echo $result."\n";
1194
+					if ($globalDebug) {
1195
+						echo $result."\n";
1196
+					}
959 1197
 				    }
960 1198
 				}
961 1199
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
962 1200
 					$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']);
963 1201
 				}
964 1202
 				$this->all_flights[$id]['putinarchive'] = false;
965
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1203
+				if ($globalDebugTimeElapsed) {
1204
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1205
+				}
966 1206
 
967 1207
 				// Put statistics in $this->stats variable
968 1208
 				//if ($line['format_source'] != 'aprs') {
@@ -970,7 +1210,9 @@  discard block
 block discarded – undo
970 1210
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971 1211
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
972 1212
 					$source = $this->all_flights[$id]['source_name'];
973
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1213
+					if ($source == '') {
1214
+						$source = $this->all_flights[$id]['format_source'];
1215
+					}
974 1216
 					if (!isset($this->source_location[$source])) {
975 1217
 						$Location = new Source();
976 1218
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -991,7 +1233,9 @@  discard block
 block discarded – undo
991 1233
 					$stats_heading = round($stats_heading/22.5);
992 1234
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
993 1235
 					$current_date = date('Y-m-d');
994
-					if ($stats_heading == 16) $stats_heading = 0;
1236
+					if ($stats_heading == 16) {
1237
+						$stats_heading = 0;
1238
+					}
995 1239
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
996 1240
 						for ($i=0;$i<=15;$i++) {
997 1241
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1009,7 +1253,9 @@  discard block
 block discarded – undo
1009 1253
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1010 1254
 						    end($this->stats[$current_date][$source]['hist']);
1011 1255
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1012
-						} else $mini = 0;
1256
+						} else {
1257
+							$mini = 0;
1258
+						}
1013 1259
 						for ($i=$mini;$i<=$distance;$i+=10) {
1014 1260
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1015 1261
 						}
@@ -1021,19 +1267,27 @@  discard block
 block discarded – undo
1021 1267
 				}
1022 1268
 
1023 1269
 				$this->all_flights[$id]['lastupdate'] = time();
1024
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1270
+				if ($this->all_flights[$id]['putinarchive']) {
1271
+					$send = true;
1272
+				}
1025 1273
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1026
-			} 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";
1274
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1275
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1276
+			}
1027 1277
 			//$this->del();
1028 1278
 			
1029 1279
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1030 1280
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1031
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1281
+				if ($globalDebug) {
1282
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1283
+				}
1032 1284
 				$SpotterLive = new SpotterLive($this->db);
1033 1285
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1034 1286
 				$SpotterLive->db = null;
1035 1287
 				//SpotterLive->deleteLiveSpotterData();
1036
-				if ($globalDebug) echo " Done\n";
1288
+				if ($globalDebug) {
1289
+					echo " Done\n";
1290
+				}
1037 1291
 				$this->last_delete_hourly = time();
1038 1292
 			    } else {
1039 1293
 				$this->del();
@@ -1045,7 +1299,9 @@  discard block
 block discarded – undo
1045 1299
 		    //$ignoreImport = false;
1046 1300
 		}
1047 1301
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1048
-		if ($send) return $this->all_flights[$id];
1302
+		if ($send) {
1303
+			return $this->all_flights[$id];
1304
+		}
1049 1305
 	    }
1050 1306
 	}
1051 1307
     }
Please login to merge, or discard this patch.
live-czml.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     $s3 = sin($bank/2);
49 49
     $c1c2 = $c1*$c2;
50 50
     $s1s2 = $s1*$s2;
51
-    $w =$c1c2*$c3 - $s1s2*$s3;
52
-    $x =$c1c2*$s3 + $s1s2*$c3;
53
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
54
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
55
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51
+    $w = $c1c2*$c3 - $s1s2*$s3;
52
+    $x = $c1c2*$s3 + $s1s2*$c3;
53
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
54
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
55
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
56 56
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
57 57
 
58 58
 }
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 $min = false;
74 74
 $allhistory = false;
75 75
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
76
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
77
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
79
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
80
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
81
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
82
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
83
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
84
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
85
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
86 86
 /*
87 87
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 88
 	$min = true;
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	$from_archive = true;
130 130
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
131 131
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
132
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
133
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
134
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
135
-	$begindate = date('Y-m-d H:i:s',$begindate);
136
-	$enddate = date('Y-m-d H:i:s',$enddate);
137
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
132
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
133
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
134
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
135
+	$begindate = date('Y-m-d H:i:s', $begindate);
136
+	$enddate = date('Y-m-d H:i:s', $enddate);
137
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
138 138
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
139 139
 	$from_archive = true;
140 140
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	$begindate = $_COOKIE['archive_begin'];
145 145
 	$enddate = $_COOKIE['archive_end'];
146 146
 
147
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
148
-	$begindate = date('Y-m-d H:i:s',$begindate);
149
-	$enddate = date('Y-m-d H:i:s',$enddate);
147
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
148
+	$begindate = date('Y-m-d H:i:s', $begindate);
149
+	$enddate = date('Y-m-d H:i:s', $enddate);
150 150
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
151
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
151
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
152 152
 } elseif ($tracker) {
153 153
 	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter);
154 154
 } elseif ($marine) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 //print_r($spotter_array);
160 160
 if (!empty($spotter_array)) {
161 161
 	if (isset($_GET['archive'])) {
162
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
162
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
163 163
 	} elseif ($tracker) {
164 164
 		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
165 165
 	} elseif ($marine) {
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 	if ($flightcnt == '') $flightcnt = 0;
171 171
 } else $flightcnt = 0;
172 172
 
173
-$sqltime = round(microtime(true)-$begintime,2);
173
+$sqltime = round(microtime(true) - $begintime, 2);
174 174
 $minitime = time();
175 175
 $maxitime = 0;
176 176
 
177 177
 
178 178
 $modelsdb = array();
179 179
 if (file_exists(dirname(__FILE__).'/models/modelsdb')) {
180
-	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) {
181
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
182
-			if (isset($row[1]) ){
180
+	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) {
181
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
182
+			if (isset($row[1])) {
183 183
 				$model = $row[0];
184 184
 				$modelsdb[$model] = $row[1];
185 185
 			}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 $output .= '},';
216 216
 if (!empty($spotter_array) && is_array($spotter_array))
217 217
 {
218
-	foreach($spotter_array as $spotter_item)
218
+	foreach ($spotter_array as $spotter_item)
219 219
 	{
220 220
 		$j++;
221 221
 		//if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND';
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 			$output .= '"cartographicDegrees": [';
541 541
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
542 542
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
543
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
543
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
544 544
 			$output .= $spotter_item['longitude'].', ';
545 545
 			$output .= $spotter_item['latitude'];
546 546
 			$prevlong = $spotter_item['longitude'];
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
560 560
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
561 561
 		} else {
562
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
562
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
563 563
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
564 564
 			if ($spotter_item['ground_speed'] == 0) {
565 565
 				$output .= $prevlong.', ';
@@ -593,9 +593,9 @@  discard block
 block discarded – undo
593 593
 }
594 594
 $output .= ']';
595 595
 if (isset($globalArchive) && $globalArchive === TRUE) {
596
-	if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
597
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
598
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
599
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
596
+	if ((time() - $globalLiveInterval) > $minitime) $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output);
597
+	else $output = str_replace('%minitime%', date("c", $minitime), $output);
598
+} else $output = str_replace('%minitime%', date("c", $minitime), $output);
599
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
600 600
 print $output;
601 601
 ?>
Please login to merge, or discard this patch.
Braces   +108 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,8 +8,12 @@  discard block
 block discarded – undo
8 8
 }
9 9
 $tracker = false;
10 10
 $marine = false;
11
-if (isset($_GET['tracker'])) $tracker = true;
12
-if (isset($_GET['marine'])) $marine = true;
11
+if (isset($_GET['tracker'])) {
12
+	$tracker = true;
13
+}
14
+if (isset($_GET['marine'])) {
15
+	$marine = true;
16
+}
13 17
 if ($tracker) {
14 18
 	require_once('require/class.Tracker.php');
15 19
 	require_once('require/class.TrackerLive.php');
@@ -66,23 +70,46 @@  discard block
 block discarded – undo
66 70
 }
67 71
 header('Content-Type: text/javascript');
68 72
 
69
-if (!isset($globalJsonCompress)) $compress = true;
70
-else $compress = $globalJsonCompress;
73
+if (!isset($globalJsonCompress)) {
74
+	$compress = true;
75
+} else {
76
+	$compress = $globalJsonCompress;
77
+}
71 78
 
72 79
 $from_archive = false;
73 80
 $min = false;
74 81
 $allhistory = false;
75 82
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
83
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
84
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
85
+}
86
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
87
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
88
+}
89
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
90
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
91
+}
92
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
93
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
94
+}
95
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
96
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
97
+}
98
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
99
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
100
+}
101
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
102
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
+}
104
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
105
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
106
+}
107
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
108
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
109
+}
110
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
111
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
112
+}
86 113
 /*
87 114
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 115
 	$min = true;
@@ -167,8 +194,12 @@  discard block
 block discarded – undo
167 194
 	} else {
168 195
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
169 196
 	}
170
-	if ($flightcnt == '') $flightcnt = 0;
171
-} else $flightcnt = 0;
197
+	if ($flightcnt == '') {
198
+		$flightcnt = 0;
199
+	}
200
+	} else {
201
+	$flightcnt = 0;
202
+}
172 203
 
173 204
 $sqltime = round(microtime(true)-$begintime,2);
174 205
 $minitime = time();
@@ -192,7 +223,9 @@  discard block
 block discarded – undo
192 223
 $j = 0;
193 224
 $prev_flightaware_id = '';
194 225
 $speed = 1;
195
-if (isset($archivespeed)) $speed = $archivespeed;
226
+if (isset($archivespeed)) {
227
+	$speed = $archivespeed;
228
+}
196 229
 $output = '[';
197 230
 if ($tracker) {
198 231
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -227,9 +260,13 @@  discard block
 block discarded – undo
227 260
 			$image = "images/placeholder_thumb.png";
228 261
 		}
229 262
 
230
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
231
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
232
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
263
+                if (isset($spotter_item['flightaware_id'])) {
264
+                	$id = $spotter_item['flightaware_id'];
265
+                } elseif (isset($spotter_item['famtrackid'])) {
266
+                	$id = $spotter_item['famtrackid'];
267
+                } elseif (isset($spotter_item['fammarine_id'])) {
268
+                	$id = $spotter_item['fammarine_id'];
269
+                }
233 270
                 if ($prev_flightaware_id != $id) {
234 271
 			if ($prev_flightaware_id != '') {
235 272
 				$output .= ']';
@@ -271,7 +308,9 @@  discard block
 block discarded – undo
271 308
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
272 309
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
273 310
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
274
-						} else $aircraft_shadow = '';
311
+						} else {
312
+							$aircraft_shadow = '';
313
+						}
275 314
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
276 315
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) {
277 316
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -279,7 +318,9 @@  discard block
 block discarded – undo
279 318
 						}
280 319
 						$output .= '},';
281 320
 					}
282
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
321
+				} else {
322
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
323
+				}
283 324
 			} elseif ($one3dmodel) {
284 325
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
285 326
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20';
@@ -310,7 +351,9 @@  discard block
 block discarded – undo
310 351
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
311 352
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
312 353
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
313
-						} else $aircraft_shadow = '';
354
+						} else {
355
+							$aircraft_shadow = '';
356
+						}
314 357
 						if ($aircraft_shadow != '') {
315 358
 							if (isset($modelsdb[$aircraft_shadow])) {
316 359
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -447,7 +490,9 @@  discard block
 block discarded – undo
447 490
 								}
448 491
 								$output .= '},';
449 492
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
450
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
493
+								if ($spotter_item['aircraft_icao'] != '') {
494
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
495
+								}
451 496
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
452 497
 							}
453 498
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -469,7 +514,9 @@  discard block
 block discarded – undo
469 514
 							}
470 515
 							$output .= '},';
471 516
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
472
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
517
+							if ($spotter_item['aircraft_icao'] != '') {
518
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
519
+							}
473 520
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
474 521
 						}
475 522
 					} else {
@@ -482,7 +529,9 @@  discard block
 block discarded – undo
482 529
 						}
483 530
 						$output .= '},';
484 531
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
485
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
532
+						if ($spotter_item['aircraft_icao'] != '') {
533
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
534
+						}
486 535
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
487 536
 					}
488 537
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -538,8 +587,12 @@  discard block
 block discarded – undo
538 587
 	//		$output .= '"interpolationDegree" : 5,';
539 588
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
540 589
 			$output .= '"cartographicDegrees": [';
541
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
542
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
590
+			if ($minitime > strtotime($spotter_item['date'])) {
591
+				$minitime = strtotime($spotter_item['date']);
592
+			}
593
+			if ($maxitime < strtotime($spotter_item['date'])) {
594
+				$maxitime = strtotime($spotter_item['date']);
595
+			}
543 596
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
544 597
 			$output .= $spotter_item['longitude'].', ';
545 598
 			$output .= $spotter_item['latitude'];
@@ -553,19 +606,26 @@  discard block
 block discarded – undo
553 606
 					$output .= ', '.round($spotter_item['altitude']*30.48);
554 607
 					$prevalt = round($spotter_item['altitude']*30.48);
555 608
 				}
556
-			} else $output .= ', 0';
609
+			} else {
610
+				$output .= ', 0';
611
+			}
557 612
 			//$orientation = '"orientation" : { ';
558 613
 			//$orientation .= '"unitQuaternion": [';
559 614
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
560 615
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
561 616
 		} else {
562 617
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
563
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
618
+			if ($maxitime < strtotime($spotter_item['date'])) {
619
+				$maxitime = strtotime($spotter_item['date']);
620
+			}
564 621
 			if ($spotter_item['ground_speed'] == 0) {
565 622
 				$output .= $prevlong.', ';
566 623
 				$output .= $prevlat;
567
-				if (!$tracker && !$marine) $output .= ', '.$prevalt;
568
-				else $output .= ', 0';
624
+				if (!$tracker && !$marine) {
625
+					$output .= ', '.$prevalt;
626
+				} else {
627
+					$output .= ', 0';
628
+				}
569 629
 			} else {
570 630
 				$output .= $spotter_item['longitude'].', ';
571 631
 				$output .= $spotter_item['latitude'];
@@ -577,10 +637,15 @@  discard block
 block discarded – undo
577 637
 							$output .= ', 0';
578 638
 						}
579 639
 					} else {
580
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
581
-						else $output .= ', '.round($spotter_item['altitude']*30.48);
640
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
641
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
642
+						} else {
643
+							$output .= ', '.round($spotter_item['altitude']*30.48);
644
+						}
582 645
 					}
583
-				} else $output .= ', 0';
646
+				} else {
647
+					$output .= ', 0';
648
+				}
584 649
 			}
585 650
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
586 651
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -593,9 +658,14 @@  discard block
 block discarded – undo
593 658
 }
594 659
 $output .= ']';
595 660
 if (isset($globalArchive) && $globalArchive === TRUE) {
596
-	if ((time()-$globalLiveInterval) > $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
597
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
598
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
661
+	if ((time()-$globalLiveInterval) > $minitime) {
662
+		$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
663
+	} else {
664
+		$output = str_replace('%minitime%',date("c",$minitime),$output);
665
+	}
666
+	} else {
667
+	$output = str_replace('%minitime%',date("c",$minitime),$output);
668
+}
599 669
 $output = str_replace('%maxitime%',date("c",$maxitime),$output);
600 670
 print $output;
601 671
 ?>
Please login to merge, or discard this patch.