Completed
Push — master ( 6543b3...ee7c1e )
by Yannick
33:38
created
require/class.SpotterImport.php 1 patch
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
107
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
115
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
116
+		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']);
117 117
        }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 141
     		    $Spotter = new Spotter($this->db);
142 142
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
143
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
144 144
         	}
145 145
 	    }
146 146
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $airport_time = '';
155 155
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
158 158
     	    if (isset($closestAirports[0])) {
159 159
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 160
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         		    break;
170 170
         		}
171 171
         	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
+        	} 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))) {
173 173
         		$airport_icao = $closestAirports[0]['icao'];
174 174
         		$airport_time = $this->all_flights[$key]['datetime'];
175 175
         	} else {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         } else {
183 183
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184 184
         }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
186 186
     }
187 187
 
188 188
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	
195 195
 	foreach ($this->all_flights as $key => $flight) {
196 196
 		if (isset($flight['lastupdate'])) {
197
-			if ($flight['lastupdate'] < (time()-1800)) {
197
+			if ($flight['lastupdate'] < (time() - 1800)) {
198 198
 				$this->delKey($key);
199 199
 			}
200 200
 		}
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 			$Spotter = new Spotter($this->db);
212 212
 			$SpotterLive = new SpotterLive($this->db);
213 213
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
214
-				$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']);
214
+				$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']);
215 215
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
216 216
 				$this->all_flights[$key]['putinarchive'] = true;
217
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
217
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']);
218 218
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
219 219
 			}
220 220
 			$Spotter->db = null;
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	$send = false;
251 251
 	
252 252
 	// SBS format is CSV format
253
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
253
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254 254
 	    //print_r($line);
255 255
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
256
+  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 257
 
258 258
 		// Increment message number
259 259
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
 		if (!isset($this->all_flights[$id])) {
287 287
 		    if ($globalDebug) echo 'New flight...'."\n";
288 288
 		    $this->all_flights[$id] = array();
289
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
-		    $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' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
289
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
290
+		    $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' => ''));
291
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
292 292
 		    if (!isset($line['id'])) {
293 293
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294 294
 //			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')));
295 295
 //			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')));
296
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
296
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
297 297
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
298
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
299 299
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		}
301 301
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
302
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
303 303
 		}
304 304
 		
305 305
 		//print_r($this->all_flights);
306 306
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
307
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
308 308
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
309 309
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
310 310
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
314 314
 			    $Spotter = new Spotter($this->db);
315 315
 			    if (isset($this->all_flights[$id]['source_type'])) {
316
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
316
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
317 317
 			    } else {
318 318
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319 319
 			    }
320 320
 			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
321
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
322
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324 324
 		    }
325 325
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
326 326
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
327 327
 		}
328 328
 	        if (isset($line['id']) && !isset($line['hex'])) {
329
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
329
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
330 330
 	        }
331 331
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
332 332
 			$icao = $line['aircraft_icao'];
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
336 336
 				$Spotter->db = null;
337 337
 			}
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
339 339
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
340 340
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 341
 				// Get aircraft ICAO from aircraft name
342 342
 				$Spotter = new Spotter($this->db);
343 343
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
344 344
 				$Spotter->db = null;
345
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
345
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
346 346
 			}
347 347
 		}
348 348
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
351 351
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
352 352
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
353
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
353
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
354 354
 		}
355 355
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
356
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
356
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
357 357
 		}
358 358
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
359
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
359
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
360 360
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
361
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
362 362
 		    } else {
363 363
 				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";
364 364
 				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";
@@ -369,31 +369,31 @@  discard block
 block discarded – undo
369 369
 				*/
370 370
 				return '';
371 371
 		    }
372
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
372
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
373 373
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
374 374
 			return '';
375
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
375
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
376 376
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
377 377
 			return '';
378 378
 		} elseif (!isset($line['datetime'])) {
379 379
 			date_default_timezone_set('UTC');
380
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
380
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
381 381
 		} else {
382 382
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
383 383
 			return '';
384 384
 		}
385 385
 
386 386
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
387
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
388 388
 		}
389 389
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
390
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
390
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
391 391
 		}
392 392
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
393
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
394 394
 		}
395 395
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
396
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
396
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
397 397
 		}
398 398
  
399 399
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 402
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403 403
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
404
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
405
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
406
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
407
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408
-				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']));
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
405
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
406
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
407
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
408
+				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']));
409 409
 			} else {
410
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
410
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
411 411
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 412
 				$timeelapsed = microtime(true);
413 413
             			$Spotter = new Spotter($this->db);
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418 418
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419 419
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
420
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
420
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']);
421 421
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
422 422
 				$Spotter->db = null;
423
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
423
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
424 424
 			    }
425 425
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
426
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
427 427
 		    
428 428
 /*
429 429
 		    if (!isset($line['id'])) {
@@ -433,25 +433,25 @@  discard block
 block discarded – undo
433 433
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 434
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 435
   */
436
-		    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']));
436
+		    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']));
437 437
 
438 438
 		    //$putinarchive = true;
439 439
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
440
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
440
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
441 441
 		    }
442 442
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
443
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
443
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
444 444
 		    }
445 445
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
446
+		    		$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' => ''));
447 447
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
448 448
 			$timeelapsed = microtime(true);
449 449
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
450 450
 				$Spotter = new Spotter($this->db);
451 451
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 452
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453
-		    		$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' => ''));
454
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+		    		$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' => ''));
454
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
455 455
                         }
456 456
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 457
 			$timeelapsed = microtime(true);
@@ -465,35 +465,35 @@  discard block
 block discarded – undo
465 465
 				$Translation->db = null;
466 466
 			    }
467 467
 			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
469 469
                     	}
470 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471 471
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472 472
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
473 473
 				//    $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']));
474
-		    		$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']));
474
+		    		$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']));
475 475
 		    	    }
476 476
 			}
477 477
 			if (!isset($globalFork)) $globalFork = TRUE;
478 478
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
479
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
480 480
 			}
481 481
 		    }
482 482
 		}
483 483
 
484 484
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
485 485
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
486
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
486
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
487
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
488 488
 		    //$dataFound = true;
489 489
 		} 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'])) {
490
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
490
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
491 491
 		    if ($distance > 1000 && $distance < 10000) {
492 492
 		    // use datetime
493 493
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
494 494
 			$speed = $speed*3.6;
495 495
 			if ($speed < 1000) {
496
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
496
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
497 497
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
498 498
 	  		} else {
499 499
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509 509
 	    	    	return false;
510 510
 	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
511
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
512 512
 	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
513
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
514 514
 	    	    else unset($timediff_archive);
515 515
 	    	    if ($this->tmd > 5
516 516
 	    	        || (isset($line['format_source']) 
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
 	    	    	|| ($timediff > 30 
536 536
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
537 537
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
538
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
538
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
539 539
 	    	    	    )
540 540
 	    	    	) {
541 541
 
542 542
 			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']))) {
543 543
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
544 544
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
545
-				|| !$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'])) {
545
+				|| !$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'])) {
546 546
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547 547
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
548 548
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
 				    $timeelapsed = microtime(true);
553 553
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 554
 					$Spotter = new Spotter($this->db);
555
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
555
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
556 556
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
557 557
 					else $this->all_flights[$id]['over_country'] = '';
558 558
 					$Spotter->db = null;
559
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
559
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
560 560
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
561 561
 				    }
562 562
 				}
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
 					$this->all_flights[$id]['time_last_coord'] = time();
583 583
 				}
584 584
 				//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)) {
585
-				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)) {
585
+				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)) {
586 586
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587 587
 				    $dataFound = true;
588 588
 				    $this->all_flights[$id]['time_last_coord'] = time();
589 589
 				}
590 590
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
591
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
591
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
592 592
 				/*
593 593
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
594 594
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
 					$this->all_flights[$id]['time_last_coord'] = time();
611 611
 				}
612 612
 				//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)) {
613
-				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)) {
613
+				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)) {
614 614
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615 615
 				    $dataFound = true;
616 616
 				    $this->all_flights[$id]['time_last_coord'] = time();
617 617
 				}
618 618
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
619
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
619
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
620 620
 				/*
621 621
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
622 622
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -634,46 +634,46 @@  discard block
 block discarded – undo
634 634
 		    } else if ($globalDebug && $timediff > 30) {
635 635
 			$this->tmd = $this->tmd + 1;
636 636
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
637
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
638
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
637
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
638
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
639 639
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
640 640
 		    }
641 641
 		}
642 642
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643 643
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
644
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
645 645
 		}
646 646
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
647
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
648 648
 		    //$dataFound = true;
649 649
 		}
650 650
 		if (isset($line['format_source']) && $line['format_source'] != '') {
651
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
651
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
652 652
 		}
653 653
 		if (isset($line['source_name']) && $line['source_name'] != '') {
654
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
654
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
655 655
 		}
656 656
 		if (isset($line['emergency']) && $line['emergency'] != '') {
657
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
657
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
658 658
 		    //$dataFound = true;
659 659
 		}
660 660
 		if (isset($line['ground']) && $line['ground'] != '') {
661 661
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
662 662
 			// Here we force archive of flight because after ground it's a new one (or should be)
663
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667
-			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']));
663
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
664
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
665
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
666
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
667
+			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']));
668 668
 		    }
669 669
 		    if ($line['ground'] != 1) $line['ground'] = 0;
670
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
670
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
671 671
 		    //$dataFound = true;
672 672
 		}
673 673
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674 674
 		    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'])) {
675 675
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
676
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
677 677
 			    $highlight = '';
678 678
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679 679
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -682,66 +682,66 @@  discard block
 block discarded – undo
682 682
 				$timeelapsed = microtime(true);
683 683
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684 684
 				    $Spotter = new Spotter($this->db);
685
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
685
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
686 686
 				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
687
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
688 688
 				}
689 689
 				//$putinarchive = true;
690 690
 				//$highlight = '';
691 691
 			    }
692 692
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
693
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
694 694
 		    //$dataFound = true;
695 695
 		}
696 696
 
697 697
 		if (isset($line['altitude']) && $line['altitude'] != '') {
698 698
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
699 699
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
700
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
700
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
701 701
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
702 702
 					$line['altitude'] = $line['altitude'] - $geoid;
703 703
 				}
704 704
 			}
705 705
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706
-			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;
707
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
706
+			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;
707
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
708
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
709 709
 			//$dataFound = true;
710 710
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711 711
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 712
 			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) {
713 713
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
714
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
715
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
716
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
717
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718
-				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']));
714
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
715
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
716
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
717
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
718
+				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']));
719 719
 			}
720 720
 		    }
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
721
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
722 722
 		}
723 723
 
724 724
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
725
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
725
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
726 726
 		}
727 727
 		
728 728
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
729
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
731
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
732 732
 		    //$dataFound = true;
733 733
   		} 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']) {
734
-  		    $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']);
735
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
734
+  		    $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']);
735
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
736
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737 737
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
738 738
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739 739
   		    // If not enough messages and ACARS set heading to 0
740
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
740
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
741 741
   		}
742
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
742
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
745 745
 
746 746
 //		print_r($this->all_flights[$id]);
747 747
 		//gets the callsign from the last hour
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
753 753
 		    $this->all_flights[$id]['lastupdate'] = time();
754 754
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
-		        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'])) {
755
+		        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'])) {
756 756
 			    //print_r($this->all_flights);
757 757
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758 758
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -763,61 +763,61 @@  discard block
 block discarded – undo
763 763
 				    $SpotterLive = new SpotterLive($this->db);
764 764
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 765
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
766
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
767 767
 				    } elseif (isset($line['id'])) {
768 768
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
769
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
770 770
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 771
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
772
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
773 773
 				    } else $recent_ident = '';
774
-				    $SpotterLive->db=null;
774
+				    $SpotterLive->db = null;
775 775
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776 776
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777 777
 				} else $recent_ident = '';
778 778
 			    } else {
779 779
 				$recent_ident = '';
780
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
780
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
781 781
 			    }
782 782
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
-			    if($recent_ident == "")
783
+			    if ($recent_ident == "")
784 784
 			    {
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
786 786
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 787
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 788
 				//adds the spotter data for the archive
789 789
 				$ignoreImport = false;
790
-				foreach($globalAirportIgnore as $airportIgnore) {
790
+				foreach ($globalAirportIgnore as $airportIgnore) {
791 791
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
792 792
 					$ignoreImport = true;
793 793
 				    }
794 794
 				}
795 795
 				if (count($globalAirportAccept) > 0) {
796 796
 				    $ignoreImport = true;
797
-				    foreach($globalAirportIgnore as $airportIgnore) {
797
+				    foreach ($globalAirportIgnore as $airportIgnore) {
798 798
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
799 799
 					    $ignoreImport = false;
800 800
 					}
801 801
 				    }
802 802
 				}
803 803
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
804
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
805
-					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)) {
804
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
805
+					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)) {
806 806
 					    $ignoreImport = true;
807 807
 					}
808 808
 				    }
809 809
 				}
810 810
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
811 811
 				    $ignoreImport = true;
812
-				    foreach($globalAirlineAccept as $airlineAccept) {
813
-					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)) {
812
+				    foreach ($globalAirlineAccept as $airlineAccept) {
813
+					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)) {
814 814
 					    $ignoreImport = false;
815 815
 					}
816 816
 				    }
817 817
 				}
818 818
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
819 819
 				    $ignoreImport = true;
820
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
820
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
821 821
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
822 822
 					    $ignoreImport = false;
823 823
 					}
@@ -829,12 +829,12 @@  discard block
 block discarded – undo
829 829
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830 830
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831 831
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    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')));
832
+				    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')));
833 833
 				    $timeelapsed = microtime(true);
834 834
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 835
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 					    $Spotter = new Spotter($this->db);
837
-					    $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']);
837
+					    $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']);
838 838
 					    $Spotter->db = null;
839 839
 					    if ($globalDebug) {
840 840
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
@@ -847,22 +847,22 @@  discard block
 block discarded – undo
847 847
 					    }
848 848
 					}
849 849
 				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
850
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
851 851
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 852
 
853 853
 				    // Add source stat in DB
854 854
 				    $Stats = new Stats($this->db);
855 855
 				    if (!empty($this->stats)) {
856 856
 					if ($globalDebug) echo 'Add source stats : ';
857
-				        foreach($this->stats as $date => $data) {
858
-					    foreach($data as $source => $sourced) {
857
+				        foreach ($this->stats as $date => $data) {
858
+					    foreach ($data as $source => $sourced) {
859 859
 					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
860
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
861
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
862 862
 				    		if (isset($sourced['msg'])) {
863 863
 				    		    if (time() - $sourced['msg']['date'] > 10) {
864 864
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
865
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
866 866
 			    			        unset($this->stats[$date][$source]['msg']);
867 867
 			    			    }
868 868
 			    			}
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901 901
 					    $SpotterLive = new SpotterLive($this->db);
902 902
 					    $SpotterLive->deleteLiveSpotterData();
903
-					    $SpotterLive->db=null;
903
+					    $SpotterLive->db = null;
904 904
 					}
905 905
 				    }
906 906
 				    if ($globalDebug) echo " Done\n";
907 907
 				    $this->last_delete = time();
908 908
 				}
909 909
 			    } else {
910
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
910
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
911 911
 				    $this->all_flights[$id]['id'] = $recent_ident;
912 912
 				    $this->all_flights[$id]['addedSpotter'] = 1;
913 913
 				}
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
916 916
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917 917
 					    $Spotter = new Spotter($this->db);
918
-					    $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']);
918
+					    $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']);
919 919
 					    $Spotter->db = null;
920 920
 					}
921 921
 				    }
@@ -941,37 +941,37 @@  discard block
 block discarded – undo
941 941
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942 942
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
943 943
 
944
-		    foreach($globalAirportIgnore as $airportIgnore) {
944
+		    foreach ($globalAirportIgnore as $airportIgnore) {
945 945
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946 946
 			    $ignoreImport = true;
947 947
 			}
948 948
 		    }
949 949
 		    if (count($globalAirportAccept) > 0) {
950 950
 		        $ignoreImport = true;
951
-		        foreach($globalAirportIgnore as $airportIgnore) {
951
+		        foreach ($globalAirportIgnore as $airportIgnore) {
952 952
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
953 953
 				$ignoreImport = false;
954 954
 			    }
955 955
 			}
956 956
 		    }
957 957
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
958
-			foreach($globalAirlineIgnore as $airlineIgnore) {
959
-			    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)) {
958
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
959
+			    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)) {
960 960
 				$ignoreImport = true;
961 961
 			    }
962 962
 			}
963 963
 		    }
964 964
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
965 965
 			$ignoreImport = true;
966
-			foreach($globalAirlineAccept as $airlineAccept) {
967
-			    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)) {
966
+			foreach ($globalAirlineAccept as $airlineAccept) {
967
+			    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)) {
968 968
 				$ignoreImport = false;
969 969
 			    }
970 970
 			}
971 971
 		    }
972 972
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
973 973
 			$ignoreImport = true;
974
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
974
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
975 975
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976 976
 			        $ignoreImport = false;
977 977
 			    }
@@ -979,23 +979,23 @@  discard block
 block discarded – undo
979 979
 		    }
980 980
 
981 981
 		    if (!$ignoreImport) {
982
-			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'])) {
983
-				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')));
982
+			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'])) {
983
+				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')));
984 984
 				$timeelapsed = microtime(true);
985 985
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986 986
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 987
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
988 988
 					$SpotterLive = new SpotterLive($this->db);
989
-					$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']);
989
+					$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']);
990 990
 					$SpotterLive->db = null;
991 991
 					if ($globalDebug) echo $result."\n";
992 992
 				    }
993 993
 				}
994 994
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995
-					$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']);
995
+					$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']);
996 996
 				}
997 997
 				$this->all_flights[$id]['putinarchive'] = false;
998
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
998
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
999 999
 
1000 1000
 				// Put statistics in $this->stats variable
1001 1001
 				//if ($line['format_source'] != 'aprs') {
@@ -1014,19 +1014,19 @@  discard block
 block discarded – undo
1014 1014
 							$latitude = $globalCenterLatitude;
1015 1015
 							$longitude = $globalCenterLongitude;
1016 1016
 						}
1017
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1017
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1018 1018
 					} else {
1019 1019
 						$latitude = $this->source_location[$source]['latitude'];
1020 1020
 						$longitude = $this->source_location[$source]['longitude'];
1021 1021
 					}
1022
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1022
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1023 1023
 					//$stats_heading = $stats_heading%22.5;
1024 1024
 					$stats_heading = round($stats_heading/22.5);
1025
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1025
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1026 1026
 					$current_date = date('Y-m-d');
1027 1027
 					if ($stats_heading == 16) $stats_heading = 0;
1028 1028
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029
-						for ($i=0;$i<=15;$i++) {
1029
+						for ($i = 0; $i <= 15; $i++) {
1030 1030
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1041,9 +1041,9 @@  discard block
 block discarded – undo
1041 1041
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1042 1042
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043 1043
 						    end($this->stats[$current_date][$source]['hist']);
1044
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1044
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1045 1045
 						} else $mini = 0;
1046
-						for ($i=$mini;$i<=$distance;$i+=10) {
1046
+						for ($i = $mini; $i <= $distance; $i += 10) {
1047 1047
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1048
 						}
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 				$this->all_flights[$id]['lastupdate'] = time();
1057 1057
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1058 1058
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
-			} 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";
1059
+			} 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";
1060 1060
 			//$this->del();
1061 1061
 			
1062 1062
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.