|
@@ -34,12 +34,12 @@ discard block |
|
|
block discarded – undo |
|
34
|
34
|
$currentdate = date('Y-m-d'); |
|
35
|
35
|
$sourcestat = $Stats->getStatsSource($currentdate); |
|
36
|
36
|
if (!empty($sourcestat)) { |
|
37
|
|
- foreach($sourcestat as $srcst) { |
|
|
37
|
+ foreach ($sourcestat as $srcst) { |
|
38
|
38
|
$type = $srcst['stats_type']; |
|
39
|
39
|
if ($type == 'polar' || $type == 'hist') { |
|
40
|
40
|
$source = $srcst['source_name']; |
|
41
|
41
|
$data = $srcst['source_data']; |
|
42
|
|
- $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
|
42
|
+ $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43
|
43
|
} |
|
44
|
44
|
} |
|
45
|
45
|
} |
|
@@ -51,14 +51,14 @@ discard block |
|
|
block discarded – undo |
|
51
|
51
|
if (isset($globalGeoid) && $globalGeoid) { |
|
52
|
52
|
try { |
|
53
|
53
|
$GeoidClass = new GeoidHeight(); |
|
54
|
|
- } catch(Exception $e) { |
|
|
54
|
+ } catch (Exception $e) { |
|
55
|
55
|
if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
56
|
56
|
$GeoidClass = FALSE; |
|
57
|
57
|
} |
|
58
|
58
|
} |
|
59
|
59
|
} |
|
60
|
60
|
|
|
61
|
|
- public function get_Schedule($id,$ident) { |
|
|
61
|
+ public function get_Schedule($id, $ident) { |
|
62
|
62
|
global $globalDebug, $globalFork, $globalSchedulesFetch; |
|
63
|
63
|
// Get schedule here, so it's done only one time |
|
64
|
64
|
|
|
@@ -83,8 +83,8 @@ discard block |
|
|
block discarded – undo |
|
83
|
83
|
$schedule = $Schedule->fetchSchedule($operator); |
|
84
|
84
|
if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
|
85
|
85
|
if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
|
86
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
|
87
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88
|
88
|
// Should also check if route schedule = route from DB |
|
89
|
89
|
if ($schedule['DepartureAirportIATA'] != '') { |
|
90
|
90
|
if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
|
@@ -104,7 +104,7 @@ discard block |
|
|
block discarded – undo |
|
104
|
104
|
} |
|
105
|
105
|
} |
|
106
|
106
|
} |
|
107
|
|
- $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
|
107
|
+ $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108
|
108
|
} |
|
109
|
109
|
} else $scheduleexist = true; |
|
110
|
110
|
} else $scheduleexist = true; |
|
@@ -112,7 +112,7 @@ discard block |
|
|
block discarded – undo |
|
112
|
112
|
if ($scheduleexist) { |
|
113
|
113
|
if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
114
|
114
|
$sch = $Schedule->getSchedule($operator); |
|
115
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
|
115
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116
|
116
|
} |
|
117
|
117
|
$Spotter->db = null; |
|
118
|
118
|
$Schedule->db = null; |
|
@@ -139,7 +139,7 @@ discard block |
|
|
block discarded – undo |
|
139
|
139
|
//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140
|
140
|
$Spotter = new Spotter($this->db); |
|
141
|
141
|
$real_arrival = $this->arrival($key); |
|
142
|
|
- if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
|
142
|
+ if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143
|
143
|
} |
|
144
|
144
|
} |
|
145
|
145
|
} |
|
@@ -153,7 +153,7 @@ discard block |
|
|
block discarded – undo |
|
153
|
153
|
$airport_time = ''; |
|
154
|
154
|
if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
155
|
155
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
156
|
|
- $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
|
156
|
+ $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157
|
157
|
if (isset($closestAirports[0])) { |
|
158
|
158
|
if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159
|
159
|
$airport_icao = $closestAirports[0]['icao']; |
|
@@ -168,7 +168,7 @@ discard block |
|
|
block discarded – undo |
|
168
|
168
|
break; |
|
169
|
169
|
} |
|
170
|
170
|
} |
|
171
|
|
- } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
|
171
|
+ } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172
|
172
|
$airport_icao = $closestAirports[0]['icao']; |
|
173
|
173
|
$airport_time = $this->all_flights[$key]['datetime']; |
|
174
|
174
|
} else { |
|
@@ -181,7 +181,7 @@ discard block |
|
|
block discarded – undo |
|
181
|
181
|
} else { |
|
182
|
182
|
if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183
|
183
|
} |
|
184
|
|
- return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
|
184
|
+ return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185
|
185
|
} |
|
186
|
186
|
|
|
187
|
187
|
|
|
@@ -192,7 +192,7 @@ discard block |
|
|
block discarded – undo |
|
192
|
192
|
if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
193
|
193
|
foreach ($this->all_flights as $key => $flight) { |
|
194
|
194
|
if (isset($flight['lastupdate'])) { |
|
195
|
|
- if ($flight['lastupdate'] < (time()-1800)) { |
|
|
195
|
+ if ($flight['lastupdate'] < (time() - 1800)) { |
|
196
|
196
|
$this->delKey($key); |
|
197
|
197
|
} |
|
198
|
198
|
} |
|
@@ -208,7 +208,7 @@ discard block |
|
|
block discarded – undo |
|
208
|
208
|
$real_arrival = $this->arrival($key); |
|
209
|
209
|
$Spotter = new Spotter($this->db); |
|
210
|
210
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
211
|
|
- $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
|
211
|
+ $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212
|
212
|
if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
213
|
213
|
} |
|
214
|
214
|
} |
|
@@ -241,10 +241,10 @@ discard block |
|
|
block discarded – undo |
|
241
|
241
|
$send = false; |
|
242
|
242
|
|
|
243
|
243
|
// SBS format is CSV format |
|
244
|
|
- if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
|
244
|
+ if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245
|
245
|
//print_r($line); |
|
246
|
246
|
if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247
|
|
- 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)) { |
|
|
247
|
+ 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)) { |
|
248
|
248
|
|
|
249
|
249
|
// Increment message number |
|
250
|
250
|
if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
|
@@ -277,25 +277,25 @@ discard block |
|
|
block discarded – undo |
|
277
|
277
|
if (!isset($this->all_flights[$id])) { |
|
278
|
278
|
if ($globalDebug) echo 'New flight...'."\n"; |
|
279
|
279
|
$this->all_flights[$id] = array(); |
|
280
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282
|
|
- if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
|
280
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
281
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
|
282
|
+ if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283
|
283
|
if (!isset($line['id'])) { |
|
284
|
284
|
if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285
|
285
|
// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
286
|
286
|
// if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
287
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === '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'))); |
|
|
287
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288
|
288
|
//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
289
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290
|
290
|
if ($globalAllFlights !== FALSE) $dataFound = true; |
|
291
|
291
|
} |
|
292
|
292
|
if (isset($line['source_type']) && $line['source_type'] != '') { |
|
293
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
|
293
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294
|
294
|
} |
|
295
|
295
|
|
|
296
|
296
|
//print_r($this->all_flights); |
|
297
|
297
|
if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
|
298
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
|
298
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299
|
299
|
//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
300
|
300
|
//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
301
|
301
|
//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
@@ -304,20 +304,20 @@ discard block |
|
|
block discarded – undo |
|
304
|
304
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
305
|
305
|
$Spotter = new Spotter($this->db); |
|
306
|
306
|
if (isset($this->all_flights[$id]['source_type'])) { |
|
307
|
|
- $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
|
307
|
+ $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308
|
308
|
} else { |
|
309
|
309
|
$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
|
310
|
310
|
} |
|
311
|
311
|
$Spotter->db = null; |
|
312
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
312
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
|
313
|
+ if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314
|
314
|
} |
|
315
|
315
|
} |
|
316
|
316
|
if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317
|
317
|
if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
318
|
318
|
} |
|
319
|
319
|
if (isset($line['id']) && !isset($line['hex'])) { |
|
320
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
|
320
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321
|
321
|
} |
|
322
|
322
|
if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
|
323
|
323
|
$icao = $line['aircraft_icao']; |
|
@@ -326,14 +326,14 @@ discard block |
|
|
block discarded – undo |
|
326
|
326
|
if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
327
|
327
|
$Spotter->db = null; |
|
328
|
328
|
} |
|
329
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
|
329
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
330
|
330
|
} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
|
331
|
331
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
332
|
332
|
// Get aircraft ICAO from aircraft name |
|
333
|
333
|
$Spotter = new Spotter($this->db); |
|
334
|
334
|
$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
|
335
|
335
|
$Spotter->db = null; |
|
336
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
336
|
+ if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
337
|
337
|
} |
|
338
|
338
|
} |
|
339
|
339
|
if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
|
@@ -341,15 +341,15 @@ discard block |
|
|
block discarded – undo |
|
341
|
341
|
elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
342
|
342
|
elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
343
|
343
|
elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
344
|
|
- if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
344
|
+ if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
345
|
345
|
} |
|
346
|
346
|
if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
|
347
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
|
347
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
348
|
348
|
} |
|
349
|
349
|
//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
350
|
|
- if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
|
350
|
+ if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
351
|
351
|
if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
352
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
|
352
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
353
|
353
|
} else { |
|
354
|
354
|
if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
355
|
355
|
elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
@@ -360,31 +360,31 @@ discard block |
|
|
block discarded – undo |
|
360
|
360
|
*/ |
|
361
|
361
|
return ''; |
|
362
|
362
|
} |
|
363
|
|
- } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
|
363
|
+ } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
364
|
364
|
if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
365
|
365
|
return ''; |
|
366
|
|
- } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
|
366
|
+ } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
367
|
367
|
if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
368
|
368
|
return ''; |
|
369
|
369
|
} elseif (!isset($line['datetime'])) { |
|
370
|
370
|
date_default_timezone_set('UTC'); |
|
371
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
|
371
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
372
|
372
|
} else { |
|
373
|
373
|
if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
374
|
374
|
return ''; |
|
375
|
375
|
} |
|
376
|
376
|
|
|
377
|
377
|
if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
|
378
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
|
378
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
379
|
379
|
} |
|
380
|
380
|
if (isset($line['waypoints']) && $line['waypoints'] != '') { |
|
381
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
|
381
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
382
|
382
|
} |
|
383
|
383
|
if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
|
384
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
|
384
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
385
|
385
|
} |
|
386
|
386
|
if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
|
387
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
|
387
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
388
|
388
|
} |
|
389
|
389
|
|
|
390
|
390
|
if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
|
@@ -392,13 +392,13 @@ discard block |
|
|
block discarded – undo |
|
392
|
392
|
if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
393
|
393
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
|
394
|
394
|
if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
395
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
396
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
397
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
398
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
399
|
|
- elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
395
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
396
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
397
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
|
398
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
399
|
+ elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
400
|
400
|
} else { |
|
401
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
401
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
402
|
402
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
403
|
403
|
$timeelapsed = microtime(true); |
|
404
|
404
|
$Spotter = new Spotter($this->db); |
|
@@ -408,13 +408,13 @@ discard block |
|
|
block discarded – undo |
|
408
|
408
|
elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
409
|
409
|
elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
410
|
410
|
elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
411
|
|
- $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
|
411
|
+ $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
412
|
412
|
if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
413
|
413
|
$Spotter->db = null; |
|
414
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
414
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
415
|
415
|
} |
|
416
|
416
|
} |
|
417
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
417
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418
|
418
|
|
|
419
|
419
|
/* |
|
420
|
420
|
if (!isset($line['id'])) { |
|
@@ -424,25 +424,25 @@ discard block |
|
|
block discarded – undo |
|
424
|
424
|
else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
425
|
425
|
} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
426
|
426
|
*/ |
|
427
|
|
- if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
427
|
+ if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428
|
428
|
|
|
429
|
429
|
//$putinarchive = true; |
|
430
|
430
|
if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
431
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
|
431
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
432
|
432
|
} |
|
433
|
433
|
if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
434
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
|
434
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
435
|
435
|
} |
|
436
|
436
|
if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
437
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
|
437
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
438
|
438
|
} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
439
|
439
|
$timeelapsed = microtime(true); |
|
440
|
440
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
441
|
441
|
$Spotter = new Spotter($this->db); |
|
442
|
442
|
$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
|
443
|
443
|
$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
|
444
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
444
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
|
445
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
446
|
446
|
} |
|
447
|
447
|
} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
448
|
448
|
$timeelapsed = microtime(true); |
|
@@ -456,35 +456,35 @@ discard block |
|
|
block discarded – undo |
|
456
|
456
|
$Translation->db = null; |
|
457
|
457
|
} |
|
458
|
458
|
$Spotter->db = null; |
|
459
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
459
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
460
|
460
|
} |
|
461
|
461
|
if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
|
462
|
462
|
//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
463
|
463
|
if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
464
|
464
|
// $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'])); |
|
465
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
|
465
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
466
|
466
|
} |
|
467
|
467
|
} |
|
468
|
468
|
if (!isset($globalFork)) $globalFork = TRUE; |
|
469
|
469
|
if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
|
470
|
|
- if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
|
470
|
+ if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
471
|
471
|
} |
|
472
|
472
|
} |
|
473
|
473
|
} |
|
474
|
474
|
|
|
475
|
475
|
if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
|
476
|
476
|
// $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
|
477
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
478
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
|
477
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
|
478
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
479
|
479
|
//$dataFound = true; |
|
480
|
480
|
} 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'])) { |
|
481
|
|
- $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
|
481
|
+ $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
482
|
482
|
if ($distance > 1000 && $distance < 10000) { |
|
483
|
483
|
// use datetime |
|
484
|
484
|
$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
|
485
|
485
|
$speed = $speed*3.6; |
|
486
|
486
|
if ($speed < 1000) { |
|
487
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
|
487
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
488
|
488
|
if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
489
|
489
|
} else { |
|
490
|
490
|
if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
@@ -499,9 +499,9 @@ discard block |
|
|
block discarded – undo |
|
499
|
499
|
if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
500
|
500
|
return false; |
|
501
|
501
|
} |
|
502
|
|
- if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
|
502
|
+ if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
503
|
503
|
else unset($timediff); |
|
504
|
|
- if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
|
504
|
+ if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
505
|
505
|
else unset($timediff_archive); |
|
506
|
506
|
if ($this->tmd > 5 |
|
507
|
507
|
|| (isset($line['format_source']) |
|
@@ -526,14 +526,14 @@ discard block |
|
|
block discarded – undo |
|
526
|
526
|
|| ($timediff > 30 |
|
527
|
527
|
&& isset($this->all_flights[$id]['latitude']) |
|
528
|
528
|
&& isset($this->all_flights[$id]['longitude']) |
|
529
|
|
- && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
|
529
|
+ && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
530
|
530
|
) |
|
531
|
531
|
) { |
|
532
|
532
|
|
|
533
|
533
|
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']))) { |
|
534
|
534
|
if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
535
|
535
|
|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
|
536
|
|
- || !$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'])) { |
|
|
536
|
+ || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
537
|
537
|
$this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
538
|
538
|
$this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
539
|
539
|
$this->all_flights[$id]['putinarchive'] = true; |
|
@@ -543,11 +543,11 @@ discard block |
|
|
block discarded – undo |
|
543
|
543
|
$timeelapsed = microtime(true); |
|
544
|
544
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
545
|
545
|
$Spotter = new Spotter($this->db); |
|
546
|
|
- $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
|
546
|
+ $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
547
|
547
|
if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
548
|
548
|
else $this->all_flights[$id]['over_country'] = ''; |
|
549
|
549
|
$Spotter->db = null; |
|
550
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
550
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
551
|
551
|
if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
552
|
552
|
} |
|
553
|
553
|
} |
|
@@ -573,13 +573,13 @@ discard block |
|
|
block discarded – undo |
|
573
|
573
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
574
|
574
|
} |
|
575
|
575
|
//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)) { |
|
576
|
|
- if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
|
576
|
+ if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
577
|
577
|
$this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
578
|
578
|
$dataFound = true; |
|
579
|
579
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
580
|
580
|
} |
|
581
|
581
|
// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
|
582
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
|
582
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
583
|
583
|
/* |
|
584
|
584
|
if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
|
585
|
585
|
$this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
@@ -601,13 +601,13 @@ discard block |
|
|
block discarded – undo |
|
601
|
601
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
602
|
602
|
} |
|
603
|
603
|
//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)) { |
|
604
|
|
- if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
|
604
|
+ if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
605
|
605
|
$this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
606
|
606
|
$dataFound = true; |
|
607
|
607
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
608
|
608
|
} |
|
609
|
609
|
// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
|
610
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
|
610
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
611
|
611
|
/* |
|
612
|
612
|
if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
|
613
|
613
|
$this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
@@ -625,46 +625,46 @@ discard block |
|
|
block discarded – undo |
|
625
|
625
|
} else if ($globalDebug && $timediff > 30) { |
|
626
|
626
|
$this->tmd = $this->tmd + 1; |
|
627
|
627
|
echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
|
628
|
|
- echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
629
|
|
- echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
|
628
|
+ echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
|
629
|
+ echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
630
|
630
|
echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
|
631
|
631
|
} |
|
632
|
632
|
} |
|
633
|
633
|
if (isset($line['last_update']) && $line['last_update'] != '') { |
|
634
|
634
|
if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
635
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
|
635
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
636
|
636
|
} |
|
637
|
637
|
if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
|
638
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
|
638
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
639
|
639
|
//$dataFound = true; |
|
640
|
640
|
} |
|
641
|
641
|
if (isset($line['format_source']) && $line['format_source'] != '') { |
|
642
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
|
642
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
643
|
643
|
} |
|
644
|
644
|
if (isset($line['source_name']) && $line['source_name'] != '') { |
|
645
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
|
645
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
646
|
646
|
} |
|
647
|
647
|
if (isset($line['emergency']) && $line['emergency'] != '') { |
|
648
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
|
648
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
649
|
649
|
//$dataFound = true; |
|
650
|
650
|
} |
|
651
|
651
|
if (isset($line['ground']) && $line['ground'] != '') { |
|
652
|
652
|
if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
653
|
653
|
// Here we force archive of flight because after ground it's a new one (or should be) |
|
654
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
655
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
656
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658
|
|
- elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
654
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
655
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
656
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
|
657
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
658
|
+ elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
659
|
659
|
} |
|
660
|
660
|
if ($line['ground'] != 1) $line['ground'] = 0; |
|
661
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
|
661
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
662
|
662
|
//$dataFound = true; |
|
663
|
663
|
} |
|
664
|
664
|
if (isset($line['squawk']) && $line['squawk'] != '') { |
|
665
|
665
|
if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666
|
666
|
if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
667
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
667
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
668
|
668
|
$highlight = ''; |
|
669
|
669
|
if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670
|
670
|
if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
@@ -673,66 +673,66 @@ discard block |
|
|
block discarded – undo |
|
673
|
673
|
$timeelapsed = microtime(true); |
|
674
|
674
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
675
|
675
|
$Spotter = new Spotter($this->db); |
|
676
|
|
- $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
|
676
|
+ $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
677
|
677
|
$Spotter->db = null; |
|
678
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
678
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
679
|
679
|
} |
|
680
|
680
|
//$putinarchive = true; |
|
681
|
681
|
//$highlight = ''; |
|
682
|
682
|
} |
|
683
|
683
|
|
|
684
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
684
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
685
|
685
|
//$dataFound = true; |
|
686
|
686
|
} |
|
687
|
687
|
|
|
688
|
688
|
if (isset($line['altitude']) && $line['altitude'] != '') { |
|
689
|
689
|
if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
|
690
|
690
|
if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
|
691
|
|
- $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
|
691
|
+ $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
692
|
692
|
//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
|
693
|
693
|
$line['altitude'] = $line['altitude'] - $geoid; |
|
694
|
694
|
} |
|
695
|
695
|
} |
|
696
|
696
|
//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697
|
|
- if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
699
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
|
697
|
+ if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
|
698
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
|
699
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
700
|
700
|
//$dataFound = true; |
|
701
|
701
|
//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702
|
702
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
703
|
703
|
if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
|
704
|
704
|
if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
705
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
706
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
707
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709
|
|
- elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
705
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
706
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
707
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
|
708
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
709
|
+ elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
710
|
710
|
} |
|
711
|
711
|
} |
|
712
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
|
712
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
713
|
713
|
} |
|
714
|
714
|
|
|
715
|
715
|
if (isset($line['noarchive']) && $line['noarchive'] === true) { |
|
716
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
|
716
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
717
|
717
|
} |
|
718
|
718
|
|
|
719
|
719
|
if (isset($line['heading']) && $line['heading'] != '') { |
|
720
|
|
- if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
|
720
|
+ if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
|
721
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
|
722
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
723
|
723
|
//$dataFound = true; |
|
724
|
724
|
} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
|
725
|
|
- $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727
|
|
- if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
|
725
|
+ $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
|
726
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
|
727
|
+ if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728
|
728
|
if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
729
|
729
|
} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
|
730
|
730
|
// If not enough messages and ACARS set heading to 0 |
|
731
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
|
731
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
732
|
732
|
} |
|
733
|
|
- if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734
|
|
- elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735
|
|
- elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
|
733
|
+ if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
|
734
|
+ elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
|
735
|
+ elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
736
|
736
|
|
|
737
|
737
|
// print_r($this->all_flights[$id]); |
|
738
|
738
|
//gets the callsign from the last hour |
|
@@ -743,7 +743,7 @@ discard block |
|
|
block discarded – undo |
|
743
|
743
|
if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
|
744
|
744
|
$this->all_flights[$id]['lastupdate'] = time(); |
|
745
|
745
|
if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
746
|
|
- 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'])) { |
|
|
746
|
+ if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747
|
747
|
//print_r($this->all_flights); |
|
748
|
748
|
//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
749
|
749
|
//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
@@ -754,61 +754,61 @@ discard block |
|
|
block discarded – undo |
|
754
|
754
|
$SpotterLive = new SpotterLive($this->db); |
|
755
|
755
|
if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
756
|
756
|
$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
757
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
757
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
758
|
758
|
} elseif (isset($line['id'])) { |
|
759
|
759
|
$recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
760
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
760
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
761
|
761
|
} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762
|
762
|
$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
763
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
763
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
764
|
764
|
} else $recent_ident = ''; |
|
765
|
|
- $SpotterLive->db=null; |
|
|
765
|
+ $SpotterLive->db = null; |
|
766
|
766
|
if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767
|
767
|
elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768
|
768
|
} else $recent_ident = ''; |
|
769
|
769
|
} else { |
|
770
|
770
|
$recent_ident = ''; |
|
771
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
|
771
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
772
|
772
|
} |
|
773
|
773
|
//if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774
|
|
- if($recent_ident == "") |
|
|
774
|
+ if ($recent_ident == "") |
|
775
|
775
|
{ |
|
776
|
776
|
if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
777
|
777
|
if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
778
|
778
|
if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
779
|
779
|
//adds the spotter data for the archive |
|
780
|
780
|
$ignoreImport = false; |
|
781
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
781
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
782
|
782
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
783
|
783
|
$ignoreImport = true; |
|
784
|
784
|
} |
|
785
|
785
|
} |
|
786
|
786
|
if (count($globalAirportAccept) > 0) { |
|
787
|
787
|
$ignoreImport = true; |
|
788
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
788
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
789
|
789
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
790
|
790
|
$ignoreImport = false; |
|
791
|
791
|
} |
|
792
|
792
|
} |
|
793
|
793
|
} |
|
794
|
794
|
if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
795
|
|
- foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796
|
|
- 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)) { |
|
|
795
|
+ foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
|
796
|
+ 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)) { |
|
797
|
797
|
$ignoreImport = true; |
|
798
|
798
|
} |
|
799
|
799
|
} |
|
800
|
800
|
} |
|
801
|
801
|
if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
802
|
802
|
$ignoreImport = true; |
|
803
|
|
- foreach($globalAirlineAccept as $airlineAccept) { |
|
804
|
|
- 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)) { |
|
|
803
|
+ foreach ($globalAirlineAccept as $airlineAccept) { |
|
|
804
|
+ 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)) { |
|
805
|
805
|
$ignoreImport = false; |
|
806
|
806
|
} |
|
807
|
807
|
} |
|
808
|
808
|
} |
|
809
|
809
|
if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
810
|
810
|
$ignoreImport = true; |
|
811
|
|
- foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
|
811
|
+ foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
812
|
812
|
if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
813
|
813
|
$ignoreImport = false; |
|
814
|
814
|
} |
|
@@ -820,32 +820,32 @@ discard block |
|
|
block discarded – undo |
|
820
|
820
|
if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821
|
821
|
if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822
|
822
|
if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823
|
|
- if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
823
|
+ if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824
|
824
|
$timeelapsed = microtime(true); |
|
825
|
825
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
826
|
826
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
827
|
827
|
$Spotter = new Spotter($this->db); |
|
828
|
|
- $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']); |
|
|
828
|
+ $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
829
|
829
|
$Spotter->db = null; |
|
830
|
830
|
if ($globalDebug && isset($result)) echo $result."\n"; |
|
831
|
831
|
} |
|
832
|
832
|
} |
|
833
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
833
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
834
|
834
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
835
|
835
|
|
|
836
|
836
|
// Add source stat in DB |
|
837
|
837
|
$Stats = new Stats($this->db); |
|
838
|
838
|
if (!empty($this->stats)) { |
|
839
|
839
|
if ($globalDebug) echo 'Add source stats : '; |
|
840
|
|
- foreach($this->stats as $date => $data) { |
|
841
|
|
- foreach($data as $source => $sourced) { |
|
|
840
|
+ foreach ($this->stats as $date => $data) { |
|
|
841
|
+ foreach ($data as $source => $sourced) { |
|
842
|
842
|
//print_r($sourced); |
|
843
|
|
- if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844
|
|
- if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
|
843
|
+ if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
|
844
|
+ if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
845
|
845
|
if (isset($sourced['msg'])) { |
|
846
|
846
|
if (time() - $sourced['msg']['date'] > 10) { |
|
847
|
847
|
$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
848
|
|
- echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
|
848
|
+ echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
849
|
849
|
unset($this->stats[$date][$source]['msg']); |
|
850
|
850
|
} |
|
851
|
851
|
} |
|
@@ -883,14 +883,14 @@ discard block |
|
|
block discarded – undo |
|
883
|
883
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
884
|
884
|
$SpotterLive = new SpotterLive($this->db); |
|
885
|
885
|
$SpotterLive->deleteLiveSpotterData(); |
|
886
|
|
- $SpotterLive->db=null; |
|
|
886
|
+ $SpotterLive->db = null; |
|
887
|
887
|
} |
|
888
|
888
|
} |
|
889
|
889
|
if ($globalDebug) echo " Done\n"; |
|
890
|
890
|
$this->last_delete = time(); |
|
891
|
891
|
} |
|
892
|
892
|
} else { |
|
893
|
|
- 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')) { |
|
|
893
|
+ 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')) { |
|
894
|
894
|
$this->all_flights[$id]['id'] = $recent_ident; |
|
895
|
895
|
$this->all_flights[$id]['addedSpotter'] = 1; |
|
896
|
896
|
} |
|
@@ -898,7 +898,7 @@ discard block |
|
|
block discarded – undo |
|
898
|
898
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
899
|
899
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
900
|
900
|
$Spotter = new Spotter($this->db); |
|
901
|
|
- $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']); |
|
|
901
|
+ $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
902
|
902
|
$Spotter->db = null; |
|
903
|
903
|
} |
|
904
|
904
|
} |
|
@@ -924,37 +924,37 @@ discard block |
|
|
block discarded – undo |
|
924
|
924
|
if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
925
|
925
|
if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
926
|
926
|
|
|
927
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
927
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
928
|
928
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
929
|
929
|
$ignoreImport = true; |
|
930
|
930
|
} |
|
931
|
931
|
} |
|
932
|
932
|
if (count($globalAirportAccept) > 0) { |
|
933
|
933
|
$ignoreImport = true; |
|
934
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
934
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
935
|
935
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
936
|
936
|
$ignoreImport = false; |
|
937
|
937
|
} |
|
938
|
938
|
} |
|
939
|
939
|
} |
|
940
|
940
|
if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
941
|
|
- foreach($globalAirlineIgnore as $airlineIgnore) { |
|
942
|
|
- 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)) { |
|
|
941
|
+ foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
|
942
|
+ 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)) { |
|
943
|
943
|
$ignoreImport = true; |
|
944
|
944
|
} |
|
945
|
945
|
} |
|
946
|
946
|
} |
|
947
|
947
|
if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
948
|
948
|
$ignoreImport = true; |
|
949
|
|
- foreach($globalAirlineAccept as $airlineAccept) { |
|
950
|
|
- 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)) { |
|
|
949
|
+ foreach ($globalAirlineAccept as $airlineAccept) { |
|
|
950
|
+ 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)) { |
|
951
|
951
|
$ignoreImport = false; |
|
952
|
952
|
} |
|
953
|
953
|
} |
|
954
|
954
|
} |
|
955
|
955
|
if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
956
|
956
|
$ignoreImport = true; |
|
957
|
|
- foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
|
957
|
+ foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
958
|
958
|
if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
959
|
959
|
$ignoreImport = false; |
|
960
|
960
|
} |
|
@@ -962,23 +962,23 @@ discard block |
|
|
block discarded – undo |
|
962
|
962
|
} |
|
963
|
963
|
|
|
964
|
964
|
if (!$ignoreImport) { |
|
965
|
|
- if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966
|
|
- if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
965
|
+ if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
|
966
|
+ if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
967
|
967
|
$timeelapsed = microtime(true); |
|
968
|
968
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
969
|
969
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970
|
970
|
if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
971
|
971
|
$SpotterLive = new SpotterLive($this->db); |
|
972
|
|
- $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']); |
|
|
972
|
+ $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
973
|
973
|
$SpotterLive->db = null; |
|
974
|
974
|
if ($globalDebug) echo $result."\n"; |
|
975
|
975
|
} |
|
976
|
976
|
} |
|
977
|
977
|
if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
|
978
|
|
- $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']); |
|
|
978
|
+ $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
979
|
979
|
} |
|
980
|
980
|
$this->all_flights[$id]['putinarchive'] = false; |
|
981
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
981
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
982
|
982
|
|
|
983
|
983
|
// Put statistics in $this->stats variable |
|
984
|
984
|
//if ($line['format_source'] != 'aprs') { |
|
@@ -997,19 +997,19 @@ discard block |
|
|
block discarded – undo |
|
997
|
997
|
$latitude = $globalCenterLatitude; |
|
998
|
998
|
$longitude = $globalCenterLongitude; |
|
999
|
999
|
} |
|
1000
|
|
- $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
|
1000
|
+ $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1001
|
1001
|
} else { |
|
1002
|
1002
|
$latitude = $this->source_location[$source]['latitude']; |
|
1003
|
1003
|
$longitude = $this->source_location[$source]['longitude']; |
|
1004
|
1004
|
} |
|
1005
|
|
- $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
|
1005
|
+ $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1006
|
1006
|
//$stats_heading = $stats_heading%22.5; |
|
1007
|
1007
|
$stats_heading = round($stats_heading/22.5); |
|
1008
|
|
- $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
|
1008
|
+ $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1009
|
1009
|
$current_date = date('Y-m-d'); |
|
1010
|
1010
|
if ($stats_heading == 16) $stats_heading = 0; |
|
1011
|
1011
|
if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
|
1012
|
|
- for ($i=0;$i<=15;$i++) { |
|
|
1012
|
+ for ($i = 0; $i <= 15; $i++) { |
|
1013
|
1013
|
$this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1014
|
1014
|
} |
|
1015
|
1015
|
$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
|
@@ -1024,9 +1024,9 @@ discard block |
|
|
block discarded – undo |
|
1024
|
1024
|
if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
|
1025
|
1025
|
if (isset($this->stats[$current_date][$source]['hist'][0])) { |
|
1026
|
1026
|
end($this->stats[$current_date][$source]['hist']); |
|
1027
|
|
- $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
|
1027
|
+ $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1028
|
1028
|
} else $mini = 0; |
|
1029
|
|
- for ($i=$mini;$i<=$distance;$i+=10) { |
|
|
1029
|
+ for ($i = $mini; $i <= $distance; $i += 10) { |
|
1030
|
1030
|
$this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031
|
1031
|
} |
|
1032
|
1032
|
$this->stats[$current_date][$source]['hist'][$distance] = 1; |
|
@@ -1039,7 +1039,7 @@ discard block |
|
|
block discarded – undo |
|
1039
|
1039
|
$this->all_flights[$id]['lastupdate'] = time(); |
|
1040
|
1040
|
if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1041
|
1041
|
//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1042
|
|
- } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
|
1042
|
+ } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1043
|
1043
|
//$this->del(); |
|
1044
|
1044
|
|
|
1045
|
1045
|
if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |